|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bea.document.internal.Document
The default implementation of the IDocument interface that uses XML for its serialized form. This class SHOULD be safe for multi-thread access, but has not been rigorously tested in this way.
Constructor Summary | |
Document()
Construct a blank document. |
|
Document(Document doc)
Construct a new document from the given Xerces DOM Document. |
|
Document(Element documentElement)
Construct a new document from the given DOM Element. |
|
Document(File file)
Create a document by reading XML text previously saved to a file. |
|
Document(File file,
String encoding)
Construct a new document using the XML content previously saved to a file. |
|
Document(IDocument doc)
Create a new document which is a deep copy of the given document. |
|
Document(InputSource inputSource)
Construct a new document using the given SAX InputSource. |
|
Document(Reader reader)
Construct a new document from the data available from the given Reader. |
|
Document(String xml)
Construct a new document from the given XML. |
|
Document(String xml,
boolean deferParse)
Construct a new document from the given XML. |
Method Summary | |
Attr |
addAttribute(String parentPath,
String attrName)
Add a new attribute to the parent data element referred to by parentPath. |
Attr |
addAttribute(String parentPath,
String attrName,
String value)
Add a new attribute to the parent data element referred to by parentPath. |
void |
addDocumentData(String parentPath,
DocumentData value)
Add the given value to the parent data element referred to by parentPath. |
Element |
addElement(String parentPath,
String elementName)
Add a new element to the parent data element referred to by parentPath. |
Element |
addElement(String parentPath,
String elementName,
String value)
Add a new element to the parent data element referred to by parentPath. |
void |
addNode(String parentPath,
Node node)
Add a new node to the parent data element referred to by parentPath. |
Object |
clone()
Clone this document |
void |
ensureNamespaceDeclaration()
Ensure that the XML content has proper namespace declarations, and if not add a default namespace declaration. |
static void |
ensureNamespaceDeclaration(Reader in,
SOMSchema schema,
com.bea.document.internal.Document.PrefixInfo prefixInfo,
Set globalElementNames,
Writer out)
Ensure that the given XML text has a namespace declaration attached to the given prefix. |
void |
ensureNoNamespaceDeclarations()
Ensure that the XML content does not contain namespace declarations. |
static void |
ensureNoNamespaceDeclarations(Reader in,
Writer out)
Ensure that the XML content does not contain namespace declarations. |
void |
forceParsed()
Force this document into the parsed state by using a DOM parser with the document's internal content. |
void |
fromXML(ContentHandler contentHandler)
Parse the (unparsed) internal content of this document using a SAX parser and the given ContentHandler. |
void |
fromXML(File file)
Retrieves an XML document previously saved to a file. |
void |
fromXML(File file,
String encoding)
Retrieves an XML document previously saved to a file. |
void |
fromXML(InputSource inputSource)
Use the given SAX InputSource to import XML into this document (thus replacing any previous data elements in this document). |
void |
fromXML(Reader reader)
Given an XML stream read from reader, import this representation into this document (thus replacing any previous data elements in this document). |
void |
fromXML(String xmlText)
Given an XML string, import this representation into this document (thus replacing any previous data elements in this document). |
static String |
generateNamespacePrefix(String namespaceURI)
|
static String |
generateNamespacePrefix(String namespaceURI,
Map currentPrefixes)
|
boolean |
getBooleanFrom(String nodeName)
Return a boolean representing the given xpath. |
boolean |
getBooleanFromFirst(String nodeName)
Return a boolean representing the value of the first element found with the given name. |
Calendar |
getDateFrom(String nodeName)
Return a Calendar representing the value of the given xpath. |
Calendar |
getDateFromFirst(String nodeName)
Return a Calendar representing the value of the first element found with the given name. |
Calendar |
getDateTimeFrom(String nodeName)
Return a Calendar representing the value of the given xpath. |
Calendar |
getDateTimeFromFirst(String nodeName)
Return a Calendar representing the value of the first element found with the given name. |
Document |
getDocument()
Get the internal org.w3c.dom.Document object from this document. |
DocumentData |
getDocumentData(String path)
Return an object which encapsulates the data that corresponds to the given path (XPath syntax). |
IDocumentDefinition |
getDocumentDefinition()
Get the IDocumentDefinition for this document which describes the structure and usage of this type of document. |
Element |
getDocumentElement()
Get the internal document element from this document. |
String |
getDocumentTypeName()
Get the document type name for this document. |
double |
getDoubleFrom(String nodeName)
Return a double representing the value of the given xpath. |
double |
getDoubleFromFirst(String nodeName)
Return a double representing the value of the first element found with the given name. |
String |
getEncoding()
Returns the Java encoding value for this document. |
EntityResolver |
getEntityResolver()
Get the EntityResolver being used when unserializing documents. |
String |
getFirstNamespacePrefix()
Get the first usable namespace prefix from this document. |
static Set |
getGlobalAttributeNames(SOMSchema schema)
|
static Set |
getGlobalElementNames(SOMSchema schema)
|
int |
getIntegerFrom(String nodeName)
Return an int representing the value of the given xpath. |
int |
getIntegerFromFirst(String nodeName)
Return an int representing the value of the first element found with the given name. |
String |
getPublicID()
Get the public ID for this document. |
String |
getRawXML()
Get the raw XML for this document. |
String |
getRootElementName()
Get the root element name for this document definition. |
String |
getStringFrom(String nodeName)
Return a string representing the value of the nodes found with the given xpath. |
String |
getStringFromFirst(String nodeName)
Return a string representing the value of the first element found with the given name. |
IDocument[] |
getSubDocuments(String path)
Get an array of sub-documents representing the nodes that are referred to by the path argument. |
String |
getSystemID()
Get the system ID for this document. |
Calendar |
getTimeFrom(String nodeName)
Return a Calendar representing the value of the given xpath. |
Calendar |
getTimeFromFirst(String nodeName)
Return a Calendar representing the value of the first element found with the given name. |
boolean |
getValidating()
Is this Document validating content in calls to fromXML()? |
boolean |
isParsed()
Is this document's XML parsed? If so, the getDocument() method may be used to retrieve the document's parsed XML as a DOM. |
static void |
main(String[] args)
|
void |
removeDocumentData(String path)
Remove the data element referred to by path. |
void |
resetContextNode()
Resets the context node to the document root element. |
static String |
serializeDocumentType(DocumentType docType)
|
static void |
serializeDocumentType(Writer writer,
DocumentType docType)
|
static String |
serializeElement(Element elem)
|
static void |
serializeElement(Writer writer,
Element elem)
|
static void |
serializeElement(Writer writer,
int indent,
int indentSize,
Element elem)
|
void |
setBooleanIn(String nodeName,
boolean newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setBooleanInFirst(String nodeName,
boolean newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setContextNode(DocumentData data)
Sets the context node for use in all queries to data. |
void |
setContextNode(Node node)
Sets the context node for use in all queries to node. |
void |
setContextNode(String path)
Sets the context node for use in all queries to path. |
void |
setDateIn(String nodeName,
Calendar newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setDateInFirst(String nodeName,
Calendar newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setDateTimeIn(String nodeName,
Calendar newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setDateTimeInFirst(String nodeName,
Calendar newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setDocumentData(String path,
DocumentData value)
Set the data element referred to by path to be value. |
void |
setDocumentDefinition(IDocumentDefinition docDef)
Set the IDocumentDefinition for this document. |
void |
setDocumentElement(Element documentElement)
Set the root document element of this document to the given DOM Element. |
void |
setDocumentTypeName(String typeName)
Set the document type name for this document. |
void |
setDoubleIn(String nodeName,
double newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setDoubleInFirst(String nodeName,
double newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setEncoding(String encoding)
|
void |
setEntityResolver(EntityResolver entityResolver)
Set the EntityResolver to use when unserializing. |
void |
setIntegerIn(String nodeName,
int newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setIntegerInFirst(String nodeName,
int newValue)
Set the first element that matches the given XPath to the value given by newValue. |
static void |
setPerThreadEntityResolver(EntityResolver entityResolver)
Convenience method to set the EntityResolver to use when unserializing. |
void |
setPublicID(String id)
Set the public ID for this document. |
void |
setStringIn(String nodeName,
String newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setStringInFirst(String nodeName,
String newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setSystemID(String id)
Set the system ID for this document. |
void |
setTimeIn(String nodeName,
Calendar newValue)
Set the node value of all data nodes found for the given xpath to the string representation of the given newValue. |
void |
setTimeInFirst(String nodeName,
Calendar newValue)
Set the first element that matches the given XPath to the value given by newValue. |
void |
setValidating(boolean validating)
Set this Document to validate/not-validate during calls to fromXML. |
byte[] |
toByteXML()
|
String |
toXML()
Get the XML represented by this document as a String. |
void |
toXML(Writer writer)
Get the XML represented by this document, and write it to the given Writer. |
void |
toXML(Writer writer,
int indentSize,
String encoding)
Get the XML represented by this document, and write it to the given Writer using the given indentSize and character encoding. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Document()
public Document(String xml) throws DocumentParseException, DocumentException
public Document(String xml, boolean deferParse) throws DocumentParseException, DocumentException
public Document(File file) throws DocumentParseException, DocumentException
file
-
DocumentParseException
DocumentException
fromXML(File, String)
public Document(File file, String encoding) throws DocumentParseException, DocumentException
file
- encoding
- The Java encoding style for the content in the given file.
DocumentParseException
DocumentException
public Document(Reader reader) throws DocumentParseException, DocumentException
public Document(Element documentElement)
public Document(Document doc)
public Document(InputSource inputSource) throws DocumentParseException, DocumentException
public Document(IDocument doc)
Method Detail |
public Object clone() throws CloneNotSupportedException
clone
in interface IDocument
CloneNotSupportedException
public Attr addAttribute(String parentPath, String attrName) throws DocumentException
IDocument
addAttribute
in interface IDocument
DocumentException
public Attr addAttribute(String parentPath, String attrName, String value) throws DocumentException
IDocument
addAttribute
in interface IDocument
DocumentException
public Element addElement(String parentPath, String elementName) throws DocumentException
IDocument
addElement
in interface IDocument
DocumentException
public Element addElement(String parentPath, String elementName, String value) throws DocumentException
IDocument
addElement
in interface IDocument
DocumentException
public void addNode(String parentPath, Node node) throws DocumentException
IDocument
addNode
in interface IDocument
DocumentException
public void addDocumentData(String parentPath, DocumentData value) throws DocumentException
IDocument
addDocumentData
in interface IDocument
DocumentException
public void ensureNamespaceDeclaration() throws DocumentParseException, DocumentException
ensureNamespaceDeclaration
in interface IDocument
DocumentParseException
- if this method is forced to parse raw XML
and the parse fails.
DocumentException
- if any other error occurs setting the namespace.public static Set getGlobalElementNames(SOMSchema schema)
public static Set getGlobalAttributeNames(SOMSchema schema)
public static String generateNamespacePrefix(String namespaceURI)
public static String generateNamespacePrefix(String namespaceURI, Map currentPrefixes)
public static void ensureNamespaceDeclaration(Reader in, SOMSchema schema, com.bea.document.internal.Document.PrefixInfo prefixInfo, Set globalElementNames, Writer out) throws DocumentException
in
- The Reader instance that will read the XML text to check.schema
- The SOMSchema that controls the content for this document.prefixInfo
- Prefix to mapping info (can be blank via no-arg ctor).globalElementNames
- A set of names to be treated as global element
names (prefixed at all times).out
- The Writer instance that will write the modified XML text.
DocumentParseException
- if this method is forced to parse raw XML
and the parse fails.
DocumentException
- if any other error occurs adding the namespace.public void ensureNoNamespaceDeclarations() throws DocumentParseException, DocumentException
ensureNoNamespaceDeclarations
in interface IDocument
DocumentParseException
- if this method is forced to parse raw XML
and the parse fails.
DocumentException
- if any other error occurs removing the namespace.public static void ensureNoNamespaceDeclarations(Reader in, Writer out) throws DocumentParseException, DocumentException
DocumentParseException
- if this method is forced to parse raw XML
and the parse fails.
DocumentException
- if any other error occurs removing the namespace.public String getFirstNamespacePrefix() throws DocumentParseException, DocumentException
getFirstNamespacePrefix
in interface IDocument
DocumentParseException
- if we're forced to parse the doc, and fail.
DocumentException
- if any other exception occurs getting the prefix.public void forceParsed() throws DocumentParseException, DocumentException
forceParsed
in interface IDocument
DocumentParseException
DocumentException
public void fromXML(String xmlText) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
DocumentParseException
DocumentException
public void fromXML(File file) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
file
-
DocumentParseException
DocumentException
fromXML(File, String)
public void fromXML(File file, String encoding) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
file
- encoding
- The Java encoding style for the content in the given file.
DocumentParseException
DocumentException
public void fromXML(Reader reader) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
DocumentParseException
DocumentException
public void fromXML(InputSource inputSource) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
DocumentParseException
DocumentException
public void fromXML(ContentHandler contentHandler) throws DocumentParseException, DocumentException
fromXML
in interface IDocument
DocumentParseException
DocumentException
public Document getDocument()
getDocument
in interface IDocument
public DocumentData getDocumentData(String path) throws DocumentException
IDocument
getDocumentData
in interface IDocument
DocumentException
public IDocumentDefinition getDocumentDefinition()
IDocument
getDocumentDefinition
in interface IDocument
public Element getDocumentElement()
getDocumentElement
in interface IDocument
public String getDocumentTypeName()
getDocumentTypeName
in interface IDocument
public String getEncoding()
getEncoding
in interface IDocument
public void setEncoding(String encoding)
public EntityResolver getEntityResolver()
getEntityResolver
in interface IDocument
public String getRawXML()
getRawXML
in interface IDocument
public String getPublicID()
getPublicID
in interface IDocument
public String getRootElementName()
getRootElementName
in interface IDocument
public String getStringFromFirst(String nodeName) throws DocumentException
getStringFromFirst
in interface IDocument
DocumentException
getDocumentData(String)
public int getIntegerFromFirst(String nodeName) throws DocumentException
getIntegerFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public boolean getBooleanFromFirst(String nodeName) throws DocumentException
getBooleanFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public double getDoubleFromFirst(String nodeName) throws DocumentException
getDoubleFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getDateFromFirst(String nodeName) throws DocumentException
getDateFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getDateTimeFromFirst(String nodeName) throws DocumentException
getDateTimeFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getTimeFromFirst(String nodeName) throws DocumentException
getTimeFromFirst
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getDateFrom(String nodeName) throws DocumentException
getDateFrom
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getDateTimeFrom(String nodeName) throws DocumentException
getDateTimeFrom
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public Calendar getTimeFrom(String nodeName) throws DocumentException
getTimeFrom
in interface IDocument
DocumentException
getStringFromFirst(String)
,
getDocumentData(String)
public String getStringFrom(String nodeName) throws DocumentException
getStringFrom
in interface IDocument
DocumentException
getDocumentData(String)
public int getIntegerFrom(String nodeName) throws DocumentException
getIntegerFrom
in interface IDocument
DocumentException
getStringFrom(String)
,
getDocumentData(String)
public boolean getBooleanFrom(String nodeName) throws DocumentException
getBooleanFrom
in interface IDocument
DocumentException
getStringFrom(String)
,
getDocumentData(String)
public double getDoubleFrom(String nodeName) throws DocumentException
getDoubleFrom
in interface IDocument
DocumentException
getStringFrom(String)
,
getDocumentData(String)
public IDocument[] getSubDocuments(String path) throws DocumentException
getSubDocuments
in interface IDocument
DocumentException
public String getSystemID()
getSystemID
in interface IDocument
public boolean getValidating()
getValidating
in interface IDocument
public boolean isParsed()
isParsed
in interface IDocument
public void removeDocumentData(String path) throws DocumentException
IDocument
removeDocumentData
in interface IDocument
DocumentException
public void resetContextNode()
IDocument
resetContextNode
in interface IDocument
setContextNode(Node)
public static String serializeDocumentType(DocumentType docType) throws DocumentException
DocumentException
public static void serializeDocumentType(Writer writer, DocumentType docType) throws IOException
IOException
public static String serializeElement(Element elem) throws DocumentException
DocumentException
public static void serializeElement(Writer writer, Element elem) throws IOException, DocumentException
IOException
DocumentException
public static void serializeElement(Writer writer, int indent, int indentSize, Element elem) throws IOException, DocumentException
IOException
DocumentException
public void setContextNode(String path) throws DocumentException
IDocument
setContextNode
in interface IDocument
DocumentException
public void setContextNode(DocumentData data) throws DocumentException
IDocument
setContextNode
in interface IDocument
DocumentException
setContextNode(String)
public void setContextNode(Node node)
IDocument
setContextNode
in interface IDocument
setContextNode(DocumentData)
public void setDocumentData(String path, DocumentData value) throws DocumentException
IDocument
setDocumentData
in interface IDocument
DocumentException
public void setDocumentDefinition(IDocumentDefinition docDef)
IDocument
setDocumentDefinition
in interface IDocument
public void setDocumentElement(Element documentElement)
setDocumentElement
in interface IDocument
public void setDocumentTypeName(String typeName)
setDocumentTypeName
in interface IDocument
public void setEntityResolver(EntityResolver entityResolver)
setEntityResolver
in interface IDocument
public static void setPerThreadEntityResolver(EntityResolver entityResolver)
public void setPublicID(String id)
setPublicID
in interface IDocument
public void setStringInFirst(String nodeName, String newValue) throws DocumentException
setStringInFirst
in interface IDocument
DocumentException
public void setIntegerInFirst(String nodeName, int newValue) throws DocumentException
setIntegerInFirst
in interface IDocument
DocumentException
public void setBooleanInFirst(String nodeName, boolean newValue) throws DocumentException
setBooleanInFirst
in interface IDocument
DocumentException
public void setDoubleInFirst(String nodeName, double newValue) throws DocumentException
setDoubleInFirst
in interface IDocument
DocumentException
public void setDateInFirst(String nodeName, Calendar newValue) throws DocumentException
setDateInFirst
in interface IDocument
DocumentException
public void setDateTimeInFirst(String nodeName, Calendar newValue) throws DocumentException
setDateTimeInFirst
in interface IDocument
DocumentException
public void setTimeInFirst(String nodeName, Calendar newValue) throws DocumentException
setTimeInFirst
in interface IDocument
DocumentException
public void setStringIn(String nodeName, String newValue) throws DocumentException
setStringIn
in interface IDocument
DocumentException
public void setIntegerIn(String nodeName, int newValue) throws DocumentException
setIntegerIn
in interface IDocument
DocumentException
public void setBooleanIn(String nodeName, boolean newValue) throws DocumentException
setBooleanIn
in interface IDocument
DocumentException
public void setDoubleIn(String nodeName, double newValue) throws DocumentException
setDoubleIn
in interface IDocument
DocumentException
public void setDateIn(String nodeName, Calendar newValue) throws DocumentException
setDateIn
in interface IDocument
DocumentException
public void setDateTimeIn(String nodeName, Calendar newValue) throws DocumentException
setDateTimeIn
in interface IDocument
DocumentException
public void setTimeIn(String nodeName, Calendar newValue) throws DocumentException
setTimeIn
in interface IDocument
DocumentException
public void setSystemID(String id)
setSystemID
in interface IDocument
public void setValidating(boolean validating)
setValidating
in interface IDocument
public String toXML() throws DocumentException
toXML
in interface IDocument
DocumentException
toXML(java.io.Writer)
,
toXML(java.io.Writer, int, String)
public byte[] toByteXML() throws DocumentException
DocumentException
public void toXML(Writer writer) throws IOException, DocumentException
toXML
in interface IDocument
IOException
DocumentException
public void toXML(Writer writer, int indentSize, String encoding) throws IOException, DocumentException
toXML
in interface IDocument
IOException
DocumentException
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |