Package org.eigenbase.xom.wrappers

## Class W3CDOMWrapper

- java.lang.Object
- - org.eigenbase.xom.wrappers.W3CDOMWrapper

All Implemented Interfaces:
  `DOMWrapper`

    public class W3CDOMWrapper
    extends java.lang.Object
    implements DOMWrapper

This implementation of DOMWrapper wraps any w3c DOM-compliant java XML Parser.

### Field Summary

Fields
`(package private) org.w3c.dom.Node` `node`

### Fields inherited from interface org.eigenbase.xom.DOMWrapper

`CDATA, COMMENT, ELEMENT, FREETEXT, UNKNOWN`

### Constructor Summary

Constructors
`W3CDOMWrapper​(org.w3c.dom.Node node, Locator locator)` W3CDOMWrapper parses XML based on a Node.

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `getAttribute​(java.lang.String attrName)` Return the attribute.
`java.lang.String[]` `getAttributeNames()` Returns a list of attribute names.
`DOMWrapper[]` `getChildren()` Retrieve all children, and build an array of W3CDOMWrappers around each child that is of TEXT or ELEMENT type to return.
`DOMWrapper[]` `getElementChildren()` Retrieve all children, and build an array of W3CDOMWrappers around each ELEMENT child.
`Location` `getLocation()` Returns the location of this element.
`java.lang.String` `getTagName()` Retrieve the tag name directly.
`java.lang.String` `getText()` Recursively unwrap and create the contained text.
`int` `getType()` Map the Node's type to DOMWrapper's simplified concept of type.
`java.lang.String` `toXML()` Returns this node serialized as XML.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### node

    final org.w3c.dom.Node node

### Constructor Detail

#### W3CDOMWrapper

    public W3CDOMWrapper​(org.w3c.dom.Node node,
                         Locator locator)

W3CDOMWrapper parses XML based on a Node. The Node may be either an Element or some form of text node.

Parameters:
  `node` - DOM Node
  `locator` - Callback to find location of node. May be null.

### Method Detail

#### getType

    public int getType()

Map the Node's type to DOMWrapper's simplified concept of type.

Specified by:
  `getType` in interface `DOMWrapper`

#### getTagName

    public java.lang.String getTagName()

Retrieve the tag name directly. Return null immediately if not an element.

Specified by:
  `getTagName` in interface `DOMWrapper`

#### getAttribute

    public java.lang.String getAttribute​(java.lang.String attrName)

Return the attribute. Return null if the attribute isn't defined, or if not an element. This behavior differs from the underlying DOM, which returns an empty string for undefined attributes.

Specified by:
  `getAttribute` in interface `DOMWrapper`

#### getAttributeNames

    public java.lang.String[] getAttributeNames()

Description copied from interface: `DOMWrapper`
Returns a list of attribute names.

Specified by:
  `getAttributeNames` in interface `DOMWrapper`

#### getText

    public java.lang.String getText()

Recursively unwrap and create the contained text. If the node is a comment, return the comment text; but ignore comments inside elements.

Specified by:
  `getText` in interface `DOMWrapper`

#### toXML

    public java.lang.String toXML()

Description copied from interface: `DOMWrapper`
Returns this node serialized as XML.

Specified by:
  `toXML` in interface `DOMWrapper`

#### getChildren

    public DOMWrapper[] getChildren()

Retrieve all children, and build an array of W3CDOMWrappers around each child that is of TEXT or ELEMENT type to return.

Specified by:
  `getChildren` in interface `DOMWrapper`

#### getElementChildren

    public DOMWrapper[] getElementChildren()

Retrieve all children, and build an array of W3CDOMWrappers around each ELEMENT child.

Specified by:
  `getElementChildren` in interface `DOMWrapper`

#### getLocation

    public Location getLocation()

Description copied from interface: `DOMWrapper`
Returns the location of this element.

Specified by:
  `getLocation` in interface `DOMWrapper`