Class CMLBaseImpl
java.lang.Object
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRNodeImpl
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRElementImpl
org.episteme.natural.chemistry.loaders.cml.cmlimpl.CMLBaseImpl
- All Implemented Interfaces:
AbstractBase, CMLNode, Element, Node
The base class for all elementObjects mentioned in the Schema
Any CML element may have attributes:titleiddictRefconvention
and convenience get/set methods are provided for allAn element (FOO) subclassed from a AbstractBase may be constructed in the
following ways:FOO(). Creates a new empty element with null values of the
attributes. Required for newInstance(), but use carefully since
it has no tagName and no document associated with it.FOO(String tagName, CMLDocument document). Creates an empty
element with null attribute names.FOO(org.w3c.dom.Element element). Creates a subclassed Element with
the same attribute values as the input Element. Used when a DOM has
been created with non-CML-aware software. The routine
makeAndProcessSubclass(Element element) will replace the current Element
with the appropriate CML subclass.FOO(String title, String id, String dictRef, String convention).
Makes subclassed Element and sets attribute values.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected AbstractCMLDocumentprotected Stringprotected BaseToolprotected StringFields inherited from class PMRNodeImpl
childNodes, delegateNode, parentNode, pmrDocument, siblingNodesFields inherited from interface AbstractBase
CML1, CML2, CMLCDK, CONTENT_MODEL, CONVENTION, DICTREF, FLOAT_TYPE, ID, INTEGER_TYPE, NAMESPACE_URI, PACKAGE_NAME, REF, STRING_TYPE, TITLE, UNKNOWNFields inherited from interface Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
ConstructorsModifierConstructorDescriptioncreate a Node WITHOUT tagName OR document Use with careprotectedCMLBaseImpl(String tagName, AbstractCMLDocument document) used when creating new nodes in a DOMCMLBaseImpl(String tagName, Document document) -
Method Summary
Modifier and TypeMethodDescriptionvoidcontent modelvoidaddTextChild(String value) addStringContent to ElementappendChild(Element elem) traps the addition of an child to the element content By default this will be routed to addChild() and org.w3c.dom.Node.appendChild(), but other element-specific stuff can be interposed (within the Contvoidcharacters(SaxHandler saxHandler, String content) SAX2 parsing routine called from characters() callback NOT namespace awarestatic StringcreateToolClassName(AbstractBase abstractBase) constructs a class name for toolprotected voidoutput string if debug setdeepCopy()deep clones an element including subclassing.deepCopy(AbstractCMLDocument document) deep clones an element including subclassingvoiddeleteChild(Element elem) delete an element The element must have been previously created and present in the DOMvoidendElement(SaxHandler saxHandler) SAX2 parsing routine called from endElement() callback NOT namespace awareElement[]getChildList(String elementName) gets a (typed) list of child elements with a given namegetChildVector(String elementName) gets a Vector of all child elements with this nameget owner document as CMLDocument.gets text content from an element should only be used for text-only or mixed content.booleangetDebug()debug statusgetFirstChild(String elementName) gets the first Child of a given type (by elementName) This method will normally be used when there is a single child of this typegetOrCreateChild(String elemName) get a child of a given name If it doesn't exist, create and add itget or create tool.getTool()get tool.protected voidinit()static voidoutputChildren(Element elem, Writer w, String control) voidremoves whitespace nodes or throws any Exception for non-whitespace onesvoidsetArraySyntax(boolean syntax) set array syntaxvoidsetAttribute(String name, String value) set attribute. do not use. may be called by autogenerated code. reroutes calls to attribute "elementContent" to setTextChildvoidsetContentValue(String value) adds text content to an element should only be used for text-only or mixed content.voidsetDebug(boolean d) toggle debuggingvoidsetTextChild(String value) addStringContent to Elementvoidset toolvoidsetVersion(String v) set CML versionvoidstartElement(SaxHandler saxHandler, Attributes attributes) SAX2 parsing routine called from startElement() callback NOT namespace awarevoidupdate delegate attributes.voidupdate delegate content.voidupdate delegates. updates this delegates (content and attributes) then recurses through childrenvoidupdate DOM. updates this DOM (content and attributes) then recurses through childrenvoidupdate DOM attributes.voidupdate DOM content.voidwrite XML use current control (version and syntax)voidwrite XML (allows for syntactic variants)static voidMethods inherited from class PMRElementImpl
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNSMethods inherited from class PMRNodeImpl
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getDelegateNode, getDelegateParentNode, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, removeChild, replaceChild, setDelegateNode, setNodeValue, setOwnerDocument, setOwnerDocumentRecursively, setPrefix, setTextContent, setUserData, toString, wrapRecursivelyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbstractBase
getAttributeMethods inherited from interface Element
getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNSMethods inherited from interface Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Field Details
-
version
-
arraySyntax
protected boolean arraySyntax -
tool
-
debug
protected boolean debug -
tagName
-
ownerDocument
-
-
Constructor Details
-
CMLBaseImpl
public CMLBaseImpl()create a Node WITHOUT tagName OR document Use with care -
CMLBaseImpl
used when creating new nodes in a DOM -
CMLBaseImpl
-
-
Method Details
-
init
protected void init() -
getCMLDocument
Description copied from interface:AbstractBaseget owner document as CMLDocument.- Specified by:
getCMLDocumentin interfaceAbstractBase- Returns:
- the document
-
getClassTagName
-
addChild
content model adds a child to the element content. The elementName is checked for validity (but not its position in the list of children). It will always be added at the end. Therefore when building a DOM the author must ensure that all elements are added in correct order or must validate after addition. The count will be taken from the sum of the allowed children. Thus foo, bar, foo* will allow the addition of 1 bar and many foos.- Parameters:
elem- the element to add (identified by elementName not class)- Throws:
CMLException- element cannot be added (violates content model)
-
deleteChild
delete an element The element must have been previously created and present in the DOM- Parameters:
elem- element to be deleted.- Throws:
CMLException- element would leave invalid content
-
getFirstChild
-
getChildVector
-
getChildList
-
appendChild
traps the addition of an child to the element content By default this will be routed to addChild() and org.w3c.dom.Node.appendChild(), but other element-specific stuff can be interposed (within the Cont- Parameters:
elem- the element to add (identified by elementName not class)- Throws:
CMLException- element cannot be added (violates content model)
-
getOrCreateChild
get a child of a given name If it doesn't exist, create and add it- Specified by:
getOrCreateChildin interfaceAbstractBase- Parameters:
elemName- the elementName to get/create (identified by elementName not class)- Returns:
- the Element
- Throws:
CMLException- element cannot be added (violates content model)
-
setContentValue
adds text content to an element should only be used for text-only or mixed content.- Specified by:
setContentValuein interfaceAbstractBase- Parameters:
value- the content- Throws:
CMLException- thrown by subclasses
-
getContentValue
gets text content from an element should only be used for text-only or mixed content.- Specified by:
getContentValuein interfaceAbstractBase- Returns:
- value the content; "" if none
- Throws:
CMLException- thrown by subclasses
-
removeTextChildren
removes whitespace nodes or throws any Exception for non-whitespace ones- Specified by:
removeTextChildrenin interfaceAbstractBase- Throws:
CMLException- non-whitespace Text node
-
characters
SAX2 parsing routine called from characters() callback NOT namespace aware- Specified by:
charactersin interfaceAbstractBase- Parameters:
saxHandler- SaxHandlercontent- throws exception (probably application specific)- Throws:
CMLException
-
endElement
SAX2 parsing routine called from endElement() callback NOT namespace aware- Specified by:
endElementin interfaceAbstractBase- Parameters:
saxHandler- Saxhandler throws exception (probably application specific)- Throws:
CMLException
-
startElement
SAX2 parsing routine called from startElement() callback NOT namespace aware- Specified by:
startElementin interfaceAbstractBase- Parameters:
saxHandler- Saxhandlerattributes- the attribute list throws exception (probably application specific)- Throws:
CMLException
-
setAttribute
set attribute. do not use. may be called by autogenerated code. reroutes calls to attribute "elementContent" to setTextChild- Specified by:
setAttributein interfaceAbstractBase- Specified by:
setAttributein interfaceElement- Overrides:
setAttributein classPMRElementImpl- Parameters:
name- The name of the attribute to create or alter.value- Value to set in string form.
-
addTextChild
addStringContent to Element if no Text child, creates one if Text child, resets value if existing non-Text children, no action- Parameters:
value- to add- See Also:
-
setTextChild
addStringContent to Element if no Text child, creates one if Text child, resets value if existing non-Text children, no action- Specified by:
setTextChildin interfaceAbstractBase- Parameters:
value- to add
-
setDebug
public void setDebug(boolean d) toggle debugging- Specified by:
setDebugin interfaceAbstractBase- Parameters:
d- debug
-
getDebug
public boolean getDebug()debug status- Specified by:
getDebugin interfaceAbstractBase- Returns:
- is debug set
-
debug
-
setVersion
set CML version 1 or 2 at present (default 2)- Specified by:
setVersionin interfaceCMLNode- Parameters:
v- version
-
setArraySyntax
public void setArraySyntax(boolean syntax) set array syntax set CML array syntax (default false)- Specified by:
setArraySyntaxin interfaceCMLNode- Parameters:
syntax-
-
writeXML
write XML (allows for syntactic variants)- Specified by:
writeXMLin interfaceCMLNode- Parameters:
w- - outputcontrol- - application specific string for example "CML1 array" or "CML2"- Throws:
IOExceptionCMLException
-
writeXML
write XML use current control (version and syntax)- Specified by:
writeXMLin interfaceAbstractBase- Specified by:
writeXMLin interfaceCMLNode- Parameters:
w- - output- Throws:
CMLExceptionIOException
-
writeXML0
public static void writeXML0(Element elem, Writer w, String control) throws IOException, CMLException - Throws:
IOExceptionCMLException
-
outputChildren
public static void outputChildren(Element elem, Writer w, String control) throws IOException, CMLException - Throws:
IOExceptionCMLException
-
deepCopy
deep clones an element including subclassing. uses intermediate XML serialization object is owned by a new document all CML elements have correct subclass- Specified by:
deepCopyin interfaceAbstractBase- Returns:
- the copied object
-
deepCopy
deep clones an element including subclassing uses intermediate XML serialization object is owned by document- Specified by:
deepCopyin interfaceAbstractBase- Parameters:
document- ownerDocument- Returns:
- the copied object
-
getTool
get tool. creates one if not already created do not use if subclass is known to compiler (use FooToolImpl.getTool(foo) instead)- Specified by:
getToolin interfaceAbstractBase- Returns:
- the tool
-
getOrCreateTool
get or create tool. creates one if not already created should only be used when the subclass is not known to the compiler i.e. where an abstractBase is found- Specified by:
getOrCreateToolin interfaceAbstractBase- Returns:
- the tool
-
setTool
set tool not user-callable- Specified by:
setToolin interfaceAbstractBase- Parameters:
t- tool
-
createToolClassName
constructs a class name for tool at present converts some.where.bar.FooImpl to some.where.tool.FooToolImpl- Parameters:
abstractBase- class object- Returns:
- class name
-
updateDelegates
public void updateDelegates()update delegates. updates this delegates (content and attributes) then recurses through children- Specified by:
updateDelegatesin interfaceAbstractBase
-
updateDOM
public void updateDOM()update DOM. updates this DOM (content and attributes) then recurses through children- Specified by:
updateDOMin interfaceAbstractBase
-
updateDelegateContent
public void updateDelegateContent()update delegate content.- Specified by:
updateDelegateContentin interfaceAbstractBase
-
updateDelegateAttributes
public void updateDelegateAttributes()update delegate attributes.- Specified by:
updateDelegateAttributesin interfaceAbstractBase
-
updateDOMContent
public void updateDOMContent()update DOM content.- Specified by:
updateDOMContentin interfaceAbstractBase
-
updateDOMAttributes
public void updateDOMAttributes()update DOM attributes.- Specified by:
updateDOMAttributesin interfaceAbstractBase
-