com.simonstl.fragment
Class DocComponent

java.lang.Object
  |
  +--com.simonstl.fragment.DocComponent
Direct Known Subclasses:
Attribute, Characters, Element, Skip

public abstract class DocComponent
extends java.lang.Object

The DocComponent abstract class stores information about XML document components in a way which makes it easy use them in a streaming SAX environment.

Version 0.05 adds a matchComponent() method taking a DocComponent as an argument.

Version 0.04 removes the isAttribute property and getIsAttribute() method.

Version 0.03 adds the cleanDuplicate() method.

Version 0.02 adds the boolean isAttribute and the getIsAttribute() method.

version 0.01 is the initial release, based on version 0.05 of the Element class.

Version:
0.05 13 July 2001
Author:
Simon St.Laurent

Field Summary
protected  java.lang.String after
           
protected  java.lang.String before
           
protected  java.lang.String content
           
protected  java.lang.String localName
           
protected  java.lang.String nsURI
           
protected  Element parentElement
           
protected  java.lang.String prefix
           
protected  java.lang.String type
           
 
Constructor Summary
DocComponent()
           
 
Method Summary
 void addContent(DocComponent newComponent)
          Sets the content for this component.
abstract  DocComponent cleanDuplicate()
          Returns a clean copy of the component and its contents.
 void clearContent()
          Clears the content for this component.
abstract  void eventComponent(FragmentFilter handler)
          Describes the content for this component as a series of SAX events.
 java.lang.String getAfter()
          Returns a string of content which may appear after the component
 java.lang.String getBefore()
          Returns a string of content which may appear before the component
 java.lang.String getContent()
          Returns the content for this component.
abstract  java.lang.String getKey()
          Returns a key which can be used as a unique identifier for this component.
 java.lang.String getLocalName()
          Returns the local name for the component
 java.lang.String getNsURI()
          Returns the URI reference value for the namespace.
 Element getParentElement()
          Gets the parent element for this component (unused).
 java.lang.String getPrefix()
          Returns the prefix used to represent the namespace URI reference for this component.
 java.lang.String getType()
          Sets the type for this component.
 boolean matchAll(DocComponent component)
          Matches everything
 boolean matchComponent(DocComponent component, int matchType)
          Takes a component and returns true or false to indicate whether or not it matches 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.
 boolean matchElement(DocComponent component)
          Matches only element rules.
 boolean matchSingleton(DocComponent component)
          Matches only element and attribute rules, ignoring child elements or attributes
abstract  void print()
          Prints a representation of the component to STDOUT
 void processComponentContent(FragmentRules rules)
          Supports processing of content, if any.
 void setAfter(java.lang.String newAfter)
          Sets a string of content which may appear after the component
 void setBefore(java.lang.String newBefore)
          Sets a string of content which may appear before the component
 void setContent(java.lang.String newContent)
          Sets the content for this component.
 void setLocalName(java.lang.String newLocalName)
          Accepts a string which will serve as the local name for this component.
 void setNsURI(java.lang.String newNsURI)
          Accepts a URI reference value which is used as the namespace for the component.
 void setParentElement(Element _parentElement)
          Sets the parent element for this component (unused).
 void setPrefix(java.lang.String newPrefix)
          Accepts a string which serves as the prefix for this component.
 void setType(java.lang.String _type)
          Gets the type for this component.
abstract  java.lang.String toString()
          Returns a representation of the component as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nsURI

protected java.lang.String nsURI

localName

protected java.lang.String localName

prefix

protected java.lang.String prefix

content

protected java.lang.String content

before

protected java.lang.String before

after

protected java.lang.String after

type

protected java.lang.String type

parentElement

protected Element parentElement
Constructor Detail

DocComponent

public DocComponent()
Method Detail

matchComponent

public 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.

matchComponent

public boolean matchComponent(DocComponent component,
                              int matchType)
Takes a component and returns true or false to indicate whether or not it matches this component.

matchElement

public boolean matchElement(DocComponent component)
Matches only element rules.

matchSingleton

public boolean matchSingleton(DocComponent component)
Matches only element and attribute rules, ignoring child elements or attributes

matchAll

public boolean matchAll(DocComponent component)
Matches everything

getKey

public abstract java.lang.String getKey()
Returns a key which can be used as a unique identifier for this component.

setNsURI

public void setNsURI(java.lang.String newNsURI)
Accepts a URI reference value which is used as the namespace for the component.

getNsURI

public java.lang.String getNsURI()
Returns the URI reference value for the namespace.

setLocalName

public void setLocalName(java.lang.String newLocalName)
Accepts a string which will serve as the local name for this component.

getLocalName

public java.lang.String getLocalName()
Returns the local name for the component

setPrefix

public void setPrefix(java.lang.String newPrefix)
Accepts a string which serves as the prefix for this component.

getPrefix

public java.lang.String getPrefix()
Returns the prefix used to represent the namespace URI reference for this component.

setContent

public void setContent(java.lang.String newContent)
Sets the content for this component.

addContent

public void addContent(DocComponent newComponent)
Sets the content for this component.

clearContent

public void clearContent()
Clears the content for this component.

getContent

public java.lang.String getContent()
Returns the content for this component.

setBefore

public void setBefore(java.lang.String newBefore)
Sets a string of content which may appear before the component

getBefore

public java.lang.String getBefore()
Returns a string of content which may appear before the component

setAfter

public void setAfter(java.lang.String newAfter)
Sets a string of content which may appear after the component

getAfter

public java.lang.String getAfter()
Returns a string of content which may appear after the component

getType

public java.lang.String getType()
Sets the type for this component. CDATA is typical for attributes, but may be used for others.

setType

public void setType(java.lang.String _type)
Gets the type for this component. CDATA is typical for attributes, but may be used for others.

eventComponent

public abstract void eventComponent(FragmentFilter handler)
                             throws org.xml.sax.SAXException
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.

print

public abstract void print()
Prints a representation of the component to STDOUT

toString

public abstract java.lang.String toString()
Returns a representation of the component as a String.
Overrides:
toString in class java.lang.Object

processComponentContent

public void processComponentContent(FragmentRules rules)
Supports processing of content, if any. By default, does nothing. (Element overrides, Attribute will.)

setParentElement

public void setParentElement(Element _parentElement)
Sets the parent element for this component (unused).

getParentElement

public Element getParentElement()
Gets the parent element for this component (unused).

cleanDuplicate

public abstract DocComponent cleanDuplicate()
Returns a clean copy of the component and its contents.