| java.lang.Object org.netbeans.modules.uml.core.support.umlsupport.XMLManip
XMLManip | public class XMLManip (Code) | | Title:
Description:
Copyright: Copyright (c) 2003
Company:
author: not attributable version: 1.0 |
Method Summary | |
public static void | DebugXML(Element element, boolean perform) | public static void | appendNewLineElement(Node parent, Document doc) | public static String | checkForIllegals(String val) Makes sure that there are no invalid characters in the value. | public static void | clearCachedXPaths() | public static Element | createElement(Element element, String name, String xmlNamespace) Creates a new DOM Element in a given XML namspace. | public static Element | createElement(Document doc, String name, String xmlNamespace) Creates a new DOM Element in a given XML namspace. | public static Element | createElement(Element parentNode, String name) | public static Element | createElement(Document doc, String name) | public static Node | ensureNodeExists(Node curNode, String name, String query) | public static Element | findElementByID(Branch branch, String id) Searches under the given element for an element with the xmi.id supplied.
Parameters: branch - The element to search under (Document or Element). Parameters: id - The xmi.id of the element to look for. | public static Node | getAttribute(Node node, String name) | public static boolean | getAttributeBooleanValue(Node n, String str) Retreives a nodes attribute value as a boolean. | public static boolean | getAttributeBooleanValue(Node n, String str, boolean defaultValue) Retreives a nodes attribute value as a boolean. | public static double | getAttributeDoubleValue(Node n, String attr) Retreives a nodes attribute value as an double. | public static int | getAttributeIntValue(Node n, String attr) Retreives a nodes attribute value as an integer. | public static String | getAttributeValue(Attribute attr) | public static String | getAttributeValue(org.dom4j.Node n, String str) Retreives a nodes attribute value as a string. | public static XPath | getCreateCachedXPath(String query) | public static Document | getDOMDocument(String fileName) | public static Document | getDOMDocument(String fileName, IDResolver resolver) | public static Document | getDOMDocument() | public static Document | getDOMDocument(IDResolver resolver) | public static Document | getDOMDocumentFromString(String str) | public static Document | getDOMDocumentUseWeakCache(String fileName) | public static Node | getFirstChild(Node node) Returns the first child node of the given XML node.
Parameters: node - The node in question. | public static Namespace | getNamespace(Element ref, String namespacePrefix) Obtains a DOM4J Namespace given a namespace prefix by querying the XMI
fragment.
Parameters: namespacePrefix - A namespace prefix. | public static QName | getQName(Element ref, String nodeName) Obtains a DOM4J QName given a namespace prefixed nodeName.
Parameters: nodeName - The name of the node, probably qualified by a namespaceprefix. | public static String | getString(String message) Returns the locale specific value for the String message. | public static String | getString(String key, Object[] params) Returns the locale specific message for the given message key, applying
a MessageFormat to it with the supplied parameters, if any.
Parameters: key - The resource bundle key for the desired message. Parameters: params - Additional parameters to customize the message. | public static void | insertNode(Element parent, Node child, int position) Inserts a given child node at the given position in the parent's existing
child nodes. | public static void | insertNode(Element parent, Node child, Node ref) Inserts a given child node before the reference node in the parent's
existing child nodes. | public static XMLManip | instance() | public static Document | loadXML(String text) | public static Document | loadXML(String text, boolean validate) Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: validate - true to validate the XML against any DTDs. | public static Document | loadXML(String text, IDResolver resolver) Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: The - ID resolver used to determine IDs. | public static Document | loadXML(String text, boolean validate, IDResolver resolver) Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: validate - true to validate the XML against any DTDs. | public static void | removeAllChildNodes(Element nodeElement) Removes all child nodes from parentNode.
parentNode[in] the element to modify. | public static Node | removeChild(Node node, String query) | public static String | retrieveDCEID() Generates and retrieves the string representation of the DCE UUID globally
unique identifier. | public static String | retrieveNodeTextValue(Node curNode, String query) Retrieves the text of a given node.
curNode[in] The node to query query[in] The query to perform on curNode to find the node in whose text value we require. | public static String | retrieveSimpleName(org.dom4j.Node node) | public static boolean | save(Document document, String filename) | public static void | saveNode(Node node, String filename) | public static void | saveNodePretty(Node node, String filename) | public static boolean | savePretty(Document document, String filename) | public static List | selectAncestorNodesByAttribute(Node node, String attrName, String attrValue) A query of "ancestor::*[@attrName='attrValue']" type
Parameters: node - Parameters: attrName - Parameters: attrValue - The list of ancestors with required attribute value. | public static List | selectNodeList(org.dom4j.Node pNode, String pattern) | public static List | selectNodeListNS(Node pNode, String pattern) | public static org.dom4j.Node | selectSingleNode(org.dom4j.Node pNode, String pattern) | public static void | setAttributeValue(Element elem, String name, String value) Sets the XML attribute that has the passed in name to the passed in value.
element[in] the element to set that attribute on. | public static void | setAttributeValue(Node n, String name, String value) | public static void | setNodeTextValue(Node curNode, String query, String newVal, boolean useCData) Sets the text value of a node.
curNode[in] The node to query with query[in] The query to find the node to set value[in] The new value useCData[in] true ( the default ) to automatically wrap value in a ![CDATA[...]] block,else false to just set the data. |
DebugXML | public static void DebugXML(Element element, boolean perform)(Code) | | Parameters: element - Parameters: b - |
appendNewLineElement | public static void appendNewLineElement(Node parent, Document doc)(Code) | | Appends a newline to the passed in element
parent[in] The parent to own the text node HRESULT |
checkForIllegals | public static String checkForIllegals(String val)(Code) | | Makes sure that there are no invalid characters in the value. If
there are, they are converted appropriately.
Specifically:
'&' will be changed into &
'<' will be changed into <
'>' will be changed into >
Parameters: value - The value to modify if needed. HRESULT |
clearCachedXPaths | public static void clearCachedXPaths()(Code) | | |
createElement | public static Element createElement(Element element, String name, String xmlNamespace)(Code) | | Creates a new DOM Element in a given XML namspace. This is a lower
level routine than the CreateElement that does not take a namespace
as an argument. This call does NOT add the new element to the passed
in DOM document.
Parameters: element - [in] The element that will recieve the new element. name[in] The name of the element to create. xmlNamespace[in] The XML namespace that the new element shouldbelong to. For example, "omg.org/UML/1.4". Thedefault is "omg.org/UML/1.4" The new DOM node. |
createElement | public static Element createElement(Document doc, String name, String xmlNamespace)(Code) | | Creates a new DOM Element in a given XML namspace. This is a lower
level routine than the CreateElement that does not take a namespace
as an argument. This call does NOT add the new element to the passed
in DOM document.
doc[in] The document that will receive the new element. name[in] The name of the element to create. xmlNamespace[in] The XML namespace that the new element shouldbelong to. For example, "omg.org/UML/1.4". Thedefault is "omg.org/UML/1.4" The new DOM node. |
createElement | public static Element createElement(Document doc, String name)(Code) | | |
ensureNodeExists | public static Node ensureNodeExists(Node curNode, String name, String query)(Code) | | |
findElementByID | public static Element findElementByID(Branch branch, String id)(Code) | | Searches under the given element for an element with the xmi.id supplied.
Parameters: branch - The element to search under (Document or Element). Parameters: id - The xmi.id of the element to look for. The Element if found, or null. |
getAttribute | public static Node getAttribute(Node node, String name)(Code) | | Parameters: node - Parameters: string - |
getAttributeBooleanValue | public static boolean getAttributeBooleanValue(Node n, String str)(Code) | | Retreives a nodes attribute value as a boolean. If the value of the
attribute can not be converted to a boolean then false
will be returned.
Parameters: n - The node that is used to retrieve the attribute. Parameters: str - The name of the attribute value. The boolean value of the attribute. |
getAttributeBooleanValue | public static boolean getAttributeBooleanValue(Node n, String str, boolean defaultValue)(Code) | | Retreives a nodes attribute value as a boolean. If the value of the
attribute can not be converted to a boolean then false
will be returned.
Parameters: n - The node that is used to retrieve the attribute. Parameters: str - The name of the attribute value. Parameters: defaultValue - the value returned if the attribute is not found. The boolean value of the attribute. |
getAttributeDoubleValue | public static double getAttributeDoubleValue(Node n, String attr) throws NumberFormatException(Code) | | Retreives a nodes attribute value as an double. If the value of the
attribute can not be converted to an integer then zero will be returned.
Parameters: n - The node that is used to retrieve the attribute. Parameters: attr - The name of the attribute value. The integer value of the attribute. throws: NumberFormatException - if the attribute does not contain a parsable integer. |
getAttributeIntValue | public static int getAttributeIntValue(Node n, String attr) throws NumberFormatException(Code) | | Retreives a nodes attribute value as an integer. If the value of the
attribute can not be converted to an integer then zero will be returned.
Parameters: n - The node that is used to retrieve the attribute. Parameters: attr - The name of the attribute value. The integer value of the attribute. throws: NumberFormatException - if the attribute does not contain a parsable integer. |
getAttributeValue | public static String getAttributeValue(Attribute attr)(Code) | | |
getAttributeValue | public static String getAttributeValue(org.dom4j.Node n, String str)(Code) | | Retreives a nodes attribute value as a string.
Parameters: n - The node that is used to retrieve the attribute. Parameters: attr - The name of the attribute value. |
getCreateCachedXPath | public static XPath getCreateCachedXPath(String query)(Code) | | |
getDOMDocument | public static Document getDOMDocument(String fileName)(Code) | | |
getDOMDocument | public static Document getDOMDocument(String fileName, IDResolver resolver)(Code) | | |
getDOMDocument | public static Document getDOMDocument()(Code) | | |
getDOMDocument | public static Document getDOMDocument(IDResolver resolver)(Code) | | |
getDOMDocumentFromString | public static Document getDOMDocumentFromString(String str)(Code) | | |
getDOMDocumentUseWeakCache | public static Document getDOMDocumentUseWeakCache(String fileName)(Code) | | |
getFirstChild | public static Node getFirstChild(Node node)(Code) | | Returns the first child node of the given XML node.
Parameters: node - The node in question. Only DOM4J Element Nodes have childnodes, so passing in any other Node will return null. The first child node, or null if there are no children. |
getNamespace | public static Namespace getNamespace(Element ref, String namespacePrefix)(Code) | | Obtains a DOM4J Namespace given a namespace prefix by querying the XMI
fragment.
Parameters: namespacePrefix - A namespace prefix. A DOM4J Namespace, if the namespacePrefix was known to us. |
getQName | public static QName getQName(Element ref, String nodeName)(Code) | | Obtains a DOM4J QName given a namespace prefixed nodeName.
Parameters: nodeName - The name of the node, probably qualified by a namespaceprefix. A DOM4J QName, with the Namespace correctly set if the namespaceprefix matched a known namespace. |
getString | public static String getString(String message)(Code) | | Returns the locale specific value for the String message.
Parameters: message - |
getString | public static String getString(String key, Object[] params)(Code) | | Returns the locale specific message for the given message key, applying
a MessageFormat to it with the supplied parameters, if any.
Parameters: key - The resource bundle key for the desired message. Parameters: params - Additional parameters to customize the message. String The locale-specific text |
insertNode | public static void insertNode(Element parent, Node child, int position)(Code) | | Inserts a given child node at the given position in the parent's existing
child nodes. Note: to append the child node as the last child, it's easier
to directly call parent.add(child) than this method.
It is not necessary to detach the child before calling this method.
Parameters: parent - The parent XML Element. Parameters: child - The child Node to be added to the parent. Parameters: position - The number of the child node before which the new childwill be inserted. |
insertNode | public static void insertNode(Element parent, Node child, Node ref)(Code) | | Inserts a given child node before the reference node in the parent's
existing child nodes. Note: to append the child node as the last child,
it's easier to directly call parent.add(child) than this method.
It is not necessary to detach the child before calling this method.
Parameters: parent - The parent XML Element. Parameters: child - The child Node to be added to the parent. Parameters: position - The number of the child node before which the new childwill be inserted. |
loadXML | public static Document loadXML(String text)(Code) | | Parameters: doc - Parameters: header - |
loadXML | public static Document loadXML(String text, boolean validate)(Code) | | Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: validate - true to validate the XML against any DTDs. The Document created. |
loadXML | public static Document loadXML(String text, IDResolver resolver)(Code) | | Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: The - ID resolver used to determine IDs. The Document created. |
loadXML | public static Document loadXML(String text, boolean validate, IDResolver resolver)(Code) | | Loads a DOM Document from the given XML text.
Parameters: text - The XML text to parse and create a Document from. Parameters: validate - true to validate the XML against any DTDs. The Document created. |
removeAllChildNodes | public static void removeAllChildNodes(Element nodeElement)(Code) | | Removes all child nodes from parentNode.
parentNode[in] the element to modify. HRESULTs |
removeChild | public static Node removeChild(Node node, String query)(Code) | | |
retrieveDCEID | public static String retrieveDCEID()(Code) | | Generates and retrieves the string representation of the DCE UUID globally
unique identifier. See section 3.5.1 in the XMI spec.
the string. The form is like this: "DCE.2fac1234-31f8-11b4-a222-08002b34c003"Perfect for the xmi.uuid attribute. |
retrieveNodeTextValue | public static String retrieveNodeTextValue(Node curNode, String query)(Code) | | Retrieves the text of a given node.
curNode[in] The node to query query[in] The query to perform on curNode to find the node in whose text value we require. value[out] The text value HRESULTs |
retrieveSimpleName | public static String retrieveSimpleName(org.dom4j.Node node)(Code) | | |
save | public static boolean save(Document document, String filename)(Code) | | Parameters: document - Parameters: fileName - |
saveNode | public static void saveNode(Node node, String filename)(Code) | | |
saveNodePretty | public static void saveNodePretty(Node node, String filename)(Code) | | |
savePretty | public static boolean savePretty(Document document, String filename)(Code) | | |
selectAncestorNodesByAttribute | public static List selectAncestorNodesByAttribute(Node node, String attrName, String attrValue)(Code) | | A query of "ancestor::*[@attrName='attrValue']" type
Parameters: node - Parameters: attrName - Parameters: attrValue - The list of ancestors with required attribute value. |
selectNodeList | public static List selectNodeList(org.dom4j.Node pNode, String pattern)(Code) | | |
selectNodeListNS | public static List selectNodeListNS(Node pNode, String pattern)(Code) | | |
selectSingleNode | public static org.dom4j.Node selectSingleNode(org.dom4j.Node pNode, String pattern)(Code) | | Parameters: pNode - Parameters: pattern - |
setAttributeValue | public static void setAttributeValue(Element elem, String name, String value)(Code) | | Sets the XML attribute that has the passed in name to the passed in value.
element[in] the element to set that attribute on. attrName[in] the name of the XML attribute to set. value[in] the actual value to set. HRESULT |
setAttributeValue | public static void setAttributeValue(Node n, String name, String value)(Code) | | |
setNodeTextValue | public static void setNodeTextValue(Node curNode, String query, String newVal, boolean useCData)(Code) | | Sets the text value of a node.
curNode[in] The node to query with query[in] The query to find the node to set value[in] The new value useCData[in] true ( the default ) to automatically wrap value in a ![CDATA[...]] block,else false to just set the data. HRESULTs |
|
|