org.millscript.millscript.datatypes
Class XmlElement

java.lang.Object
  extended by org.millscript.millscript.datatypes.AbstractListAware
      extended by org.millscript.millscript.datatypes.XmlElement
All Implemented Interfaces:
java.io.Serializable, Fragment, ListAware, MapAware, Renderable

public final class XmlElement
extends AbstractListAware
implements Fragment, Renderable, java.io.Serializable

XmlElement is a lightweight objects that plays the role of an XML element. It is deliberately NOT compatible with the W3C DOM interface. That interface includes "back-pointers" from children to their parents -- a terrible design error that is slowly but surely being recognized as such.

See Also:
Implementation notes, Serialized Form

Constructor Summary
XmlElement(org.millscript.commons.xml.api.Name n, org.millscript.commons.xml.api.Attributes a, java.lang.Object[] c)
          Constructs a new XML element with the specified name, attributes and children.
 
Method Summary
 org.millscript.commons.util.IList asList()
          Returns this object as a List.
 java.lang.Object asOriginal(org.millscript.commons.util.IList<?> x)
          Returns a new object wrapping the supplied List.
 java.lang.Object get(int n)
          Returns the child at the specified position in this XML element.
 org.millscript.commons.xml.api.Attributes getAttributes()
          Returns a map containing all the elements attribute names and values.
 java.lang.Object[] getChildren()
          Returns an array of all this elements children.
 org.millscript.commons.xml.api.Name getName()
          Returns this elements Name.
 void render(Renderer r)
          This method is called to render the implementing object to the specified renderer.
 boolean sameAs(java.lang.Object x)
          Compares the specified object with this object, to see if they are the same type.
 int size()
          Returns the number of children this XML element has.
 java.lang.String tagName()
          Returns the name of the XML element.
 Atom tagWord()
          Returns the name of this XML element as an Atom.
 java.lang.String toString()
           
 
Methods inherited from class org.millscript.millscript.datatypes.AbstractListAware
asMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlElement

public XmlElement(org.millscript.commons.xml.api.Name n,
                  org.millscript.commons.xml.api.Attributes a,
                  java.lang.Object[] c)
Constructs a new XML element with the specified name, attributes and children.

Parameters:
n - the XML elements name
a - the XML elements attributes
c - the XML elements children
Method Detail

asList

public org.millscript.commons.util.IList asList()
Description copied from interface: ListAware
Returns this object as a List.

Specified by:
asList in interface ListAware
Returns:
a list containing all the items in this object.
See Also:
ListAware.asList()

asOriginal

public java.lang.Object asOriginal(org.millscript.commons.util.IList<?> x)
Description copied from interface: ListAware
Returns a new object wrapping the supplied List.

Specified by:
asOriginal in interface ListAware
Parameters:
x - a List to wrap in a copy of this object.
Returns:
an Object wrapping the supplied list.
See Also:
ListAware.asOriginal(org.millscript.commons.util.IList)

get

public java.lang.Object get(int n)
Returns the child at the specified position in this XML element.

Parameters:
n - the position of the required child
Returns:
the child at the specified position

getAttributes

public org.millscript.commons.xml.api.Attributes getAttributes()
Returns a map containing all the elements attribute names and values.

Returns:
a Map with this elements attribute name-value pairs

getChildren

public java.lang.Object[] getChildren()
Returns an array of all this elements children.

Returns:
an array of this elements children

getName

public org.millscript.commons.xml.api.Name getName()
Returns this elements Name.

Returns:
this elements Name

render

public void render(Renderer r)
            throws java.io.IOException
Description copied from interface: Renderable
This method is called to render the implementing object to the specified renderer.

If the implementing object is not a core part of MillScript you may need to query what type of renderer it is, so you can further customise your rendering as appropriate.

Specified by:
render in interface Renderable
Parameters:
r - the renderer to render this object with
Throws:
java.io.IOException - thrown if an IO problem occurs
See Also:
Renderable.render(Renderer)

sameAs

public boolean sameAs(java.lang.Object x)
Description copied from interface: ListAware
Compares the specified object with this object, to see if they are the same type.

Specified by:
sameAs in interface ListAware
Parameters:
x - Object to be compared for type with this object
Returns:
true if the specified object is the same type as this object
See Also:
ListAware.sameAs(java.lang.Object)

size

public int size()
Returns the number of children this XML element has.

Returns:
an int holding the number of children

tagName

public java.lang.String tagName()
Returns the name of the XML element.

Returns:
a String containing the XML element name

tagWord

public Atom tagWord()
Returns the name of this XML element as an Atom.

Returns:
an Atom for this XML elements name

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.