Class DocumentFactoryImpl
java.lang.Object
org.episteme.natural.chemistry.loaders.cml.cmlimpl.DocumentFactoryImpl
- All Implemented Interfaces:
CMLDocumentFactory
manufactures CMLDocuments
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new DocumentFactoryImpl object with default documentClassName -
Method Summary
Modifier and TypeMethodDescriptionCreates a CMLDocument instance using the current documentClassName.createDocument(String documentClassName) Creates a CMLDocument instance using the specified class name.static AbstractCMLDocumentCreates a new CMLDocument this creates Documents of the subclassed documentClassName NOTE: The default class will create Elements of type CMLBaseImpl, subclassed to fit the schema.static CMLDocumentFactoryCreates a new DocumentFactory this creates Documents and elements of the abstract documentClassName NOTE: The default class will create Elements of type PMRElement, not subclassed to fit the schema.static CMLDocumentFactoryCreates a new DocumentFactory this creates Documents of the subclassed documentClassName NOTE: The default class will create Elements of type CMLBaseImpl, subclassed to fit the schema.static CMLDocumentFactorynewInstance(String documentClassName) Creates a new DocumentFactory for the specified document class.parseSAX(InputSource is) Parses an XML document via SAX (whitespace is ignored).parseSAX(InputSource is, boolean debug) Parses an XML document via SAX with optional debugging (whitespace is ignored).parseSAX(InputSource is, AbstractCMLDocument doc) Parses an XML document via SAX into an existing DOM (whitespace is ignored).parseSAX(InputSource is, AbstractCMLDocument doc, boolean debug) Description of the Method whitespace is ignoredparseString(String xmlString) Convenience method to parse an XML string into a CMLDocument.voidsetDocumentClassName(String documentClassName) set the document class name
-
Field Details
-
ABSTRACT_CMLDOCUMENT
The fully qualified class name for the abstract CML document implementation.- See Also:
-
DEFAULT_CMLDOCUMENT
The fully qualified class name for the default CML document implementation.- See Also:
-
documentClassName
The class name used to instantiate new CML documents.
-
-
Constructor Details
-
DocumentFactoryImpl
protected DocumentFactoryImpl()Creates a new DocumentFactoryImpl object with default documentClassName
-
-
Method Details
-
setDocumentClassName
set the document class name- Specified by:
setDocumentClassNamein interfaceCMLDocumentFactory- Parameters:
documentClassName- the classname with which to create new Documents
-
createDocument
Creates a CMLDocument instance using the current documentClassName.- Specified by:
createDocumentin interfaceCMLDocumentFactory- Returns:
- the newly created CML document
-
createDocument
Creates a CMLDocument instance using the specified class name.- Parameters:
documentClassName- the class name of the document to create- Returns:
- the newly created CML document, or null if creation failed
-
newAbstractInstance
Creates a new DocumentFactory this creates Documents and elements of the abstract documentClassName NOTE: The default class will create Elements of type PMRElement, not subclassed to fit the schema. For that use newInstance(String documentClassName);- Returns:
- the CMLDocumentFactory
-
newInstance
Creates a new DocumentFactory this creates Documents of the subclassed documentClassName NOTE: The default class will create Elements of type CMLBaseImpl, subclassed to fit the schema. If elements of type PMRElementImpl are required use newAbstractInstance();- Returns:
- the CMLDocumentFactory
-
createNewDocument
Creates a new CMLDocument this creates Documents of the subclassed documentClassName NOTE: The default class will create Elements of type CMLBaseImpl, subclassed to fit the schema. If elements of type PMRElementImpl are required use newAbstractInstance();- Returns:
- the CMLDocumentFactory
-
newInstance
Creates a new DocumentFactory for the specified document class.- Parameters:
documentClassName- the class name for the factory's documents- Returns:
- the new document factory instance
-
parseString
Convenience method to parse an XML string into a CMLDocument.- Specified by:
parseStringin interfaceCMLDocumentFactory- Parameters:
xmlString- the well-formed XML string to parse- Returns:
- the resulting CML document
- Throws:
CMLException- if parsing fails or result is invalid
-
parseSAX
Parses an XML document via SAX (whitespace is ignored).- Specified by:
parseSAXin interfaceCMLDocumentFactory- Parameters:
is- the input source- Returns:
- the parsed CML document
- Throws:
CMLException- if a parsing error occurrsIOException- if an I/O error occurs
-
parseSAX
Parses an XML document via SAX into an existing DOM (whitespace is ignored).- Specified by:
parseSAXin interfaceCMLDocumentFactory- Parameters:
is- the input sourcedoc- the target document for the parsed elements- Returns:
- the root element of the parsed content
- Throws:
CMLException- if a parsing error occurrsIOException- if an I/O error occurs
-
parseSAX
Parses an XML document via SAX with optional debugging (whitespace is ignored).- Specified by:
parseSAXin interfaceCMLDocumentFactory- Parameters:
is- the input sourcedebug- true to enable debug output- Returns:
- the parsed CML document
- Throws:
CMLException- if a parsing error occurrsIOException- if an I/O error occurs
-
parseSAX
public Element parseSAX(InputSource is, AbstractCMLDocument doc, boolean debug) throws CMLException, IOException Description of the Method whitespace is ignored- Specified by:
parseSAXin interfaceCMLDocumentFactory- Parameters:
is- inputdoc- document to which element will belongdebug- if true, debug- Returns:
- the new root element
- Throws:
IOExceptionCMLException
-