com.simonstl.moe.factory
Class ComponentFactory

java.lang.Object
  |
  +--com.simonstl.moe.factory.ComponentFactory

public class ComponentFactory
extends java.lang.Object

The ComponentFactory class provides a relatively simple mechanism for creating new MOE components. I've kept the constructors on the components deliberately minimal, preferring to use factory classes to create particular objects

The ComponentFactory class uses System properties to define which classes map to which kinds of components. More sophisticated classes (which I haven't written) could permit, for example, the mapping of particular MOE objects to classes based on things like the namespace URI and/or local name.

This class uses class information from the system properties:

com.simonstl.moe.factory.element
com.simonstl.moe.factory.endElement
com.simonstl.moe.factory.attribute
com.simonstl.moe.factory.endAttribute
com.simonstl.moe.factory.characters
com.simonstl.moe.factory.cdataSect
com.simonstl.moe.factory.endCdataSect
com.simonstl.moe.factory.procInst
com.simonstl.moe.factory.endProcInst
com.simonstl.moe.factory.comment
com.simonstl.moe.factory.endComment
com.simonstl.moe.factory.namespace
com.simonstl.moe.factory.endNamespace
com.simonstl.moe.factory.whitespace

If these properties are empty, they default to the classes in the com.simonstl.moe package.

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

Field Summary
protected static java.lang.String attributeClass
           
protected static java.lang.String cdataSectClass
           
protected static java.lang.String charactersClass
           
protected static java.lang.String commentClass
           
protected static java.lang.String elementClass
           
protected static java.lang.String endAttributeClass
           
protected static java.lang.String endCdataSectClass
           
protected static java.lang.String endCommentClass
           
protected static java.lang.String endElementClass
           
protected static java.lang.String endNamespaceClass
           
protected static java.lang.String endProcInstClass
           
protected static java.lang.String namespaceClass
           
protected static java.lang.String procInstClass
           
protected static java.lang.String whitespaceClass
           
 
Constructor Summary
ComponentFactory()
           
 
Method Summary
static CoreComponentI attribute(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix)
          Creates an empty attribute with a namespace URI, local name, and prefix.
static CoreComponentI attribute(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, java.lang.String _text)
          Creates an attribute with a namespace URI, local name, prefix, and a text node.
static CoreComponentI attribute(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, java.lang.String _text, boolean _complete)
          Creates an attribute with a namespace URI, local name, prefix, and a text node, and allows the caller to specify whether or not the element is complete.
static java.lang.String[] breakQName(java.lang.String QName)
          Divides a QName into two pieces.
static CoreComponentI cdataSect()
          Creates an empty and incomplete CDATA section with no textual content.
static CoreComponentI cdataSect(java.lang.String _text)
          Creates a complete CDATA section with textual content.
static CoreComponentI cdataSect(java.lang.String _text, boolean _complete)
          Creates a CDATA section with textual content, allowing the code to specify whether or not it is complete.
static CoreComponentI characters(java.lang.String _text)
          Creates a text node with textual content.
static CoreComponentI comment(java.lang.String _text)
          Creates a complete Comment with textual content.
static CoreComponentI comment(java.lang.String _text, boolean _complete)
          Creates a comment with textual content, allowing the code to specify whether or not it is complete.
protected static CoreComponentI createComponent(java.lang.String className)
           
static CoreComponentI element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix)
          Creates an empty element with a namespace URI, local name, and prefix.
static CoreComponentI element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, java.lang.String _text)
          Creates a complete element with a namespace URI, local name, prefix, and a text node.
static CoreComponentI element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, java.lang.String _text, boolean _complete)
          Creates an element with a namespace URI, local name, prefix, and a text node, and allows the caller to specify whether or not the element is complete.
static CoreComponentI endAttribute(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix)
          Creates an empty attribute with a namespace URI, local name, and prefix.
static CoreComponentI endCdataSect()
          Creates an end to a CDATA section.
static CoreComponentI endComment()
           
static CoreComponentI endElement(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix)
          Creates an end element with a namespace URI, local name, and prefix.
static CoreComponentI endNamespace(java.lang.String _nsURI, java.lang.String _prefix)
          Creates an end to a namespace.
static CoreComponentI endProcInst()
           
static void main(java.lang.String[] args)
           
static CoreComponentI namespace(java.lang.String _nsURI)
          Creates a default.
static CoreComponentI namespace(java.lang.String _nsURI, java.lang.String _prefix)
          Creates a namespace.
static CoreComponentI procInst(java.lang.String _target, java.lang.String _text)
          Creates a complete Processing Instruction with target and textual content.
 CoreComponentI procInst(java.lang.String _target, java.lang.String _text, boolean _complete)
          Creates a Processing Instruction with target and textual content, allowing the code to specify whether or not it is complete.
static CoreComponentI whitespace(java.lang.String _text)
          Creates a whitespace node with content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elementClass

protected static java.lang.String elementClass

endElementClass

protected static java.lang.String endElementClass

attributeClass

protected static java.lang.String attributeClass

endAttributeClass

protected static java.lang.String endAttributeClass

charactersClass

protected static java.lang.String charactersClass

cdataSectClass

protected static java.lang.String cdataSectClass

endCdataSectClass

protected static java.lang.String endCdataSectClass

procInstClass

protected static java.lang.String procInstClass

endProcInstClass

protected static java.lang.String endProcInstClass

commentClass

protected static java.lang.String commentClass

endCommentClass

protected static java.lang.String endCommentClass

namespaceClass

protected static java.lang.String namespaceClass

endNamespaceClass

protected static java.lang.String endNamespaceClass

whitespaceClass

protected static java.lang.String whitespaceClass
Constructor Detail

ComponentFactory

public ComponentFactory()
Method Detail

breakQName

public static java.lang.String[] breakQName(java.lang.String QName)
Divides a QName into two pieces.

element

public static CoreComponentI element(java.lang.String _nsURI,
                                     java.lang.String _localName,
                                     java.lang.String _prefix)
                              throws MOEException
Creates an empty element with a namespace URI, local name, and prefix.

element

public static CoreComponentI element(java.lang.String _nsURI,
                                     java.lang.String _localName,
                                     java.lang.String _prefix,
                                     java.lang.String _text)
                              throws MOEException
Creates a complete element with a namespace URI, local name, prefix, and a text node.

element

public static CoreComponentI element(java.lang.String _nsURI,
                                     java.lang.String _localName,
                                     java.lang.String _prefix,
                                     java.lang.String _text,
                                     boolean _complete)
                              throws MOEException
Creates an element with a namespace URI, local name, prefix, and a text node, and allows the caller to specify whether or not the element is complete.

attribute

public static CoreComponentI attribute(java.lang.String _nsURI,
                                       java.lang.String _localName,
                                       java.lang.String _prefix)
                                throws MOEException
Creates an empty attribute with a namespace URI, local name, and prefix.

attribute

public static CoreComponentI attribute(java.lang.String _nsURI,
                                       java.lang.String _localName,
                                       java.lang.String _prefix,
                                       java.lang.String _text)
                                throws MOEException
Creates an attribute with a namespace URI, local name, prefix, and a text node.

attribute

public static CoreComponentI attribute(java.lang.String _nsURI,
                                       java.lang.String _localName,
                                       java.lang.String _prefix,
                                       java.lang.String _text,
                                       boolean _complete)
                                throws MOEException
Creates an attribute with a namespace URI, local name, prefix, and a text node, and allows the caller to specify whether or not the element is complete.

characters

public static CoreComponentI characters(java.lang.String _text)
                                 throws MOEException
Creates a text node with textual content.

procInst

public static CoreComponentI procInst(java.lang.String _target,
                                      java.lang.String _text)
                               throws MOEException
Creates a complete Processing Instruction with target and textual content.

procInst

public CoreComponentI procInst(java.lang.String _target,
                               java.lang.String _text,
                               boolean _complete)
                        throws MOEException
Creates a Processing Instruction with target and textual content, allowing the code to specify whether or not it is complete.

comment

public static CoreComponentI comment(java.lang.String _text)
                              throws MOEException
Creates a complete Comment with textual content.

comment

public static CoreComponentI comment(java.lang.String _text,
                                     boolean _complete)
                              throws MOEException
Creates a comment with textual content, allowing the code to specify whether or not it is complete.

cdataSect

public static CoreComponentI cdataSect()
                                throws MOEException
Creates an empty and incomplete CDATA section with no textual content.

cdataSect

public static CoreComponentI cdataSect(java.lang.String _text)
                                throws MOEException
Creates a complete CDATA section with textual content.

cdataSect

public static CoreComponentI cdataSect(java.lang.String _text,
                                       boolean _complete)
                                throws MOEException
Creates a CDATA section with textual content, allowing the code to specify whether or not it is complete.

whitespace

public static CoreComponentI whitespace(java.lang.String _text)
                                 throws MOEException
Creates a whitespace node with content.

namespace

public static CoreComponentI namespace(java.lang.String _nsURI,
                                       java.lang.String _prefix)
                                throws MOEException
Creates a namespace.

namespace

public static CoreComponentI namespace(java.lang.String _nsURI)
                                throws MOEException
Creates a default.

endElement

public static CoreComponentI endElement(java.lang.String _nsURI,
                                        java.lang.String _localName,
                                        java.lang.String _prefix)
                                 throws MOEException
Creates an end element with a namespace URI, local name, and prefix.

endAttribute

public static CoreComponentI endAttribute(java.lang.String _nsURI,
                                          java.lang.String _localName,
                                          java.lang.String _prefix)
                                   throws MOEException
Creates an empty attribute with a namespace URI, local name, and prefix.

endNamespace

public static CoreComponentI endNamespace(java.lang.String _nsURI,
                                          java.lang.String _prefix)
                                   throws MOEException
Creates an end to a namespace.

endCdataSect

public static CoreComponentI endCdataSect()
                                   throws MOEException
Creates an end to a CDATA section.

endProcInst

public static CoreComponentI endProcInst()
                                  throws MOEException

endComment

public static CoreComponentI endComment()
                                 throws MOEException

createComponent

protected static CoreComponentI createComponent(java.lang.String className)
                                         throws MOEException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception