com.simonstl.moe
Class CoreComponent

java.lang.Object
  |
  +--com.simonstl.moe.CoreComponent
All Implemented Interfaces:
AnnotableI, java.lang.Cloneable, CoreComponentI, NamingI
Direct Known Subclasses:
Attribute, CDATASect, Characters, Comment, Document, Element, EndDocument, Mutable

public abstract class CoreComponent
extends java.lang.Object
implements CoreComponentI, AnnotableI

The CoreComponent class implements the bare minimum of functionality needed for objects to work with MOE.

Note that while this class implements the AnnotableI interface, it delegates all of the work to an Annotations object.

Similarly, all of the processing of the NamingI interface is delegated to a Name object.

version 0.01 is the initial release and contains plenty of bogus placeholder functionality.

Version:
0.01 7 September 2001
Author:
Simon St.Laurent

Field Summary
protected  AnnotableI annotations
          contains the annotations - often type information - for this component.
protected  boolean complete
          indicates whether the component contains all of its child parts.
protected  int componentType
          an int identifying the base type of this component.
protected  ComponentList content
          contains the ordered content (typically elements) for the component.
protected  CoreComponent context
          used by listen().
protected  Name name
          contains the name information for component (if any)
protected  CoreComponentI parent
          identifies the parent of this component.
protected  ComponentSet unorderedContent
          contains the unordered content (typically attributes) for the component.
 
Fields inherited from interface com.simonstl.moe.CoreComponentI
ATTRIBUTE, CDATA, CHARS, COMMENT, CONTAINER, DOCTYPE, DOCUMENT, ELEMENT, END_ATTRIBUTE, END_CDATA, END_COMMENT, END_CONTAINER, END_DOCTYPE, END_DOCUMENT, END_ELEMENT, END_NAMESPACE, END_PI, END_PROPERTY, GEN_ENTITY_END, GEN_ENTITY_REF, GEN_ENTITY_START, IG_WHITESPACE, NAMESPACE_DECL, PI, PROPERTY, UNPARSED, VALUE, XML_DECL
 
Constructor Summary
CoreComponent()
           
 
Method Summary
protected  CoreComponentI add(CoreComponentI component, CoreComponentI context)
           
 void addAll(java.util.Map otherAnnotations)
           
 void addContent(CoreComponentI newComponent)
          Adds content to this component.
 void addUnorderedContent(CoreComponentI newComponent)
          Adds an unordered component (usually an attribute) to a component.
 void annotate(java.lang.Object annotationType, java.lang.Object annotation)
          The annotate() method allows developers to add different kinds of annotation information to components.
 void clearAll()
          Clears the name, namespace information, and content for this component.
 void clearContent()
          Clears the content for this component.
 void clearName()
          Clears the name and namespace information for this component.
 void clearUnorderedContent()
          Clears the unordered content (usually attributes) for this component.
 java.lang.Object clone()
          Non-clone implementation needs replacement.
 java.util.Map getAllAnnotations()
          This method allows developers to retrieve all annotations at once.
 java.lang.Object getAnnotations(java.lang.Object ofAnnotationType)
          This method allows developers to retrieve annotations of one particular type.
abstract  int getBasicType()
          CoreComponent has no basic type - subclasses MUST provide one.
 ComponentListI getContent()
          Returns the content for this component as a list of nodes.
 boolean getIsComplete()
          Returns whether this object is complete (i.e., an element has ended).
 java.lang.String getLocalName()
          Returns the local name for the component
 NamingI getName()
          Returns the name object for the component.
 java.lang.String getNsURI()
          Returns the URI reference value for the namespace.
 CoreComponentI getParent()
          Returns the parent for the component.
 java.lang.String getPrefix()
          Returns the prefix used to represent the namespace URI reference for this component.
 java.lang.String getQName()
          Returns the Qualified Name (QName) for the component.
 java.lang.String getTextContent()
          Returns the content for this component as a string.
 java.util.Set getTypes()
          Returns a Set containing the types of all annotations stored in this object
 ComponentSetI getUnorderedContent()
          Returns the unordered content for this component.
 boolean hasAnnotation(java.lang.Object annotation)
          Indicates whether the provided object is stored as an annotation (of any type)
 boolean hasAnnotationOfType(java.lang.Object ofAnnotationType)
          Indicates whether there are any annotations of the given type.
 boolean hasAnnotations()
           
 int hashCode()
          The hashCode() method uses nsURI+">"+localName to generate an int.
 boolean listen(CoreComponentI component)
          Accepts new events.
 void print()
          Prints a representation of the component to STDOUT
 void removeAllAnnotations()
          This method allows developers to remove all annotations at once.
 void removeAnnotation(java.lang.Object ofAnnotationType)
          This method allows developers to remove a single annotation.
 void setContent(ComponentListI _content)
          Sets the content for this component as a list of nodes.
 void setContent(java.lang.String _content)
          Sets the content for this component as a string.
 void setIsComplete(boolean _complete)
          Sets whether this object is complete (i.e., an element has ended).
 void setLocalName(java.lang.String _localName)
          Accepts a string which will serve as the local name for this component.
 void setName(NamingI _name)
          Sets the name object for the component.
 void setNsURI(java.lang.String _nsURI)
          Accepts a URI reference value which is used as the namespace for the component.
 void setParent(CoreComponentI _parent)
          Sets the parent object for the component.
 void setPrefix(java.lang.String _prefix)
          Accepts a string which serves as the prefix for this component.
 void setQName(java.lang.String QName)
          Sets the Qualified Name (QName) for the component.
 void setUnorderedContent(ComponentSetI newContent)
          Sets the unordered content for this component.
protected  CoreComponentI textComponent()
           
abstract  java.lang.String toString()
          Returns a representation of the component as a String.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.simonstl.moe.CoreComponentI
toString
 

Field Detail

name

protected Name name
contains the name information for component (if any)

content

protected ComponentList content
contains the ordered content (typically elements) for the component.

unorderedContent

protected ComponentSet unorderedContent
contains the unordered content (typically attributes) for the component.

complete

protected boolean complete
indicates whether the component contains all of its child parts.

componentType

protected int componentType
an int identifying the base type of this component.

annotations

protected AnnotableI annotations
contains the annotations - often type information - for this component.

parent

protected CoreComponentI parent
identifies the parent of this component.

context

protected CoreComponent context
used by listen().
Constructor Detail

CoreComponent

public CoreComponent()
Method Detail

hashCode

public int hashCode()
The hashCode() method uses nsURI+">"+localName to generate an int. If you need something more precise, you'll need to override this.
Specified by:
hashCode in interface CoreComponentI
Overrides:
hashCode in class java.lang.Object

setNsURI

public void setNsURI(java.lang.String _nsURI)
Description copied from interface: CoreComponentI
Accepts a URI reference value which is used as the namespace for the component.
Specified by:
setNsURI in interface CoreComponentI

getNsURI

public java.lang.String getNsURI()
Description copied from interface: CoreComponentI
Returns the URI reference value for the namespace.
Specified by:
getNsURI in interface CoreComponentI

setLocalName

public void setLocalName(java.lang.String _localName)
Description copied from interface: CoreComponentI
Accepts a string which will serve as the local name for this component.
Specified by:
setLocalName in interface CoreComponentI

getLocalName

public java.lang.String getLocalName()
Description copied from interface: CoreComponentI
Returns the local name for the component
Specified by:
getLocalName in interface CoreComponentI

setPrefix

public void setPrefix(java.lang.String _prefix)
Description copied from interface: CoreComponentI
Accepts a string which serves as the prefix for this component.
Specified by:
setPrefix in interface CoreComponentI

getPrefix

public java.lang.String getPrefix()
Description copied from interface: CoreComponentI
Returns the prefix used to represent the namespace URI reference for this component.
Specified by:
getPrefix in interface CoreComponentI

getQName

public java.lang.String getQName()
Returns the Qualified Name (QName) for the component.
Specified by:
getQName in interface CoreComponentI

setQName

public void setQName(java.lang.String QName)
Sets the Qualified Name (QName) for the component. Overrides current local name and prefix, if any.
Specified by:
setQName in interface CoreComponentI

getName

public NamingI getName()
Returns the name object for the component.
Specified by:
getName in interface CoreComponentI

setName

public void setName(NamingI _name)
Sets the name object for the component.
Specified by:
setName in interface CoreComponentI

getParent

public CoreComponentI getParent()
Description copied from interface: CoreComponentI
Returns the parent for the component.
Specified by:
getParent in interface CoreComponentI

setParent

public void setParent(CoreComponentI _parent)
Description copied from interface: CoreComponentI
Sets the parent object for the component. Permits upward traversal of document trees.
Specified by:
setParent in interface CoreComponentI

setContent

public void setContent(java.lang.String _content)
Description copied from interface: CoreComponentI
Sets the content for this component as a string.
Specified by:
setContent in interface CoreComponentI

setContent

public void setContent(ComponentListI _content)
Description copied from interface: CoreComponentI
Sets the content for this component as a list of nodes.
Specified by:
setContent in interface CoreComponentI

addContent

public void addContent(CoreComponentI newComponent)
Description copied from interface: CoreComponentI
Adds content to this component.
Specified by:
addContent in interface CoreComponentI

clearContent

public void clearContent()
Description copied from interface: CoreComponentI
Clears the content for this component.
Specified by:
clearContent in interface CoreComponentI

getTextContent

public java.lang.String getTextContent()
Description copied from interface: CoreComponentI
Returns the content for this component as a string.
Specified by:
getTextContent in interface CoreComponentI

getContent

public ComponentListI getContent()
Description copied from interface: CoreComponentI
Returns the content for this component as a list of nodes.
Specified by:
getContent in interface CoreComponentI

addUnorderedContent

public void addUnorderedContent(CoreComponentI newComponent)
Description copied from interface: CoreComponentI
Adds an unordered component (usually an attribute) to a component.
Specified by:
addUnorderedContent in interface CoreComponentI

clearUnorderedContent

public void clearUnorderedContent()
Description copied from interface: CoreComponentI
Clears the unordered content (usually attributes) for this component.
Specified by:
clearUnorderedContent in interface CoreComponentI

getUnorderedContent

public ComponentSetI getUnorderedContent()
Description copied from interface: CoreComponentI
Returns the unordered content for this component.
Specified by:
getUnorderedContent in interface CoreComponentI

setUnorderedContent

public void setUnorderedContent(ComponentSetI newContent)
Description copied from interface: CoreComponentI
Sets the unordered content for this component.
Specified by:
setUnorderedContent in interface CoreComponentI

clearName

public void clearName()
Description copied from interface: CoreComponentI
Clears the name and namespace information for this component.
Specified by:
clearName in interface CoreComponentI

clearAll

public void clearAll()
Description copied from interface: CoreComponentI
Clears the name, namespace information, and content for this component.
Specified by:
clearAll in interface CoreComponentI

print

public void print()
Description copied from interface: CoreComponentI
Prints a representation of the component to STDOUT
Specified by:
print in interface CoreComponentI

toString

public abstract java.lang.String toString()
Description copied from interface: CoreComponentI
Returns a representation of the component as a String. Note: toString() is really only guaranteed effective for debugging, because namespaces may require the additional intelligence of a visitor class.
Specified by:
toString in interface CoreComponentI
Overrides:
toString in class java.lang.Object

setIsComplete

public void setIsComplete(boolean _complete)
Description copied from interface: CoreComponentI
Sets whether this object is complete (i.e., an element has ended).
Specified by:
setIsComplete in interface CoreComponentI

getIsComplete

public boolean getIsComplete()
Description copied from interface: CoreComponentI
Returns whether this object is complete (i.e., an element has ended).
Specified by:
getIsComplete in interface CoreComponentI

getBasicType

public abstract int getBasicType()
CoreComponent has no basic type - subclasses MUST provide one.
Specified by:
getBasicType in interface CoreComponentI

listen

public boolean listen(CoreComponentI component)
               throws MOEException
Description copied from interface: CoreComponentI
Accepts new events. Returns false until one of those events signals the completion of the current listener. The listen() method is designed for 'conventional' XML use. Attributes will be treated as unordered content, while everything else will be treated as ordered content. If you need to break those expectations, you'll need to use setContent() or setUnorderedContent() directly.
Specified by:
listen in interface CoreComponentI

clone

public java.lang.Object clone()
Non-clone implementation needs replacement. Will be made abstract when subclasses have implementation.
Specified by:
clone in interface CoreComponentI
Overrides:
clone in class java.lang.Object

annotate

public void annotate(java.lang.Object annotationType,
                     java.lang.Object annotation)
Description copied from interface: AnnotableI
The annotate() method allows developers to add different kinds of annotation information to components.
Specified by:
annotate in interface AnnotableI

addAll

public void addAll(java.util.Map otherAnnotations)
Specified by:
addAll in interface AnnotableI

getAnnotations

public java.lang.Object getAnnotations(java.lang.Object ofAnnotationType)
Description copied from interface: AnnotableI
This method allows developers to retrieve annotations of one particular type.
Specified by:
getAnnotations in interface AnnotableI

getAllAnnotations

public java.util.Map getAllAnnotations()
Description copied from interface: AnnotableI
This method allows developers to retrieve all annotations at once.
Specified by:
getAllAnnotations in interface AnnotableI

hasAnnotationOfType

public boolean hasAnnotationOfType(java.lang.Object ofAnnotationType)
Description copied from interface: AnnotableI
Indicates whether there are any annotations of the given type.
Specified by:
hasAnnotationOfType in interface AnnotableI

hasAnnotation

public boolean hasAnnotation(java.lang.Object annotation)
Description copied from interface: AnnotableI
Indicates whether the provided object is stored as an annotation (of any type)
Specified by:
hasAnnotation in interface AnnotableI

hasAnnotations

public boolean hasAnnotations()
Specified by:
hasAnnotations in interface AnnotableI

getTypes

public java.util.Set getTypes()
Description copied from interface: AnnotableI
Returns a Set containing the types of all annotations stored in this object
Specified by:
getTypes in interface AnnotableI

removeAnnotation

public void removeAnnotation(java.lang.Object ofAnnotationType)
Description copied from interface: AnnotableI
This method allows developers to remove a single annotation.
Specified by:
removeAnnotation in interface AnnotableI

removeAllAnnotations

public void removeAllAnnotations()
Description copied from interface: AnnotableI
This method allows developers to remove all annotations at once.
Specified by:
removeAllAnnotations in interface AnnotableI

add

protected CoreComponentI add(CoreComponentI component,
                             CoreComponentI context)
                      throws MOEException

textComponent

protected CoreComponentI textComponent()