Class XmlHelper
- Author:
- cp/gg 2000.10.25
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceAn interface that describes a callback to resolve a substitutable parameter value.Nested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidaddElements(XmlElement xml, Iterator iter) Add the elements from the iterator to the passed XML.static ObjectConvert the passed Object to the specified type.static ObjectcreateInstance(XmlElement xml, ClassLoader loader, XmlHelper.ParameterResolver resolver) Create an instance of the class configured using an XmlElement of the following structure:static ObjectcreateInstance(XmlElement xml, ClassLoader loader, XmlHelper.ParameterResolver resolver, Class clzAssignable) Create an instance of the class configured using an XmlElement of the following structure:static StringdecodeAttribute(String sValue) Decode an attribute value that was quoted.static StringdecodeContent(String sValue) Decode an element's content value.static StringDecode a System Identifier as per the XML 1.0 Specification 2nd ed section 4.2.2.static StringencodeAttribute(String sValue, char chQuote) Encode an attribute value so that it can be quoted and made part of a valid and well formed XML document.static StringencodeContent(String sValue, boolean fPreferBlockEscape) Encode an element's content value so that it can be made part of a valid and well formed XML document.static XmlElementencodeInitParams(XmlElement xmlParent, XmlElement xmlConfig) Encode the supplied xmlConfig XmlElement as a series of init-param elements.static StringEncode a System Identifier as per the XML 1.0 Specification second edition, section 4.2.2.static XmlElementensureElement(XmlElement xml, String sPath) Ensure that a child element exists.static voidensureNamespace(XmlElement xml, String sPrefix, String sUri) Ensure the existence of the Namespace declaration attribute in a context of the specified XmlElement.static booleanequalsElement(XmlElement xml1, XmlElement xml2) Compare one XML element with another XML element for equality.static booleanequalsValue(XmlValue val1, XmlValue val2) Compare one XML value with another XML value for equality.static XmlElementfindElement(XmlElement xml, String sPath) Find a child element of the specified element with the specified '/'-delimited path.static XmlElementfindElement(XmlElement xml, String sPath, Object oValue) Find a child element of the specified element with the specified '/'-delimited path and specified value.static StringGet the '/'-delimited path of the passed element starting from the root element.static XmlValuegetAttribute(XmlElement xml, String sLocal, String sUri) Get an attribute of the specified XmlElement that matches to the specified local name and the specified Namespace URI.static XmlElementgetElement(XmlElement xml, String sName) Get a child element for the specified element.static XmlElementgetElement(XmlElement xml, String sLocal, String sUri) Get a child element of the specified XmlElement that matches to the specified local name and the specified Namespace URI.static IteratorgetElements(XmlElement xml, String sLocal, String sUri) Get an iterator of child elements of the specified XmlElement that match to the specified local name and the specified Namespace URI.static StringgetNamespacePrefix(XmlElement xml, String sUri) Retrieve the Namespace prefix for a given URI in a context of the specified XmlElement.static StringgetNamespaceUri(XmlElement xml, String sPrefix) Retrieve the Namespace URI for a given prefix in a context of the specified XmlElement.getSchemaLocations(XmlElement xml, String sPrefix) Retrieve a listing of schema locations (schemaLocation/noNamespaceSchemaLocation) URL's referenced in XmlElement and all of its children.static StringgetUniversalName(String sLocal, String sPrefix) Return a universal XML element name.static booleanhasElement(XmlElement xml, String sName) Return true iff the specified element has a child element of the specified name.static inthashElement(XmlElement xml) Provide a hash value for the XML element and all of its contained information.static intProvide a hash value for the XML value.static booleanisCommentValid(String sComment) Validate the passed comment.static booleanisElementMatch(XmlElement xml, String sLocal, String sUri) Check whether or not an element matches to the specified local name and Namespace URI.static booleanisEmpty(XmlElement xml) Check whether or not this element or any of its children elements have any content such as values or attributes.static booleanisEncodingValid(String sEncoding) Validate the passed encoding.static booleanisInstanceConfigEmpty(XmlElement xmlClass) Check whether or not the specified configuration defines an instance of a class.static booleanisNameMatch(XmlElement xml, String sName, String sLocal, String sUri) Check whether or not a universal (composite) name matches to the specified local name and Namespace URI.static booleanisNameValid(String sName) Validate the passed name.static booleanisPublicIdentifierValid(String sName) Validate the passed public identifier.protected static booleanisSimpleSequence(List<XmlElement> listXml) Check whether or not the specified list contains only simple elements with the same names.static booleanisSystemIdentifierValid(String sName) Validate the passed system identifier.static booleanisWhitespace(char ch) Test if the specified character is XML whitespace.static XmlDocumentloadFileOrResource(String sName, String sDescr) Load the configuration from a file or resource.static XmlDocumentloadFileOrResource(String sName, String sDescr, ClassLoader loader) Load the configuration from a file or resource.static XmlDocumentloadFileOrResource(String sName, String sDescr, ClassLoader loader, boolean fWarnNoSchema) Load the configuration from a file or resource.static XmlDocumentloadFileOrResourceOrDefault(String sName, String sDescr, ClassLoader loader) Load the configuration from a file or resource.static XmlDocumentloadResource(String sName, String sDescr) Load the configuration from a resource.static XmlDocumentloadResource(String sName, String sDescr, ClassLoader loader) Load the configuration from resource.static XmlDocumentloadResource(URL url, String sDescr, ClassLoader loader) Load the configuration from a URL resource.protected static XmlDocumentloadResourceInternal(String sName, String sDescr, ClassLoader loader, boolean fFile, boolean fWarnNoSchema, boolean fDefault) Load the configuration from a file or resource.protected static XmlDocumentloadResourceInternal(URL url, String sDescr, boolean fWarnNoSchema) Load the configuration from a URL.static XmlDocumentloadXml(InputStream stream) Load XML from a stream.static XmlDocumentloadXml(InputStream stream, String sCharset) Load XML from a stream using the specified charset.static XmlDocumentLoad XML from a file for a class.static XmlDocumentLoad XML from a file for a class using a given charset.static XmlDocumentLoad XML from a file that is collocated with the specified class with a given charset.static XmlDocumentLoad XML from a string.static voidloadXml(String sXml, XmlDocument xmlRoot) Load XML from a String into the specified XmlElement.static voidloadXml(String sXml, XmlDocument xmlRoot, boolean fValidate) Load XML from a String into the specified XmlElement.static XmlDocumentLoad the XML from the specified url using the default character set.static XmlDocumentLoad the XML from the specified url using the specified character set.static XmlElementmergeSchema(XmlElement xmlTarget, XmlElement xmlSource) Merge thexmlnsschema attributes andxsi:schemaLocationattribute of the targetXmlElementinto the sourceXmlElement.static voidoverrideElement(XmlElement xmlBase, XmlElement xmlOverride) Override the values of the specified base element with values from the specified override element.static voidoverrideElement(XmlElement xmlBase, XmlElement xmlOverride, String sIdAttrName) Override the values of the specified base element with values from the specified override element.static Object[]parseInitParams(XmlElement xmlParams) Parse the specified "init-params" element of the following structure:static Object[]parseInitParams(XmlElement xmlParams, XmlHelper.ParameterResolver resolver) Parse the specified "init-params" element of the following structure:static String[]parseParamTypes(XmlElement xmlParams) Parse the specified "init-params" elements and return the array of the param types.static longparseTime(XmlElement xml, String sName, long cDefault) Parse the String value of the child XmlElement with the given name as a time in milliseconds.static voidFor the children elements of the specified XmlElement purge the repetitive Namespace declarations.static voidpurgeNamespace(XmlElement xml) For the specified XmlElement purge the Namespace declarations that are declared somewhere up the xml tree.static StringXML quote the passed string.static intremoveElement(XmlElement xml, String sName) Remove all immediate child elements with the given namestatic XmlElementRemove all empty descendant elements.static booleanreplaceElement(XmlElement xmlParent, XmlElement xmlReplace) Replace a child element with the same name as the specified element.static voidreplaceSystemProperties(XmlElement xml, String sPropertyAttribute) Replace the values of the XmlElement and all its children that contain the specified attribute with the values returned by the Config.getProperty() call.static StringtoString(XmlSerializable xml) Return the XML of an XmlSerializable object as a String.static XmlElementtransformInitParams(XmlElement xmlParent, XmlElement xmlParams) Transform the specified "init-params" element of the following structure:static StringTrim XML whitespace.static StringTrim trailing XML whitespace.static StringTrim leading XML whitespace.Methods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
- 
Field Details- 
XML_ATTR_SCHEMA_LOCATIONThe XML attribute used to specify schema locations.- See Also:
 
- 
XML_ATTR_XMLNSThe XML attribute name used to specify xml schema.- See Also:
 
 
- 
- 
Constructor Details- 
XmlHelperpublic XmlHelper()
 
- 
- 
Method Details- 
loadXmlLoad XML from a file for a class.- Parameters:
- clz- the class for which to load the XML
- Returns:
- the XML content or null
 
- 
loadXmlLoad XML from a file for a class using a given charset.- Parameters:
- clz- the class for which to load the XML
- sCharset- the charset name; pass null to use the default charset
- Returns:
- the XML content or null
 
- 
loadXmlLoad XML from a file that is collocated with the specified class with a given charset.- Parameters:
- clz- the class for which to load the XML
- sName- the XML file name (including extension if any) that exists in the package from which the class was loaded
- sCharset- the charset name; pass null to use the default charset
- Returns:
- the XML content or null
 
- 
loadXmlLoad XML from a stream.- Parameters:
- stream- the InputStream object
- Returns:
- the XML content
 
- 
loadXmlLoad XML from a stream using the specified charset.- Parameters:
- stream- the InputStream object
- sCharset- the charset name
- Returns:
- the XML content
 
- 
loadXmlLoad the XML from the specified url using the default character set.- Parameters:
- url- the url from which to load the XML
- Returns:
- the XML content
 
- 
loadXmlLoad the XML from the specified url using the specified character set.- Parameters:
- url- the url from which to load the XML
- sCharset- the charset name
- Returns:
- the XML content
 
- 
loadXmlLoad XML from a string.- Parameters:
- sXml- the string containing an XML
- Returns:
- the XML content
 
- 
loadXmlLoad XML from a String into the specified XmlElement.- Parameters:
- sXml- the string containing an XML
- xmlRoot- the root XmlElement to parse the string into
 
- 
loadXmlLoad XML from a String into the specified XmlElement.- Parameters:
- sXml- the string containing an XML
- xmlRoot- the root XmlElement to parse the string into
- fValidate- whether to validate the loaded XML
- Since:
- 14.1.1.0
 
- 
loadResourceLoad the configuration from a resource.- Parameters:
- sName- the name of the resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- Returns:
- the configuration XML
 
- 
loadResourceLoad the configuration from resource.- Parameters:
- sName- the name of the resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- Returns:
- the configuration XML
 
- 
loadResourceLoad the configuration from a URL resource.- Parameters:
- url- the resource URL
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- Returns:
- the configuration XML
 
- 
loadFileOrResourceLoad the configuration from a file or resource.- Parameters:
- sName- the name of the file or resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- Returns:
- the configuration XML
 
- 
loadFileOrResourceLoad the configuration from a file or resource.- Parameters:
- sName- the name of the file or resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- Returns:
- the configuration XML
 
- 
loadFileOrResourceOrDefaultpublic static XmlDocument loadFileOrResourceOrDefault(String sName, String sDescr, ClassLoader loader) Load the configuration from a file or resource.- Parameters:
- sName- the name of the file or resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- Returns:
- the configuration XML
 
- 
loadFileOrResourcepublic static XmlDocument loadFileOrResource(String sName, String sDescr, ClassLoader loader, boolean fWarnNoSchema) Load the configuration from a file or resource.- Parameters:
- sName- the name of the file or resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- fWarnNoSchema- display warning if schema is missing
- Returns:
- the configuration XML
 
- 
loadResourceInternalprotected static XmlDocument loadResourceInternal(String sName, String sDescr, ClassLoader loader, boolean fFile, boolean fWarnNoSchema, boolean fDefault) Load the configuration from a file or resource.- Parameters:
- sName- the name of the file or resource
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- loader- (optional) ClassLoader that should be used to load the configuration resource
- fFile- true if the specified name could refer to a file
- fWarnNoSchema- display warning if schema is missing
- fDefault- try to locate the resource in the default location if it cannot be found
- Returns:
- the configuration XML
 
- 
loadResourceInternalLoad the configuration from a URL.Note: The default character set is used to load configurations provided in files; otherwise the character set "ISO-8859-1" is used. - Parameters:
- url- the file or resource URL
- sDescr- a description of the resource being loaded (e.g. "cache configuration"). The description is only used in logging and error messages related to loading the resource
- fWarnNoSchema- display warning if schema is missing
- Returns:
- the configuration XML
 
- 
isEncodingValidValidate the passed encoding. Encodings are latin strings defined as: [A-Za-z] ([A-Za-z0-9._] | '-')*- Parameters:
- sEncoding- the document encoding
- Returns:
- true if the encoding is valid, false otherwise
 
- 
isSystemIdentifierValidValidate the passed system identifier.- Parameters:
- sName- the system identifier of the XML document
- Returns:
- true if the identifier is valid, false otherwise
 
- 
isPublicIdentifierValidValidate the passed public identifier.- Parameters:
- sName- the public identifier of the XML document
- Returns:
- true if the identifier is valid, false otherwise
 
- 
isCommentValidValidate the passed comment. Comments may not contain "--". See the XML specification 1.0 2ed section 2.5.- Parameters:
- sComment- the XML comment
- Returns:
- true if the comment is valid, false otherwise
 
- 
isNameValidValidate the passed name. Currently, this does not allow the "CombiningChar" or "Extender" characters that are allowed by the XML specification 1.0 2ed section 2.3 [4].- Parameters:
- sName- the XML name to validate
- Returns:
- true if the name is valid, false otherwise
 
- 
isWhitespacepublic static boolean isWhitespace(char ch) Test if the specified character is XML whitespace.- Parameters:
- ch- a character
- Returns:
- true if the passed character is XML whitespace
 
- 
trimTrim XML whitespace. See XML 1.0 2ed section 2.3.- Parameters:
- s- the original String
- Returns:
- the passed String minus any leading or trailing whitespace
 
- 
trimfTrim leading XML whitespace. See XML 1.0 2ed section 2.3.- Parameters:
- s- the original String
- Returns:
- the passed String minus any leading whitespace
 
- 
trimbTrim trailing XML whitespace. See XML 1.0 2ed section 2.3.- Parameters:
- s- the original String
- Returns:
- the passed String minus any trailing whitespace
 
- 
encodeAttributeEncode an attribute value so that it can be quoted and made part of a valid and well formed XML document.- Parameters:
- sValue- the attribute value to encode
- chQuote- the character that will be used to quote the attribute
- Returns:
- the attribute value in its encoded form (but not quoted)
 
- 
decodeAttributeDecode an attribute value that was quoted.- Parameters:
- sValue- the attribute value to decode
- Returns:
- the attribute value in its decoded form
 
- 
encodeContentEncode an element's content value so that it can be made part of a valid and well formed XML document.- Parameters:
- sValue- the content value to encode
- fPreferBlockEscape- pass true to use the CDATA escape if two conditions are met: that escaping is required, and that the value does not contain the string "]]>"
- Returns:
- the attribute value in its encoded form (but not quoted)
 
- 
decodeContentDecode an element's content value.- Parameters:
- sValue- the content value to decode
- Returns:
- the attribute value in its decoded form
 
- 
encodeUriEncode a System Identifier as per the XML 1.0 Specification second edition, section 4.2.2.- Parameters:
- sUri- the URI to encode
- Returns:
- the encoded URI
 
- 
decodeUriDecode a System Identifier as per the XML 1.0 Specification 2nd ed section 4.2.2.- Parameters:
- sUri- the URI to decode
- Returns:
- the decoded URI
 
- 
quoteXML quote the passed string.- Parameters:
- s- the string to quote
- Returns:
- the quoted string
 
- 
getAbsolutePathGet the '/'-delimited path of the passed element starting from the root element.- Parameters:
- xml- an XML element
- Returns:
- the path to the passed element in "absolute" format
 
- 
isEmptyCheck whether or not this element or any of its children elements have any content such as values or attributes.- Parameters:
- xml- an XmlElement
- Returns:
- true iff the element itself and all of its children have neither values nor attributes
 
- 
getElementGet a child element for the specified element. If multiple child elements exist that have the specified name, then the behavior of this method is undefined, and it is permitted to return any one of the matching elements, to return null, or to throw an arbitrary runtime exception.- Parameters:
- xml- an XML element
- sName- the name of the desired child element
- Returns:
- the specified element as an object implementing XmlElement, or null if the specified child element does not exist
 
- 
hasElementReturn true iff the specified element has a child element of the specified name.- Parameters:
- xml- an XML element
- sName- the name of the child element to test for
- Returns:
- true iff the child element exists
 
- 
findElementFind a child element of the specified element with the specified '/'-delimited path.The path format is based on file-system paths (not XPath). - Leading '/' to specify root
- Use of '/' as a path delimiter
- Use of '..' to specify parent
 If multiple child elements exist that have the specified name, then the behavior of this method is undefined, and it is permitted to return any one of the matching elements, to return null, or to throw an arbitrary runtime exception. - Parameters:
- xml- an XML element
- sPath- the path to follow to find the desired XML element
- Returns:
- the child element with the specified path or null if such a child element does not exist
 
- 
findElementFind a child element of the specified element with the specified '/'-delimited path and specified value.The path format is based on file-system paths (not XPath). - Leading '/' to specify root
- Use of '/' as a path delimiter
- Use of '..' to specify parent
 If multiple child elements exist that have the specified name and value, then this method returns any one of the matching elements - Parameters:
- xml- an XML element
- sPath- the path to follow to find the desired XML element
- oValue- the value to match
- Returns:
- the child element with the specified path and value or null if the such a child element does not exist
 
- 
ensureElementEnsure that a child element exists. If any part of the path does not exist create new child elements to match the path.- Parameters:
- xml- and XmlElement
- sPath- element path
- Returns:
- the existing or new XmlElement object
- Throws:
- IllegalArgumentException- if the name is null or if any part of the path is not a legal XML tag name
- UnsupportedOperationException- if any element in the path is immutable or otherwise can not add a child element
- See Also:
 
- 
addElementsAdd the elements from the iterator to the passed XML.- Parameters:
- xml- an XmlElement object to add to
- iter- an Iterator of zero or more XmlElement objects to add
 
- 
removeElementRemove all immediate child elements with the given name- Parameters:
- xml- an XmlElement
- sName- child element name
- Returns:
- the number of removed child elements
- Throws:
- UnsupportedOperationException- if the element is immutable or otherwise cannot remove a child element
 
- 
removeEmptyElementsRemove all empty descendant elements.- Parameters:
- xml- the parent XmlElement
- Returns:
- the input XmlElement
- Throws:
- UnsupportedOperationException- if the element is immutable or otherwise cannot remove a child element
 
- 
replaceElementReplace a child element with the same name as the specified element. If the child element does not exist the specified element is just added.- Parameters:
- xmlParent- parent XmlElement
- xmlReplace- element to replace with
- Returns:
- true if matching child element has been found and replaced; false otherwise
- Throws:
- UnsupportedOperationException- if the parent element is immutable or otherwise cannot remove a child element
 
- 
overrideElementOverride the values of the specified base element with values from the specified override element.The values are only overridden if there is an exact match between the element paths and all attribute values. Empty override values are ignored. Override elements that do not match any of the base elements are just copied over. No ambiguity is allowed. For example, if the base element has more then one child with the same name and attributes then the override is not allowed. - Parameters:
- xmlBase- base XmlElement
- xmlOverride- override XmlElement
- Throws:
- UnsupportedOperationException- if the base element is immutable or there is ambiguity between the override and base elements
 
- 
overrideElementOverride the values of the specified base element with values from the specified override element.The values are only overridden if there is an exact match between the element paths and an attribute value for the specified attribute name. Empty override values are ignored. Override elements that do not match any of the base elements are just copied over. No ambiguity is allowed. For example, if the base element has more then one child with the same name and the specified attribute's value then the override is not allowed. As of Coherence 12.2.1, the only exception from the above rule is a scenario when a parent override element is a homogeneous sequence of identically named simple child elements with no attributes. In that case, all the corresponding child elements from the base are removed and replaced with the override content. - Parameters:
- xmlBase- base XmlElement
- xmlOverride- override XmlElement
- sIdAttrName- attribute name that serves as an identifier allowing to match elements with the same name; if not specified all attributes have to match for an override
- Throws:
- UnsupportedOperationException- if the base element is immutable or there is ambiguity between the override and base elements
 
- 
mergeSchemaMerge thexmlnsschema attributes andxsi:schemaLocationattribute of the targetXmlElementinto the sourceXmlElement.- Parameters:
- xmlTarget- the- XmlElementto merge the schema attributes into
- xmlSource- the- XmlElementto merge the schema attributes from
- Returns:
- the xmlSource element
 
- 
replaceSystemPropertiesReplace the values of the XmlElement and all its children that contain the specified attribute with the values returned by the Config.getProperty() call.This method iterates the specified XmlElement tree and for each element that contains the attribute with the specified name replaces its value with the value of the corresponding system property (if exists). - Parameters:
- xml- the XmlElement to process
- sPropertyAttribute- the name of the attribute that supplies the corresponding system property name
 
- 
getSchemaLocationsRetrieve a listing of schema locations (schemaLocation/noNamespaceSchemaLocation) URL's referenced in XmlElement and all of its children.- Parameters:
- xml- the XmlElement to process
- sPrefix- prefix of schema instances
- Returns:
- List of strings representing the schema location URL's
 
- 
getNamespaceUriRetrieve the Namespace URI for a given prefix in a context of the specified XmlElement.- Parameters:
- xml- the XmlElement
- sPrefix- the Namespace prefix
- Returns:
- the Namespace URI corresponding to the prefix
 
- 
getNamespacePrefixRetrieve the Namespace prefix for a given URI in a context of the specified XmlElement.- Parameters:
- xml- the XmlElement
- sUri- the Namespace URI
- Returns:
- the Namespace prefix corresponding to the URI
 
- 
ensureNamespaceEnsure the existence of the Namespace declaration attribute in a context of the specified XmlElement.- Parameters:
- xml- the XmlElement
- sPrefix- the Namespace prefix
- sUri- the Namespace URI
 
- 
getUniversalNameReturn a universal XML element name.- Parameters:
- sLocal- the local XML element name
- sPrefix- the Namespace prefix
- Returns:
- the universal XML element name.
- See Also:
 
- 
isNameMatchCheck whether or not a universal (composite) name matches to the specified local name and Namespace URI.- Parameters:
- xml- the (context) XmlElement
- sName- the universal name
- sLocal- the local xml name
- sUri- the Namespace URI
- Returns:
- true if the specified element matches to the specified local name and the specified Namespace URI.
 
- 
isElementMatchCheck whether or not an element matches to the specified local name and Namespace URI.- Parameters:
- xml- the XmlElement
- sLocal- the local xml name
- sUri- the Namespace URI
- Returns:
- true if the specified element matches to the specified local name and the specified Namespace URI.
 
- 
getElementGet a child element of the specified XmlElement that matches to the specified local name and the specified Namespace URI.- Parameters:
- xml- the parent XmlElement
- sLocal- the local xml name
- sUri- the Namespace URI
- Returns:
- an element that matches to the specified local name and the specified Namespace URI.
 
- 
isSimpleSequenceCheck whether or not the specified list contains only simple elements with the same names.- Parameters:
- listXml- the list of XmlElements
- Returns:
- true if the specified list contains only simple elements with the same name
 
- 
getAttributeGet an attribute of the specified XmlElement that matches to the specified local name and the specified Namespace URI.- Parameters:
- xml- the XmlElement
- sLocal- the local attribute name
- sUri- the Namespace URI
- Returns:
- an XmlValue that matches to the specified local name and the specified Namespace URI.
 
- 
getElementsGet an iterator of child elements of the specified XmlElement that match to the specified local name and the specified Namespace URI.- Parameters:
- xml- the parent XmlElement
- sLocal- the local xml name
- sUri- the Namespace URI
- Returns:
- an iterator containing all matching child elements.
 
- 
purgeNamespaceFor the specified XmlElement purge the Namespace declarations that are declared somewhere up the xml tree.- Parameters:
- xml- the XmlElement
 
- 
purgeChildrenNamespaceFor the children elements of the specified XmlElement purge the repetitive Namespace declarations.- Parameters:
- xml- the XmlElement
 
- 
parseInitParamsParse the specified "init-params" element of the following structure:<!ELEMENT init-params (init-param*)> <!ELEMENT init-param ((param-name | param-type), param-value, description?)> into an object array.For the purpose of this method only the parameters that have the "param-type" element specified are processed. The following types are supported: - string (a.k.a. java.lang.String)
- boolean (a.k.a. java.lang.Boolean)
- int (a.k.a. java.lang.Integer)
- long (a.k.a. java.lang.Long)
- double (a.k.a. java.lang.Double)
- decimal (a.k.a. java.math.BigDecimal)
- file (a.k.a. java.io.File)
- date (a.k.a. java.sql.Date)
- time (a.k.a. java.sql.Time)
- datetime (a.k.a. java.sql.Timestamp)
- xml (a.k.a. com.tangosol.run.xml.XmlElement)
 - Parameters:
- xmlParams- the "init-params" XmlElement to parse
- Returns:
- an array of parameters
 
- 
parseTimeParse the String value of the child XmlElement with the given name as a time in milliseconds. If the specified child XmlElement does not exist or is empty, the specified default value is returned.- Parameters:
- xml- the parent XmlElement
- sName- the name of the child XmlElement
- cDefault- the default value
- Returns:
- the time (in milliseconds) represented by the specified child XmlElement
 
- 
parseInitParamsParse the specified "init-params" element of the following structure:<!ELEMENT init-params (init-param*)> <!ELEMENT init-param ((param-name | param-type), param-value, description?)> into an object array.For the purpose of this method only the parameters that have the "param-type" element specified are processed. The following types are supported: - string (a.k.a. java.lang.String)
- boolean (a.k.a. java.lang.Boolean)
- int (a.k.a. java.lang.Integer)
- long (a.k.a. java.lang.Long)
- double (a.k.a. java.lang.Double)
- decimal (a.k.a. java.math.BigDecimal)
- file (a.k.a. java.io.File)
- date (a.k.a. java.sql.Date)
- time (a.k.a. java.sql.Time)
- datetime (a.k.a. java.sql.Timestamp)
- xml (a.k.a. com.tangosol.run.xml.XmlElement)
 - Parameters:
- xmlParams- the "init-params" XmlElement to parse
- resolver- a ParameterResolver to resolve "{macro}" values (optional)
- Returns:
- an array of parameters
 
- 
transformInitParamsTransform the specified "init-params" element of the following structure:<!ELEMENT init-params (init-param*)> <!ELEMENT init-param ((param-name | param-type), param-value, description?)> into an XML element composed of the corresponding names. For example, the the "init-params" element of the following structure:<init-param> <param-name>NameOne</param-name> <param-value>ValueOne</param-value> </init-param> <init-param> <param-name>NameTwo</param-name> <param-value>ValueTwo</param-value> </init-param>will transform into<NameOne>ValueOne</NameOne> <NameTwo>ValueTwo</NameTwo> For the purpose of this method only the parameters that have the "param-name" element specified are processed.- Parameters:
- xmlParent- the XML element to insert the transformed elements into
- xmlParams- the "init-params" XmlElement to parse
- Returns:
- the resulting XmlElement (xmlParent)
 
- 
encodeInitParamsEncode the supplied xmlConfig XmlElement as a series of init-param elements. This operation is the inverse of transformInitParams.- Parameters:
- xmlParent- the element in which to add the init-param elements
- xmlConfig- the element to encode from
- Returns:
- the resulting XmlElement (xmlParent)
 
- 
parseParamTypesParse the specified "init-params" elements and return the array of the param types.- Parameters:
- xmlParams- the "init-params" XmlElement to parse
- Returns:
- an array of parameter types
 
- 
isInstanceConfigEmptyCheck whether or not the specified configuration defines an instance of a class. The specified XmlElement should be of the same structure as used in thecreateInstance()method.- Parameters:
- xmlClass- the XML element that contains the instantiation info
- Returns:
- true iff there is no class configuration information available
 
- 
createInstancepublic static Object createInstance(XmlElement xml, ClassLoader loader, XmlHelper.ParameterResolver resolver) Create an instance of the class configured using an XmlElement of the following structure:<!ELEMENT ... (class-name | (class-factory-name, method-name), init-params?> <!ELEMENT init-params (init-param*)> <!ELEMENT init-param ((param-name | param-type), param-value, description?)> As of Coherence 3.6 the supplied element may specify all of the above elements within an <instance> element.- Parameters:
- xml- the XML element that contains the instantiation info
- loader- a ClassLoader that should be used to load necessary classes (optional)
- resolver- a ParameterResolver to resolve "{macro}" values (optional)
- Returns:
- an object instantiated or obtained based on the class configuration
 
- 
createInstancepublic static Object createInstance(XmlElement xml, ClassLoader loader, XmlHelper.ParameterResolver resolver, Class clzAssignable) Create an instance of the class configured using an XmlElement of the following structure:<!ELEMENT ... (class-name | (class-factory-name, method-name), init-params?> <!ELEMENT init-params (init-param*)> <!ELEMENT init-param ((param-name | param-type), param-value, description?)> As of Coherence 3.6 the supplied element may also be of the following format:<!ELEMENT instance> where the "instance" format is the same as above.- Parameters:
- xml- the XML element that contains the instantiation info
- loader- a ClassLoader that should be used to load necessary classes (optional)
- resolver- a ParameterResolver to resolve "{macro}" values (optional)
- clzAssignable- if non-null, this method will validate that the Class is assignable from the loaded Class
- Returns:
- an object instantiated or obtained based on the class configuration
 
- 
hashElementProvide a hash value for the XML element and all of its contained information. The hash value is defined as a xor of the following:- the hashCode from the element's value (i.e. super.hashCode())
- the hashCode from each attribute name
- the hashCode from each attribute value
- the hashCode from each sub-element
 - Parameters:
- xml- the XML element
- Returns:
- the hash value for the XML element
 
- 
hashValueProvide a hash value for the XML value. The hash value is defined as one of the following:- 0 if getValue() returns null
- otherwise the hash value is the hashCode() of the string representation of the value
 - Parameters:
- val- the XML value
- Returns:
- the hash value for the XML value
 
- 
equalsElementCompare one XML element with another XML element for equality.- Parameters:
- xml1- a non-null XmlElement object
- xml2- a non-null XmlElement object
- Returns:
- true if the elements are equal, false otherwise
 
- 
equalsValueCompare one XML value with another XML value for equality.- Parameters:
- val1- a non-null XmlValue object
- val2- a non-null XmlValue object
- Returns:
- true if the values are equal, false otherwise
 
- 
toStringReturn the XML of an XmlSerializable object as a String.- Parameters:
- xml- an object that can serialize itself into XML
- Returns:
- a String description of the object
 
- 
convertConvert the passed Object to the specified type.- Parameters:
- o- the object value or null
- nType- the enumerated type to convert to
- Returns:
- an object of the specified type
 
 
-