FileDocCategorySizeDatePackage
AbstractAdapterNode.javaAPI DocExample11059Mon Jul 23 13:26:44 BST 2007org.apache.struts2.views.xslt

AbstractAdapterNode

public abstract class AbstractAdapterNode extends Object implements AdapterNode
AbstractAdapterNode is the base for childAdapters that expose a read-only view of a Java object as a DOM Node. This class implements the core parent-child and sibling node traversal functionality shared by all adapter type nodes and used in proxy node support.
see
AbstractAdapterElement

Fields Summary
private static final NamedNodeMap
EMPTY_NAMEDNODEMAP
private List
childAdapters
private Log
log
private Object
propertyValue
private String
propertyName
private AdapterNode
parent
private AdapterFactory
adapterFactory
Constructors Summary
public AbstractAdapterNode()



      
        if (LogFactory.getLog(getClass()).isDebugEnabled()) {
            LogFactory.getLog(getClass()).debug("Creating " + this);
        }
    
Methods Summary
public org.w3c.dom.NodeappendChild(org.w3c.dom.Node node)

        throw operationNotSupported();
    
protected java.util.ListbuildChildAdapters()
subclasses override to produce their children

return
List of child adapters.

        return new ArrayList<Node>();
    
public org.w3c.dom.NodecloneNode(boolean b)

        log.trace("cloneNode");
        throw operationNotSupported();
    
public shortcompareDocumentPosition(org.w3c.dom.Node node)

        throw operationNotSupported();
    
public AdapterFactorygetAdapterFactory()

        return adapterFactory;
    
public org.w3c.dom.NamedNodeMapgetAttributes()

        return EMPTY_NAMEDNODEMAP;
    
public java.lang.StringgetBaseURI()

        throw operationNotSupported();
    
protected java.util.ListgetChildAdapters()
Lazily initialize child childAdapters

        if (childAdapters == null) {
            childAdapters = buildChildAdapters();
        }
        return childAdapters;
    
public org.w3c.dom.NodegetChildAfter(org.w3c.dom.Node child)

        log.trace("getChildafter");
        return getChildBeforeOrAfter(child, false/*after*/);
    
public org.w3c.dom.NodegetChildBefore(org.w3c.dom.Node child)

        log.trace("getchildbefore");
        return getChildBeforeOrAfter(child, true/*after*/);
    
public org.w3c.dom.NodegetChildBeforeOrAfter(org.w3c.dom.Node child, boolean before)

        log.debug("getChildBeforeOrAfter: ");
        List adapters = getChildAdapters();
        log.debug("childAdapters = " + adapters);
        log.debug("child = " + child);
        int index = adapters.indexOf(child);
        if (index < 0)
            throw new StrutsException(child + " is no child of " + this);
        int siblingIndex = before ? index - 1 : index + 1;
        return ((0 < siblingIndex) && (siblingIndex < adapters.size())) ?
                ((Node) adapters.get(siblingIndex)) : null;
    
public org.w3c.dom.NodeListgetChildNodes()

        NodeList nl = new SimpleNodeList(getChildAdapters());
        if (log.isDebugEnabled())
            log.debug("getChildNodes for tag: "
                    + getNodeName() + " num children: " + nl.getLength());
        return nl;
    
public org.w3c.dom.NodeListgetElementsByTagName(java.lang.String tagName)

        if (tagName.equals("*")) {
            return getChildNodes();
        } else {
            LinkedList<Node> filteredChildren = new LinkedList<Node>();

            for (Node adapterNode : getChildAdapters()) {
                if (adapterNode.getNodeName().equals(tagName)) {
                    filteredChildren.add(adapterNode);
                }
            }

            return new SimpleNodeList(filteredChildren);
        }
    
public org.w3c.dom.NodeListgetElementsByTagNameNS(java.lang.String string, java.lang.String string1)

        // TODO:
        return null;
    
public java.lang.ObjectgetFeature(java.lang.String string, java.lang.String string1)

        throw operationNotSupported();
    
public org.w3c.dom.NodegetFirstChild()

        return (getChildNodes().getLength() > 0) ? getChildNodes().item(0) : null;
    
public org.w3c.dom.NodegetLastChild()

        return (getChildNodes().getLength() > 0) ? getChildNodes().item(getChildNodes().getLength() - 1) : null;
    
public java.lang.StringgetLocalName()

        return null;
    
public java.lang.StringgetNamespaceURI()

        return null;
    
public org.w3c.dom.NodegetNextSibling()

        Node next = getParent().getChildAfter(this);
        if (log.isTraceEnabled()) {
            log.trace("getNextSibling on " + getNodeName() + ": "
                    + ((next == null) ? "null" : next.getNodeName()));
        }

        return getParent().getChildAfter(this);
    
public java.lang.StringgetNodeName()

        throw operationNotSupported();
    
public shortgetNodeType()

        throw operationNotSupported();
    
public java.lang.StringgetNodeValue()

        throw operationNotSupported();
    
public org.w3c.dom.DocumentgetOwnerDocument()

        return null;
    
public AdapterNodegetParent()

        return parent;
    
public org.w3c.dom.NodegetParentNode()

        log.trace("getParentNode");
        return getParent();
    
public java.lang.StringgetPrefix()

        return null;
    
public org.w3c.dom.NodegetPreviousSibling()

        return getParent().getChildBefore(this);
    
public java.lang.StringgetPropertyName()

        return propertyName;
    
public java.lang.ObjectgetPropertyValue()

        return propertyValue;
    
public java.lang.StringgetTextContent()

        throw operationNotSupported();
    
public java.lang.ObjectgetUserData(java.lang.String string)

        throw operationNotSupported();
    
public booleanhasAttributes()

        return false;
    
public booleanhasChildNodes()

        return false;
    
public org.w3c.dom.NodeinsertBefore(org.w3c.dom.Node node, org.w3c.dom.Node node1)

        throw operationNotSupported();
    
public booleanisDefaultNamespace(java.lang.String string)

        throw operationNotSupported();
    
public booleanisEqualNode(org.w3c.dom.Node node)

        throw operationNotSupported();
    
public booleanisSameNode(org.w3c.dom.Node node)

        throw operationNotSupported();
    
public booleanisSupported(java.lang.String string, java.lang.String string1)

        throw operationNotSupported();
    
public java.lang.StringlookupNamespaceURI(java.lang.String string)

        throw operationNotSupported();
    
public java.lang.StringlookupPrefix(java.lang.String string)

        throw operationNotSupported();
    
public voidnormalize()

        log.trace("normalize");
        throw operationNotSupported();
    
protected org.apache.struts2.StrutsExceptionoperationNotSupported()

        return new StrutsException("Operation not supported.");
    
public org.w3c.dom.NoderemoveChild(org.w3c.dom.Node node)

        throw operationNotSupported();
    
public org.w3c.dom.NodereplaceChild(org.w3c.dom.Node node, org.w3c.dom.Node node1)

        throw operationNotSupported();
    
public voidsetAdapterFactory(AdapterFactory adapterFactory)

        this.adapterFactory = adapterFactory;
    
protected voidsetContext(AdapterFactory adapterFactory, AdapterNode parent, java.lang.String propertyName, java.lang.Object value)

param
adapterFactory
param
parent
param
propertyName
param
value

        setAdapterFactory(adapterFactory);
        setParent(parent);
        setPropertyName(propertyName);
        setPropertyValue(value);
    
public voidsetNodeValue(java.lang.String string)

        throw operationNotSupported();
    
public voidsetParent(AdapterNode parent)

        this.parent = parent;
    
public voidsetPrefix(java.lang.String string)

        throw operationNotSupported();
    
public voidsetPropertyName(java.lang.String name)

        this.propertyName = name;
    
public voidsetPropertyValue(java.lang.Object prop)

        this.propertyValue = prop;
    
public voidsetTextContent(java.lang.String string)

        throw operationNotSupported();

    
public java.lang.ObjectsetUserData(java.lang.String string, java.lang.Object object, org.w3c.dom.UserDataHandler userDataHandler)

        throw operationNotSupported();
    
public java.lang.StringtoString()

        return getClass() + ": " + getNodeName() + " parent=" + getParentNode();