|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
de.folt.models.documentmodel.document.XmlDocument
public class XmlDocument
This class XmlDocument defines the methods for reading and writing an XML
Documents specific for the FOLT/OpenTMS needs.
| Constructor Summary | |
|---|---|
XmlDocument()
Constructor does nothing. |
|
XmlDocument(java.io.File file)
|
|
XmlDocument(java.lang.String fileName)
|
|
| Method Summary | |
|---|---|
static boolean |
bIsXmlDocument(java.lang.String fileName)
bIsXmlDocument check if a document is an xml document - look for |
boolean |
bIsXmLFile(java.lang.String fileName)
bIsXmLFile simple check if a file is an xml file - just check if we find at the start " |
org.jdom.Element |
buildElement(java.lang.String elementString)
buildElement creates an Element from a string representation of the element. |
boolean |
createDocument(java.lang.String xmlDocumentName)
createDocument creates an xml document; must be overridden by subclass |
java.lang.String |
elementContentToString(org.jdom.Element element)
|
java.lang.String |
elementContentToString(org.jdom.Element element,
boolean bDoNotKeepElements)
elementContentToString returns a pure string version of the content of the element. |
java.lang.String |
elementToString(org.jdom.Element element)
elementToString creates a pure string version of the element (including the tag name etc.) |
java.lang.String |
getCatalogueDirectory()
|
org.jdom.Document |
getDocument()
|
org.jdom.Namespace |
getNamespace()
|
java.util.List<org.jdom.Namespace> |
getNamespacelist()
|
org.jdom.Element |
getRoot()
getRoot get the root element of the XmlDocument |
java.lang.String |
getRootElementName()
getRootElementName gets the name of the root element of the loaded document |
static java.lang.String |
getRootElementName(java.lang.String fileName)
getRootElementName gets the name of the root element of an xml file |
org.jdom.Element |
getsubElementFromElementAttributeNameValue(org.jdom.Element element,
java.lang.String subElementName,
java.lang.String attributeName,
java.lang.String attributeValue)
getsubElementFromElementAttributeNameValue get the (sub) element with string name subElementName of an element where the subelement has an attribute with name attributeName and an attribute value of attributeValue Example: <prop-group name="MULTI-624649fa-7e65-42ee-928d-aa2b10b12f27"><prop prop-value="creationid">1233c020bc55054_klemens</prop><prop prop-value="usagecount">0</prop><prop prop-value="entrynumber">21477</prop><prop prop-value="datatype">125447</prop><prop prop-value="changeid">1233c020bc55054_klemens</prop></prop-group> getsubElementFromElementAttributeNameValue(prop-group, "prop", "prop-value", "creation-id") will return <prop prop-value="creationid">1233c020bc55054_klemens</prop> |
org.jdom.Element |
getsubElementFromElementAttributeNameValueRegExp(org.jdom.Element element,
java.lang.String subElementName,
java.lang.String attributeName,
java.lang.String attributeValue)
getsubElementFromElementAttributeNameValueRegExp get the (sub) element with string name subElementName of an element where the subelement has an attribute with name attributeName and an attribute value of attributeValue which is a regular expression Example: <prop-group name="MULTI-624649fa-7e65-42ee-928d-aa2b10b12f27"><prop prop-value="creationid">1233c020bc55054_klemens</prop><prop prop-value="usagecount">0</prop><prop prop-value="entrynumber">21477</prop><prop prop-value="datatype">125447</prop><prop prop-value="changeid">1233c020bc55054_klemens</prop></prop-group> getsubElementFromElementAttributeNameValue(prop-group, "prop", "prop-value", "$creation.*") will return <prop prop-value="creationid">1233c020bc55054_klemens</prop> |
java.lang.String |
getXmlDocumentName()
|
org.jdom.output.XMLOutputter |
getXmlOutputter()
|
java.net.URL |
getXmlURL()
|
boolean |
isBExpandExternalEntities()
|
boolean |
isValidElement(java.lang.String elementString)
|
org.jdom.Document |
loadXmlFile(java.io.File newFile)
loadXmlFile loads an XML file |
org.jdom.Document |
loadXmlFile(java.lang.String filename)
loadXmlFile loads an XML file as a document |
static void |
main(java.lang.String[] args)
main - test xml document just supply a xml document |
java.lang.String |
quoteXMLString(java.lang.String string)
quoteXMLString convert character & < and > to their entity equivalent string = string.replaceAll("<", "<"); string = string.replaceAll(">", ">"); string = string.replaceAll("&", "&"); |
boolean |
saveToXmlFile()
saveToXmlFile saves the currently loaded document back to the original filename |
boolean |
saveToXmlFile(java.io.File outFile)
saveToXmlFile |
boolean |
saveToXmlFile(java.lang.String filename)
saveToXmlFile writes the document to the given file name |
void |
setBExpandExternalEntities(boolean bExpandExternalEntities)
|
void |
setCatalogueDirectory(java.lang.String catalogueDirectory)
|
void |
setDocument(org.jdom.Document document)
|
void |
setNamespace(org.jdom.Namespace namespace)
|
void |
setNamespacelist(java.util.List<org.jdom.Namespace> namespacelist)
|
void |
setXmlDocumentName(java.lang.String xmlDocumentName)
Method stores the name of the associated XML document; in addition it creates an URL from the file name and stores in xmLURL. |
void |
setXmlURL(java.net.URL xmlURL)
|
| Methods inherited from class java.util.Observable |
|---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XmlDocument()
public XmlDocument(java.io.File file)
file - create an xml document and load an xml file streampublic XmlDocument(java.lang.String fileName)
fileName - create an xml document and load an xml file| Method Detail |
|---|
public static boolean bIsXmlDocument(java.lang.String fileName)
fileName - the file to check
public static java.lang.String getRootElementName(java.lang.String fileName)
fileName - the xml file to check
public static void main(java.lang.String[] args)
args - 0: xml document filepublic boolean bIsXmLFile(java.lang.String fileName)
fileName - file to check
public org.jdom.Element buildElement(java.lang.String elementString)
throws OpenTMSException
elementString - the string from which an element should be created.
OpenTMSExceptionpublic boolean createDocument(java.lang.String xmlDocumentName)
xmlDocumentName - the document to create
public java.lang.String elementContentToString(org.jdom.Element element)
element -
public java.lang.String elementContentToString(org.jdom.Element element,
boolean bDoNotKeepElements)
TU string a (0) = "<seg><ph><img class="face" src="../img/face/klemens_waldhoer.jpg" alt="</ph>Dr. Klemens Waldhör<ph>" /></ph></seg>" TU string b (0) = "<ph><img class="face" src="../img/face/klemens_waldhoer.jpg" alt="</ph>Dr. Klemens Waldhör<ph>" /></ph>"
element - the element to create a string for the content
public java.lang.String elementToString(org.jdom.Element element)
"<seg><ph><img class="face" src="../img/face/klemens_waldhoer.jpg" alt="</ph>Dr. Klemens Waldhör<ph>" /></ph></seg>"
element - the element to create a string from
public java.lang.String getCatalogueDirectory()
public org.jdom.Document getDocument()
public org.jdom.Namespace getNamespace()
public java.util.List<org.jdom.Namespace> getNamespacelist()
public org.jdom.Element getRoot()
public java.lang.String getRootElementName()
public org.jdom.Element getsubElementFromElementAttributeNameValue(org.jdom.Element element,
java.lang.String subElementName,
java.lang.String attributeName,
java.lang.String attributeValue)
<prop-group name="MULTI-624649fa-7e65-42ee-928d-aa2b10b12f27"><prop prop-value="creationid">1233c020bc55054_klemens</prop><prop prop-value="usagecount">0</prop><prop prop-value="entrynumber">21477</prop><prop prop-value="datatype">125447</prop><prop prop-value="changeid">1233c020bc55054_klemens</prop></prop-group>
getsubElementFromElementAttributeNameValue(prop-group, "prop", "prop-value", "creation-id") will return
<prop prop-value="creationid">1233c020bc55054_klemens</prop>
element - the element which is the super element
("surrounds subElementName")subElementName - the string name of the sub elementattributeName - the searched attribute name of the sub elementattributeValue - the searched attribute value of the searched attribute name of
the sub element
public org.jdom.Element getsubElementFromElementAttributeNameValueRegExp(org.jdom.Element element,
java.lang.String subElementName,
java.lang.String attributeName,
java.lang.String attributeValue)
<prop-group name="MULTI-624649fa-7e65-42ee-928d-aa2b10b12f27"><prop prop-value="creationid">1233c020bc55054_klemens</prop><prop prop-value="usagecount">0</prop><prop prop-value="entrynumber">21477</prop><prop prop-value="datatype">125447</prop><prop prop-value="changeid">1233c020bc55054_klemens</prop></prop-group>
getsubElementFromElementAttributeNameValue(prop-group, "prop", "prop-value", "$creation.*") will return
<prop prop-value="creationid">1233c020bc55054_klemens</prop>
element - the element which is the super element
("surrounds subElementName")subElementName - the string name of the sub elementattributeName - the searched attribute name of the sub elementattributeValue - the searched attribute value of the searched attribute name of
the sub element; the search is based on a regular expression
for the attributeValue
public java.lang.String getXmlDocumentName()
public org.jdom.output.XMLOutputter getXmlOutputter()
public java.net.URL getXmlURL()
public boolean isBExpandExternalEntities()
public boolean isValidElement(java.lang.String elementString)
elementString -
public org.jdom.Document loadXmlFile(java.io.File newFile)
newFile - the File of the XML File
public org.jdom.Document loadXmlFile(java.lang.String filename)
filename - the file name of the XML file
public java.lang.String quoteXMLString(java.lang.String string)
string = string.replaceAll("<", "<");
string = string.replaceAll(">", ">");
string = string.replaceAll("&", "&");
string - the string to quote
public boolean saveToXmlFile()
public boolean saveToXmlFile(java.io.File outFile)
outFile - the File handle for the xml output
public boolean saveToXmlFile(java.lang.String filename)
filename - the file anme for the output xml file
public void setBExpandExternalEntities(boolean bExpandExternalEntities)
bExpandExternalEntities - the bExpandExternalEntities to setpublic void setCatalogueDirectory(java.lang.String catalogueDirectory)
catalogueDirectors - the catalogueDirectors to setpublic void setDocument(org.jdom.Document document)
document - the document to setpublic void setNamespace(org.jdom.Namespace namespace)
namespace - the namespace to setpublic void setNamespacelist(java.util.List<org.jdom.Namespace> namespacelist)
namespacelist - the namespacelist to setpublic void setXmlDocumentName(java.lang.String xmlDocumentName)
xmlDocumentName - the xmlDocumentName to set;public void setXmlURL(java.net.URL xmlURL)
xmlURL - the xmlURL to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||