org.jbind.xml.instance.impl
Class ElementImpl

java.lang.Object
  extended byorg.jbind.xml.instance.impl.Impl
      extended byorg.jbind.xml.instance.impl.DataImpl
          extended byorg.jbind.xml.instance.impl.ElementImpl
All Implemented Interfaces:
IDataImpl, IElementImpl, IHasLocation, IImpl, IImplChild, IImplContainer, IImplWithText

public class ElementImpl
extends DataImpl
implements IElementImpl


Constructor Summary
ElementImpl(IImplContainer aParent, java.lang.String aNamespace, java.lang.String aName, java.util.Map aPrefixMapping, ILocation aLocation)
           
 
Method Summary
 void accept(IDataImplVisitor aVisitor)
           
 IAttributeImpl addAttribute(java.lang.String aNamespace, java.lang.String aQName, ITextContentProvider aProvider, boolean anIsDefault, ILocation aLocation)
           
 IAttributeImpl addAttribute(java.lang.String aNamespace, java.lang.String aQName, java.lang.String aValue, boolean anIsDefault, ILocation aLocation)
          Adds an attribute.
 IElementImpl addElement(java.lang.String aNamespace, java.lang.String aQName)
          Adds a new element.
 IElementImpl addElement(java.lang.String aNamespace, java.lang.String aQName, java.util.Map aPrefixMapping, ILocation aLocation)
          Adds a new element implementation.
 ITextImpl addText(java.lang.String aText, ILocation aLocation)
          Adds a new text implementation.
 IAnyTypeData getAttributeData(java.lang.String aNamespace, java.lang.String aName)
          Gets the data object of an attribute.
 IAttributeImpl getAttributeImpl(java.lang.String aNamespace, java.lang.String aName)
          Gets an attribute implementation.
 java.lang.String getDefaultTextContent()
           
 java.lang.String getNamespaceForPrefix(java.lang.String aPrefix)
          Gets a namespace for a prefix.
 java.lang.String getPrefixForNamespace(java.lang.String aNamespace, boolean aCreate)
          Gets a prefix for a namespace.
 java.util.Map getPrefixToNamespaceMapping()
          Gets the prefix to namespace mapping.
 java.lang.String getTextContent()
          Gets the textual content.
 boolean hasTextContent()
          Checks if the implementation has textual content.
 boolean isDefault()
          Checks if the data implementation is a default value or if a value was assigned explicitly.
 boolean isNil()
          Indicates if the data implementation was assigned "nil".
 java.util.Iterator iterAttributeImpls()
          Iterates the attribute implementations.
 java.util.Iterator iterAttributes(java.lang.String aNamespace, java.lang.String aName)
          Iterates the attribute data objects for the specified namespace and name.
 java.util.ListIterator iterChildren()
          Iterates the children.
 java.util.ListIterator iterElementData(java.lang.String aNamespace, java.lang.String aName)
          Iterates the data objects for the specified namespace and element name.
 void removeAttribute(java.lang.String aNamespace, java.lang.String aName)
           
 void restoreTextContent(ITextContentMemento aMemento)
           
 ITextContentMemento saveTextContent()
           
 void setDefaultAttrCreator(IDefaultAttrCreator aCreator)
           
 void setDefaultTextContent(java.lang.String aString)
           
 void setTextContent(ITextContentProvider aTextContentProvider)
          Sets the textual content by specifiying a provider for lazy evaluation.
 void setTextContent(java.lang.String aString)
          Sets the textual content.
 
Methods inherited from class org.jbind.xml.instance.impl.DataImpl
getData, getNamespace, getParent, getParentImpl, getPartName, setData
 
Methods inherited from class org.jbind.xml.instance.impl.Impl
getLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jbind.xml.core.bridge.IDataImpl
getData, getNamespace, getPartName, setData
 
Methods inherited from interface org.jbind.xml.base.IHasLocation
getLocation
 
Methods inherited from interface org.jbind.xml.core.bridge.IImplChild
getParentImpl
 

Constructor Detail

ElementImpl

public ElementImpl(IImplContainer aParent,
                   java.lang.String aNamespace,
                   java.lang.String aName,
                   java.util.Map aPrefixMapping,
                   ILocation aLocation)
Method Detail

accept

public void accept(IDataImplVisitor aVisitor)
            throws XmlException
Specified by:
accept in interface IImpl
Throws:
XmlException

addElement

public IElementImpl addElement(java.lang.String aNamespace,
                               java.lang.String aQName)
Description copied from interface: IImplContainer
Adds a new element. Calls the method addElement(aNamespace, aName, aPrefixMappings, aLocation) with the prefix mappings of this data implementation and the location set to null.

Specified by:
addElement in interface IImplContainer
Parameters:
aNamespace - (required).

addElement

public IElementImpl addElement(java.lang.String aNamespace,
                               java.lang.String aQName,
                               java.util.Map aPrefixMapping,
                               ILocation aLocation)
Description copied from interface: IImplContainer
Adds a new element implementation.

Specified by:
addElement in interface IImplContainer
Parameters:
aNamespace - (required).
aQName - (required).
aPrefixMapping - (required).
aLocation - (optional).
Returns:
(required). The newly created element implementation.

iterChildren

public java.util.ListIterator iterChildren()
Description copied from interface: IImpl
Iterates the children.

Specified by:
iterChildren in interface IImpl
Returns:
(required). A list iterator of IImpl.

iterElementData

public java.util.ListIterator iterElementData(java.lang.String aNamespace,
                                              java.lang.String aName)
Description copied from interface: IImpl
Iterates the data objects for the specified namespace and element name.

Specified by:
iterElementData in interface IImpl
Parameters:
aNamespace - (required).
aName - (required).
Returns:
(required). An iterator of IAnyTypeData.

isNil

public boolean isNil()
Description copied from interface: IImpl
Indicates if the data implementation was assigned "nil".

Specified by:
isNil in interface IImpl
Returns:
Returns true iff the data implementation was assigned "nil".

addAttribute

public IAttributeImpl addAttribute(java.lang.String aNamespace,
                                   java.lang.String aQName,
                                   ITextContentProvider aProvider,
                                   boolean anIsDefault,
                                   ILocation aLocation)
Specified by:
addAttribute in interface IElementImpl

addAttribute

public IAttributeImpl addAttribute(java.lang.String aNamespace,
                                   java.lang.String aQName,
                                   java.lang.String aValue,
                                   boolean anIsDefault,
                                   ILocation aLocation)
Description copied from interface: IElementImpl
Adds an attribute.

Specified by:
addAttribute in interface IElementImpl
Parameters:
aNamespace - (required).
aQName - (required).
aValue - (required).
aLocation - (optional).
Returns:
(required).

getAttributeData

public IAnyTypeData getAttributeData(java.lang.String aNamespace,
                                     java.lang.String aName)
Description copied from interface: IImpl
Gets the data object of an attribute.

Specified by:
getAttributeData in interface IImpl
Parameters:
aNamespace - (required).
aName - (required).
Returns:
(optional).

getAttributeImpl

public IAttributeImpl getAttributeImpl(java.lang.String aNamespace,
                                       java.lang.String aName)
Description copied from interface: IElementImpl
Gets an attribute implementation.

Specified by:
getAttributeImpl in interface IElementImpl
Parameters:
aNamespace - (required).
aName - (required).
Returns:
(optional).

iterAttributeImpls

public java.util.Iterator iterAttributeImpls()
Description copied from interface: IElementImpl
Iterates the attribute implementations.

Specified by:
iterAttributeImpls in interface IElementImpl
Returns:
(required). An iterator of IAttributeImpl.

removeAttribute

public void removeAttribute(java.lang.String aNamespace,
                            java.lang.String aName)
                     throws XmlException
Specified by:
removeAttribute in interface IElementImpl
Throws:
XmlException

setDefaultAttrCreator

public void setDefaultAttrCreator(IDefaultAttrCreator aCreator)
Specified by:
setDefaultAttrCreator in interface IElementImpl

iterAttributes

public java.util.Iterator iterAttributes(java.lang.String aNamespace,
                                         java.lang.String aName)
Description copied from interface: IDataImpl
Iterates the attribute data objects for the specified namespace and name.

Specified by:
iterAttributes in interface IDataImpl
Parameters:
aNamespace - (optional).
aName - (optional).
Returns:
(required). An iterator of IAnyTypeData.

getDefaultTextContent

public java.lang.String getDefaultTextContent()

setDefaultTextContent

public void setDefaultTextContent(java.lang.String aString)
Specified by:
setDefaultTextContent in interface IElementImpl

addText

public ITextImpl addText(java.lang.String aText,
                         ILocation aLocation)
Description copied from interface: IImplContainer
Adds a new text implementation.

Specified by:
addText in interface IImplContainer
Parameters:
aText - (required).
Returns:
(required). The newly created text implementation.

isDefault

public boolean isDefault()
Description copied from interface: IImplWithText
Checks if the data implementation is a default value or if a value was assigned explicitly.

Specified by:
isDefault in interface IImplWithText
Returns:
Returns true iff the data implementation is a default value.

getPrefixToNamespaceMapping

public java.util.Map getPrefixToNamespaceMapping()
Description copied from interface: IImpl
Gets the prefix to namespace mapping.

Specified by:
getPrefixToNamespaceMapping in interface IImpl
Returns:
(required).

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String aPrefix)
Description copied from interface: IElementImpl
Gets a namespace for a prefix.

Specified by:
getNamespaceForPrefix in interface IElementImpl
Parameters:
aPrefix - (required).
Returns:
(optional).

getPrefixForNamespace

public java.lang.String getPrefixForNamespace(java.lang.String aNamespace,
                                              boolean aCreate)
Description copied from interface: IElementImpl
Gets a prefix for a namespace.

Specified by:
getPrefixForNamespace in interface IElementImpl
Parameters:
aNamespace - (required).
aCreate - If the create parameter is true then a new mapping is created for the prefix if there is not already one.
Returns:
(optional).

hasTextContent

public boolean hasTextContent()
Description copied from interface: IImplWithText
Checks if the implementation has textual content. This method is used to decide if a default value should be used or not.

Attribute implementations will always return true because attributes take their default values only if they are not present in the instance.

Element implementation will return true iff their text content is null or equal to the empty string. In other words the default value of an element is used when the element is empty. (cf. the note at W3C XML-Schema-Structure specification section 3.1.1).

Specified by:
hasTextContent in interface IImplWithText
Returns:
Returns true iff there is textual content.

saveTextContent

public ITextContentMemento saveTextContent()
Specified by:
saveTextContent in interface IImplWithText

restoreTextContent

public void restoreTextContent(ITextContentMemento aMemento)
Specified by:
restoreTextContent in interface IImplWithText

getTextContent

public java.lang.String getTextContent()
Description copied from interface: IImplWithText
Gets the textual content. The textual content corresponds to the lexical value of a data object. For data implementations of attributes the string that is assigned to the attribute is returned. For data implementations of elements with simple content the string value that is assigned to the simple content is returned. If the simple content is empty then the empty string is returned.

Specified by:
getTextContent in interface IImplWithText
Returns:
(required).

setTextContent

public void setTextContent(ITextContentProvider aTextContentProvider)
Description copied from interface: IImplWithText
Sets the textual content by specifiying a provider for lazy evaluation.

Specified by:
setTextContent in interface IImplWithText
Parameters:
aTextContentProvider - (required).

setTextContent

public void setTextContent(java.lang.String aString)
Description copied from interface: IImplWithText
Sets the textual content. The textual content corresponds to the lexical value of a data object.

Specified by:
setTextContent in interface IImplWithText
Parameters:
aString - (required).