com.simonstl.moe
Class Namespace

java.lang.Object
  |
  +--com.simonstl.moe.CoreComponent
        |
        +--com.simonstl.moe.explicit.Attribute
              |
              +--com.simonstl.moe.Namespace
All Implemented Interfaces:
AnnotableI, java.lang.Cloneable, CoreComponentI, NamingI
Direct Known Subclasses:
EndNamespace

public class Namespace
extends Attribute

The Namespace class provides a foundation for MOE objects to store namespaces.

There are some real complications in dealing with namespaces in an event context, made only more difficult by the potential creation of partial trees. The SAX event startPrefixMapping() takes place before the startElement() call, and similarly endPrefixMapping() is reported after endElement().

SAX also provides options for reporting/not reporting the attributes which define namespaces. In MOE, when events are assembled, the namespaces will be associated with the elements containing the definitions.

I've defined the Namespace class to be something of a broken attribute, much like Namespace declarations in XML 1.0. The prefix of the attribute is fixed to xmlns, the localName defines the prefix defined by the namespace. The toString() method handles the xmlns/xmlns:prefix issues.

The namespace URI is stored as textual content, just as with attributes. This potentially supports some rather perverse things like the use of general entities in the attribute values used to define namespaces.

nsURI is fixed to http://www.w3.org/TR/REC-xml-names/.

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

Version:
0.01 25 August 2001
Author:
Simon St.Laurent

Field Summary
protected  boolean current
          current indicates that a namespace needs to be declared in the current context.
protected  int level
          level is used by NamespaceContext to determine where in a tree a given namespace applies.
protected  NamespaceName name
          Override regular name object with NamespaceName.
 
Fields inherited from class com.simonstl.moe.CoreComponent
annotations, complete, componentType, content, context, parent, unorderedContent
 
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
Namespace()
           
 
Method Summary
 java.lang.Object clone()
          Non-clone implementation needs replacement.
 int getBasicType()
          Namespace has the basic type NAMESPACE_DECL.
 boolean getCurrent()
          getCurrent()is used by the Element object to figure out if a namespace needs to be declared here.
 int getLevel()
          getLevel()is used by the NamespaceContext object to figure out which declarations appeared where.
 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.
 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.
 boolean listen(CoreComponentI component)
          For now, the namespace class doesn't listen.
static void main(java.lang.String[] args)
          Need to update - currently elements only
 void setCurrent(boolean _current)
          setLevel()is used by the NamespaceContext object to establish which declarations appeared in the current element.
 void setLevel(int _level)
          setLevel()is used by the NamespaceContext object to establish which declarations appeared where.
 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 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.
 java.lang.String toString()
          Returns a representation of the component as a String.
 java.lang.String toString(ComponentSetI namespaceContext)
          Returns a representation of the component as a String.
 
Methods inherited from class com.simonstl.moe.CoreComponent
add, addAll, addContent, addUnorderedContent, annotate, clearAll, clearContent, clearName, clearUnorderedContent, getAllAnnotations, getAnnotations, getContent, getIsComplete, getParent, getTextContent, getTypes, getUnorderedContent, hasAnnotation, hasAnnotationOfType, hasAnnotations, hashCode, print, removeAllAnnotations, removeAnnotation, setContent, setContent, setIsComplete, setParent, setUnorderedContent, textComponent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

level

protected int level
level is used by NamespaceContext to determine where in a tree a given namespace applies.

current

protected boolean current
current indicates that a namespace needs to be declared in the current context. If events came through a SAX filter stripping xmlns attributes, this is useful.

name

protected NamespaceName name
Override regular name object with NamespaceName.
Constructor Detail

Namespace

public Namespace()
Method Detail

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.
Overrides:
setNsURI in class CoreComponent

getNsURI

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

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.
Overrides:
setLocalName in class CoreComponent

getLocalName

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

setPrefix

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

getPrefix

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

getQName

public java.lang.String getQName()
Returns the Qualified Name (QName) for the component.
Overrides:
getQName in class CoreComponent

setQName

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

getName

public NamingI getName()
Returns the name object for the component.
Overrides:
getName in class CoreComponent

setName

public void setName(NamingI _name)
Sets the name object for the component.
Overrides:
setName in class CoreComponent

toString

public 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.
Overrides:
toString in class Attribute

toString

public java.lang.String toString(ComponentSetI namespaceContext)
Description copied from interface: CoreComponentI
Returns a representation of the component as a String. Given a namespaceContext, this may be more effective than the regular toString().
Overrides:
toString in class Attribute

clone

public java.lang.Object clone()
Description copied from class: CoreComponent
Non-clone implementation needs replacement. Will be made abstract when subclasses have implementation.
Overrides:
clone in class Attribute

getBasicType

public int getBasicType()
Namespace has the basic type NAMESPACE_DECL.
Overrides:
getBasicType in class Attribute

listen

public boolean listen(CoreComponentI component)
For now, the namespace class doesn't listen. This may be modified to support more attribute-like functionality, but the issue of using general entities in namespaces gets complex rapidly.
Overrides:
listen in class Attribute

getLevel

public int getLevel()
getLevel()is used by the NamespaceContext object to figure out which declarations appeared where.

setLevel

public void setLevel(int _level)
setLevel()is used by the NamespaceContext object to establish which declarations appeared where.

getCurrent

public boolean getCurrent()
getCurrent()is used by the Element object to figure out if a namespace needs to be declared here.

setCurrent

public void setCurrent(boolean _current)
setLevel()is used by the NamespaceContext object to establish which declarations appeared in the current element.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Description copied from class: Attribute
Need to update - currently elements only