com.simonstl.fragment
Class Element

java.lang.Object
  |
  +--com.simonstl.fragment.DocComponent
        |
        +--com.simonstl.fragment.Element
All Implemented Interfaces:
java.lang.Cloneable

public class Element
extends DocComponent

The Element class stores information about elements (and perhaps someday attributes) in a format that supports namespaces, allows the preservation of prefix information, and supports matching on namespace URIs and localNames.

I may eventually add support for attributes, and also for wildcard matching on nsURI and/or localName.

Version 0.06 extends DocComponent rather than trying to handle all cases itself.

Version 0.05 adds support for beforeInside and afterInside attributes, allowing rules to add content inside of the element they create.

Version 0.04 changed support for skipping, allowing for the chars element to operate when character output is desired. It also now calls the startChars() and endChars() methods of FragmentFilter to give these characters their own place in the stack. Finally, it now supports before and after content.

Version 0.03 added properties for content and attributes. It also added the eventElement() method, which allows Element objects to write out their own SAX events. This should make it easier to manage configuration in the future.

version 0.02 added the getKey() method, so that Elements could define their own keys. This should permit future versions to support more complex matching than just nsURI>localName. (Making that work will involve revisions to matchElement (String match) as well.)

Version:
0.06 1 July 2001
Author:
Simon St.Laurent

Fields inherited from class com.simonstl.fragment.DocComponent
after, before, content, localName, nsURI, prefix
 
Constructor Summary
Element(Element oldElement)
           
Element(java.lang.String newNsURI, java.lang.String newLocalName)
           
Element(java.lang.String newNsURI, java.lang.String newLocalName, java.lang.String newPrefix)
           
Element(java.lang.String newNsURI, java.lang.String newLocalName, java.lang.String newPrefix, java.lang.String newContent)
           
 
Method Summary
 void eventComponent(FragmentFilter handler)
          Describes the content for this component as a series of SAX events.
 java.lang.String getAfterInside()
           
 org.xml.sax.helpers.AttributesImpl getAtts()
           
 java.lang.String getBeforeInside()
           
 java.lang.String getKey()
          Returns a key which can be used as a unique identifier for this component.
 boolean matchComponent(java.lang.String match)
          Takes a string representing a component description and returns true or false to indicate whether or not it matches this component.
 void print()
          Prints a representation of the component to STDOUT
 void setAfterInside(java.lang.String newAfterInside)
           
 void setAtts(org.xml.sax.helpers.AttributesImpl newAtts)
           
 void setBeforeInside(java.lang.String newBeforeInside)
           
 java.lang.String toString()
          Returns a representation of the component as a String.
 
Methods inherited from class com.simonstl.fragment.DocComponent
clone, getAfter, getBefore, getContent, getLocalName, getNsURI, getPrefix, setAfter, setBefore, setContent, setLocalName, setNsURI, setPrefix
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(java.lang.String newNsURI,
               java.lang.String newLocalName)

Element

public Element(java.lang.String newNsURI,
               java.lang.String newLocalName,
               java.lang.String newPrefix)

Element

public Element(java.lang.String newNsURI,
               java.lang.String newLocalName,
               java.lang.String newPrefix,
               java.lang.String newContent)

Element

public Element(Element oldElement)
Method Detail

matchComponent

public boolean matchComponent(java.lang.String match)
Description copied from class: DocComponent
Takes a string representing a component description and returns true or false to indicate whether or not it matches this component.
Overrides:
matchComponent in class DocComponent

getKey

public java.lang.String getKey()
Description copied from class: DocComponent
Returns a key which can be used as a unique identifier for this component.
Overrides:
getKey in class DocComponent

setAtts

public void setAtts(org.xml.sax.helpers.AttributesImpl newAtts)

getAtts

public org.xml.sax.helpers.AttributesImpl getAtts()

setBeforeInside

public void setBeforeInside(java.lang.String newBeforeInside)

getBeforeInside

public java.lang.String getBeforeInside()

setAfterInside

public void setAfterInside(java.lang.String newAfterInside)

getAfterInside

public java.lang.String getAfterInside()

eventComponent

public void eventComponent(FragmentFilter handler)
                    throws org.xml.sax.SAXException
Description copied from class: DocComponent
Describes the content for this component as a series of SAX events. Note that FragmentFilter supports some events (startChars and endChars) which are extensions to the existing SAX models and which serve to keep the stacks under control.
Overrides:
eventComponent in class DocComponent

print

public void print()
Description copied from class: DocComponent
Prints a representation of the component to STDOUT
Overrides:
print in class DocComponent

toString

public java.lang.String toString()
Description copied from class: DocComponent
Returns a representation of the component as a String.
Overrides:
toString in class DocComponent