001/*
002 *  Copyright 2012 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016
017package org.ametys.core.util.dom;
018
019import org.w3c.dom.Element;
020
021/**
022 * DOM layer on top if an object hierarchy.
023 * @param <T> the actual type of the wrapped object.
024 */
025public abstract class AbstractWrappingAmetysElement<T> extends AbstractAmetysElement
026{
027    /** The wrapper object. */
028    protected T _object;
029    
030    /**
031     * Constructor.
032     * @param object the underlying object.
033     */
034    public AbstractWrappingAmetysElement(T object)
035    {
036        this(object, null);
037    }
038
039    /**
040     * Constructor.
041     * @param tagName the tag name.
042     * @param object the underlying object.
043     */
044    public AbstractWrappingAmetysElement(String tagName, T object)
045    {
046        this(tagName, object, null);
047    }
048
049    /**
050     * Constructor.
051     * @param object the underlying object.
052     * @param parent the parent {@link Element}.
053     */
054    public AbstractWrappingAmetysElement(T object, Element parent)
055    {
056        super(parent);
057        _object = object;
058    }
059
060    /**
061     * Constructor.
062     * @param tagName the tag name.
063     * @param object the underlying object.
064     * @param parent the parent {@link Element}.
065     */
066    public AbstractWrappingAmetysElement(String tagName, T object, Element parent)
067    {
068        super(tagName, parent);
069        _object = object;
070    }
071    
072    /**
073     * Returns the wrapped object.
074     * @return the wrapped object.
075     */
076    public T getWrappedObject()
077    {
078        return _object;
079    }
080}