Package org.cip4.jdflib.core
Class JDFDoc
- java.lang.Object
-
- org.cip4.jdflib.core.XMLDoc
-
- org.cip4.jdflib.core.JDFDoc
-
- All Implemented Interfaces:
java.lang.Cloneable,IStreamWriter
public class JDFDoc extends XMLDoc
-
-
Constructor Summary
Constructors Constructor Description JDFDoc()constructorJDFDoc(java.lang.String strDocType)constructor - create the kind of JDF you needJDFDoc(java.lang.String strDocType, JDFElement.EnumVersion version)constructor - create the kind of JDF you needJDFDoc(DocumentJDFImpl document)constructorJDFDoc(XMLDoc document)constructor note that the constructor will create a copy of the document in case it is not a typesafe DocumentJDFImplJDFDoc(org.w3c.dom.Document document)constructor from a document note that the constructor will create a copy of the document in case it is not a typesafe DocumentJDFImpl
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearDirtyIDs()clear the vector of all IDs of elements that are dirtyJDFDocclone()cloneintcollectGarbageResources(VString nodeNames)Deprecated.use JDFNode.eraseUnlinkedResourcesorg.w3c.dom.ElementcreateElement(java.lang.String elementName)createElement create a JDFElement that floats in nirvana.static JDFDoccreateJDF(java.lang.String jdfPath)Deprecated.simply use constructorprotected JDFDoccreateRoot(org.w3c.dom.Document document)java.lang.StringgetContentType()gets the content typestatic java.lang.StringgetContentType(KElement e)gets the contentType for a given root elementXMLDocUserDatagetCreateXMLDocUserData()get/create the associated XMLDocUserData - it is always there!VStringgetDirtyIDs()get a vector of all IDs of elements that are dirtyprotected DocumentXMLImplgetImpl()booleangetInitOnCreate()if true (the default) initialize element when they are created, else don't call init() when an element is initially createdJDFNodegetJDFNodeByID(java.lang.String id)Deprecated.use getRoot().getTarget(id, AttributeName.ID) and cast.JDFNodegetJDFRoot()GetJDFRoot - get the jdf rootJDFJMFgetJMFRoot()GetJMFRoot - get the jmf rootDocumentJDFImplgetMemberDocument()getMemberDocumentprotected XMLDocUserDatagetXMLDocUserData()Method getXMLDocUserData - get the associated XMLDocUserDataprotected XMLParsergetXMLParser()get the correct parser for this type of documentprotected booleanhasXMLDocUserData()does the owner document of this have an associated XMLDocUserDatabooleanisDirty(java.lang.String strID)is the node with ID dirty?static JDFDocparseFile(java.io.File file)parse a JDF filestatic JDFDocparseFile(java.lang.String fileName)parse a JDF filestatic JDFDocparseStream(java.io.InputStream is)parse a JDF input streamstatic JDFDocparseString(java.lang.String string)parse a JDF stringstatic JDFDocparseURL(java.lang.String url, javax.mail.BodyPart bp)parse a given urlprotected voidpushParser(XMLParser xmlParser)static voidregisterCustomClass(java.lang.String strElement, java.lang.String packagepath)register new custom class in the factoryprotected voidreparse(org.w3c.dom.Document document)voidsetInitOnCreate(boolean bInitOnCreate)if true (the default) initialize element when they are created, else don't call init() when an element is initially createdprotected voidsetMemberDoc(DocumentXMLImpl myDoc)KElementsetRoot(java.lang.String strDocType, java.lang.String namespaceURI)initialize a new root of strDocType in the document called by constructor XMLDoc(String strDocType)voidsetXPathValues(JDFAttributeMap valueMap)set the xpath values of thei to the values in the nodejava.lang.StringtoString()toStringUrlPartwrite2HttpURL(java.net.URL strURL, HTTPDetails det)java.net.HttpURLConnectionwrite2HTTPURL(java.net.URL strURL, HTTPDetails det)JDFDocwrite2URL(java.lang.String strURL)This method sends the contents of this JDFDoc to the URLstrURLand receives the response in the returned JDFDoc.JDFDocwrite2URL(java.lang.String strURL, HTTPDetails details)This method sends the contents of this JDFDoc to the URLstrURLand receives the response in the returned JDFDoc.-
Methods inherited from class org.cip4.jdflib.core.XMLDoc
appendChild, cloneNode, copyMeta, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElementDefinition, createElementNS, createEntity, createEntityReference, createEvent, createNodeIterator, createNodeIterator, createNotation, createProcessingInstruction, createRange, createTextNode, createTreeWalker, createTreeWalker, equals, flush, getAttributes, getBodyPart, getChildNode, getChildNodes, getDocMemoryUsed, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getErrorChecking, getFirstChild, getIdentifier, getIdentifiers, getImplementation, getIndent, getLastChild, getLineWidth, getLocalName, getMultiPart, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getNSMap, getOriginalFileName, getParentNode, getPrefix, getPreviousSibling, getProcessingInstruction, getRoot, getRootName, getSchemaLocation, getSchemaLocationFile, getValidationResult, getXMLComment, getXSLTURL, getZipReader, hasAttributes, hasChildNodes, hashCode, importNode, insertBefore, isDirty, isNull, isSchemaValid, isSupported, normalize, parseZipFile, putIdentifier, removeChild, removeIdentifier, replaceChild, setBodyPart, setErrorChecking, setIndent, setLineWidth, setNodeValue, setNSMap, setOriginalFileName, setPrefix, setSchemaLocation, setValidationResult, setXSLTURL, setZipReader, toXML, write2File, write2File, write2File, write2File, write2File, write2HttpURL, write2HTTPURL, write2Stream, write2Stream, write2StreamStatic, write2StreamStatic, write2String, write2URL, write2URL, write2Zip, writeStream
-
-
-
-
Constructor Detail
-
JDFDoc
public JDFDoc()
constructor
-
JDFDoc
public JDFDoc(org.w3c.dom.Document document)
constructor from a document note that the constructor will create a copy of the document in case it is not a typesafe DocumentJDFImpl- Parameters:
document-
-
JDFDoc
public JDFDoc(XMLDoc document)
constructor note that the constructor will create a copy of the document in case it is not a typesafe DocumentJDFImpl- Parameters:
document-
-
JDFDoc
public JDFDoc(DocumentJDFImpl document)
constructor- Parameters:
document-
-
JDFDoc
public JDFDoc(java.lang.String strDocType)
constructor - create the kind of JDF you need- Parameters:
strDocType- - ElementName.JDF, ElementName.JMF, "Config" ...
-
JDFDoc
public JDFDoc(java.lang.String strDocType, JDFElement.EnumVersion version)constructor - create the kind of JDF you need- Parameters:
strDocType- - ElementName.JDF, ElementName.JMF, "Config" ...version-
-
-
Method Detail
-
reparse
protected void reparse(org.w3c.dom.Document document)
-
createRoot
protected JDFDoc createRoot(org.w3c.dom.Document document)
- Overrides:
createRootin classXMLDoc
-
getImpl
protected DocumentXMLImpl getImpl()
-
getJDFRoot
public JDFNode getJDFRoot()
GetJDFRoot - get the jdf root- Returns:
- JDFNode - the root of the JDF file
-
setMemberDoc
protected void setMemberDoc(DocumentXMLImpl myDoc)
- Overrides:
setMemberDocin classXMLDoc
-
getJMFRoot
public JDFJMF getJMFRoot()
GetJMFRoot - get the jmf root- Returns:
- JDFJMF - the root of the JMF file
-
clone
public JDFDoc clone()
clone
-
toString
public java.lang.String toString()
toString
-
createJDF
@Deprecated public static JDFDoc createJDF(java.lang.String jdfPath)
Deprecated.simply use constructorCreateJDF- Parameters:
jdfPath-- Returns:
- JDFDoc
-
getJDFNodeByID
@Deprecated public JDFNode getJDFNodeByID(java.lang.String id)
Deprecated.use getRoot().getTarget(id, AttributeName.ID) and cast.returns a JDFNode by its id attribute- Parameters:
id- the ID parameter of the JDF node- Returns:
- JDFNode - the corresponding JDF Node, null if no such node exists
-
collectGarbageResources
@Deprecated public int collectGarbageResources(VString nodeNames)
Deprecated.use JDFNode.eraseUnlinkedResourcesremoves all dangling resources and cleans up the rrefs attributes- Parameters:
nodeNames- the list of nodenames to remove, remove all if nodenames is empty- Returns:
- the number of collected resources
-
getContentType
public java.lang.String getContentType()
gets the content type- Returns:
- the content type, Text/XML if neither jdf nor jmf
-
parseStream
public static JDFDoc parseStream(java.io.InputStream is)
parse a JDF input stream- Parameters:
is-- Returns:
- the parsed JDFDoc
-
parseFile
public static JDFDoc parseFile(java.io.File file)
parse a JDF file- Parameters:
file-- Returns:
- the parsed JDFDoc
-
parseString
public static JDFDoc parseString(java.lang.String string)
parse a JDF string- Parameters:
file-- Returns:
- the parsed JDFDoc
-
parseFile
public static JDFDoc parseFile(java.lang.String fileName)
parse a JDF file- Parameters:
fileName-- Returns:
- the parsed JDFDoc
-
parseURL
public static JDFDoc parseURL(java.lang.String url, javax.mail.BodyPart bp)
parse a given url- Parameters:
url- the url to searchbp- the bodypart that the CID url is located in- Returns:
- the parsed JDFDoc
-
setRoot
public KElement setRoot(java.lang.String strDocType, java.lang.String namespaceURI)
initialize a new root of strDocType in the document called by constructor XMLDoc(String strDocType)
-
registerCustomClass
public static void registerCustomClass(java.lang.String strElement, java.lang.String packagepath)register new custom class in the factory- Parameters:
strElement- fully qualified namepackagepath- package path
-
write2URL
public JDFDoc write2URL(java.lang.String strURL)
This method sends the contents of this JDFDoc to the URLstrURLand receives the response in the returned JDFDoc. the content type is automagically set to either text/xml for undefined xml or to application/vnd.cip4-jdf+xml or application/vnd.cip4-jmf+xml- Parameters:
strURL- the URL to write to- Returns:
- docResponse the response received from URL. A Null document if no response was received, or an exception occurred
-
write2URL
public JDFDoc write2URL(java.lang.String strURL, HTTPDetails details)
This method sends the contents of this JDFDoc to the URLstrURLand receives the response in the returned JDFDoc. the content type is automagically set to either text/xml for undefined xml or to application/vnd.cip4-jdf+xml or application/vnd.cip4-jmf+xml- Parameters:
strURL- the URL to write to- Returns:
- docResponse the response received from URL. A Null document if no response was received, or an exception occurred
-
getXMLParser
protected XMLParser getXMLParser()
get the correct parser for this type of document- Overrides:
getXMLParserin classXMLDoc- Returns:
-
pushParser
protected void pushParser(XMLParser xmlParser)
- Overrides:
pushParserin classXMLDoc- Parameters:
xmlParser-
-
write2HTTPURL
public java.net.HttpURLConnection write2HTTPURL(java.net.URL strURL, HTTPDetails det)- Parameters:
strURL-det-- Returns:
-
write2HttpURL
public UrlPart write2HttpURL(java.net.URL strURL, HTTPDetails det)
- Parameters:
strURL-det-- Returns:
-
getContentType
public static java.lang.String getContentType(KElement e)
gets the contentType for a given root element- Parameters:
e-- Returns:
-
createElement
public org.w3c.dom.Element createElement(java.lang.String elementName)
Description copied from class:XMLDoccreateElement create a JDFElement that floats in nirvana. This must be appended to a node with appendChild (created in namespace JDFCoreConstants.NONAMESPACE (DOM Level 2)).
Another way would be to use KElement.appendElement(String elementName, String nameSpaceURI)- Overrides:
createElementin classXMLDoc- Parameters:
elementName- name of the element that is created- Returns:
- Element - unconnected element that is created
-
getXMLDocUserData
protected XMLDocUserData getXMLDocUserData()
Method getXMLDocUserData - get the associated XMLDocUserData- Returns:
- XMLDocUserData of this object
-
hasXMLDocUserData
protected boolean hasXMLDocUserData()
does the owner document of this have an associated XMLDocUserData- Returns:
- true if XMLDocUserData of this exists
-
getCreateXMLDocUserData
public XMLDocUserData getCreateXMLDocUserData()
get/create the associated XMLDocUserData - it is always there!- Returns:
- the XMLDocUserData of this
-
getDirtyIDs
public VString getDirtyIDs()
get a vector of all IDs of elements that are dirty- Returns:
- VString - the vector of element IDs
-
clearDirtyIDs
public void clearDirtyIDs()
clear the vector of all IDs of elements that are dirty
-
isDirty
public boolean isDirty(java.lang.String strID)
is the node with ID dirty?- Parameters:
strID- id the id to be checked- Returns:
- boolean - true if the node with ID=id is dirty
-
setInitOnCreate
public void setInitOnCreate(boolean bInitOnCreate)
if true (the default) initialize element when they are created, else don't call init() when an element is initially created- Parameters:
bInitOnCreate-
-
getInitOnCreate
public boolean getInitOnCreate()
if true (the default) initialize element when they are created, else don't call init() when an element is initially created- Returns:
- bInitOnCreate
-
getMemberDocument
public DocumentJDFImpl getMemberDocument()
getMemberDocument- Overrides:
getMemberDocumentin classXMLDoc- Returns:
- the MemberDocument
-
setXPathValues
public void setXPathValues(JDFAttributeMap valueMap)
Description copied from class:XMLDocset the xpath values of thei to the values in the node- Overrides:
setXPathValuesin classXMLDoc- Parameters:
valueMap- the map of values, if this is still null, MUST be fully qualified- See Also:
XMLDoc.setXPathValues(org.cip4.jdflib.datatypes.JDFAttributeMap)
-
-