com.verisign.epp.codec.gen
Class EPPUtil

java.lang.Object
  extended by com.verisign.epp.codec.gen.EPPUtil

public class EPPUtil
extends java.lang.Object

Provides a set of utility static methods for use by the EPP Codec classes.


Field Summary
static java.lang.String DATE_FORMAT
          Format used for the XML Schema date data type.
static java.lang.String DEFAULT_TIME_INSTANT_FORMAT
          Default format used for the XML Schema dateTime data type
 
Constructor Summary
EPPUtil()
           
 
Method Summary
static void appendChildren(org.w3c.dom.Element aSource, org.w3c.dom.Element aDest)
          Appends the children Nodes of aSource as children nodes of aDest.
static java.lang.String collapseWhitespace(java.lang.String inString)
          Collapse Whitespace, which means that all leading and trailing whitespace will be stripped, and all internal whitespace collapsed to single space characters.
static java.math.BigDecimal decodeBigDecimal(org.w3c.dom.Element aElement)
          Decode BigDecimal, from an XML Element.
static java.math.BigDecimal decodeBigDecimal(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode BigDecimal, by XML namespace and tag name, from an XML Element.
static java.lang.Boolean decodeBoolean(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode Boolean, by XML namespace and tag name, from an XML Element.
static boolean decodeBooleanAttr(org.w3c.dom.Element aElement, java.lang.String aAttr)
          Decodes a boolean attribute value given the Element and attribute name.
static EPPCodecComponent decodeComp(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName, java.lang.Class aClass)
          Decode a EPPCodecComponent, by XML namespace and tag name, from an XML Element.
static java.util.List decodeCompList(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName, java.lang.Class aClass)
          Decode a List of EPPCodecComponent's, by XML namespace and tag name, from an XML Element.
static java.util.Vector decodeCompVector(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName, java.lang.Class aClass)
          Decode a Vector of EPPCodecComponent's, by XML namespace and tag name, from an XML Element.
static java.util.Date decodeDate(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode Date, by XML namespace and tag name, from an XML Element.
static java.util.Date decodeDate(java.lang.String aDateValue)
          Decode an XML Schema date data type (YYYY-MM-DD) to a Java Date object.
static java.lang.Integer decodeInteger(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode Integer, by XML namespace and tag name, from an XML Element.
static java.util.List decodeIntegerList(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode a List of Integer's by XML namespace and tag name, from an XML Element.
static java.util.List decodeList(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode a List of String's by XML namespace and tag name, from an XML Element.
static java.lang.String decodeString(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode String, by XML namespace and tag name, from an XML Element.
static java.lang.String decodeStringAttr(org.w3c.dom.Element aElement, java.lang.String aAttr)
          Decodes a string attribute by name.
static java.lang.String decodeStringValue(org.w3c.dom.Element aElement)
          Decode String value from an XML Element.
static java.util.Date decodeTimeInstant(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode Date, as date and time, by XML namespace and tag name, from an XML Element.
static java.util.Date decodeTimeInstant(java.lang.String aTimeInstant)
          Decode an XML Schema timeInstant data type to a Java Date object.
static java.util.Vector decodeVector(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Decode a Vector of String's by XML namespace and tag name, from an XML Element.
static java.lang.String encodeBase64(org.w3c.dom.Element aElement)
          Base64 encode the XML Element tree.
static void encodeBigDecimal(org.w3c.dom.Document aDocument, org.w3c.dom.Element aElement, java.math.BigDecimal aBigDecimal, java.lang.String aFormat)
          Encode a Double in XML with a given XML namespace and tag name.
static void encodeBigDecimal(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.math.BigDecimal aBigDecimal, java.lang.String aNS, java.lang.String aTagName, java.lang.String aFormat)
          Encode a Double in XML with a given XML namespace and tag name.
static void encodeBoolean(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.lang.Boolean aBoolean, java.lang.String aNS, java.lang.String aTagName)
          Encode a Boolean in XML with a given XML namespace and tag name.
static void encodeBooleanAttr(org.w3c.dom.Element aElement, java.lang.String aAttr, boolean aVal)
          Encodes a boolean Element attribute value.
static void encodeComp(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, EPPCodecComponent aComp)
          Encode a EPPCodecComponent instance in XML.
static void encodeCompList(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.List aList)
          Encode a List of EPPCodecComponent's in XML.
static void encodeCompVector(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.Vector aVector)
          Encode a Vector of EPPCodecComponent's in XML.
static java.lang.String encodeDate(java.util.Date aDate)
          Encode a Java Date into an XML Schema date data type string.
static void encodeDate(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.Date aDate, java.lang.String aNS, java.lang.String aTagName)
          Encode a Date in XML with a given XML namespace and tag name.
static void encodeIntegerList(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.List aList, java.lang.String aNS, java.lang.String aTagName)
          Encode a List of Integer's in XML with a given XML namespace and tag name.
static void encodeList(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.List aList, java.lang.String aNS, java.lang.String aTagName)
          Encode a List of String's in XML with a given XML namespace and tag name.
static void encodeNill(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.lang.String aNS, java.lang.String aTagName)
          DOCUMENT ME!
static void encodeString(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.lang.String aString, java.lang.String aNS, java.lang.String aTagName)
          Encode a String in XML with a given XML namespace and tag name.
static void encodeStringList(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.List aList, java.lang.String aNS, java.lang.String aTagName)
           
static java.lang.String encodeTimeInstant(java.util.Date aDate)
          Encode a Java Date into an XML Schema timeInstant data type string.
static void encodeTimeInstant(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.Date aDate, java.lang.String aNS, java.lang.String aTagName)
          Encode a Date, as date and time, in XML with a given XML namespace and tag name.
static void encodeVector(org.w3c.dom.Document aDocument, org.w3c.dom.Element aRoot, java.util.Vector aVector, java.lang.String aNS, java.lang.String aTagName)
          Encode a Vector of String's in XML with a given XML namespace and tag name.
static boolean equalLists(java.util.List aV1, java.util.List aV2)
          compares two List instances.
static boolean equalVectors(java.util.Vector aV1, java.util.Vector aV2)
          compares two Vector instances.
static org.w3c.dom.Element getElementByTagNameNS(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Gets the first direct child element with a given tag name and XML namespace.
static java.util.Vector getElementsByTagNameNS(org.w3c.dom.Element aElement, java.lang.String aNS, java.lang.String aTagName)
          Gets all of the direct child element with a given tag name and XML namespace.
static org.w3c.dom.Element getFirstElementChild(org.w3c.dom.Element aElement)
          Gets the first DOM Element Node of the aElement DOM Element.
static java.lang.String getLocalName(java.lang.String aQualifiedName)
          Gets the local name given the qualified element name.
static org.w3c.dom.Element getNextElementSibling(org.w3c.dom.Element aElement)
          Gets the next sibling Element of a provided Element.
static java.lang.String getPrefix(java.lang.String aQualifiedName)
          Gets the namespace prefix given a qualified name.
static java.lang.String getTextContent(org.w3c.dom.Node node)
          A pass-thru to the getTextContent() method using a default value of false for the required flag.
static java.lang.String getTextContent(org.w3c.dom.Node node, boolean allowEmpty)
          Return the text data within an XML tag.
static java.lang.String getTimeInstantFormat()
          Gets the XML Schema timeDate format used in and #encodeTimeInstant(Document, Element, Date, String, String).
static boolean listSubset(java.util.List aV1, java.util.List aV2)
          Determines if one List is a subset of another List.
static java.lang.String removeWhitespace(java.lang.String inString)
          Remove Whitespace, which means that all whitespace will be stripped.
static void setTimeInstantFormat(java.lang.String aTimeInstantFormat)
          Sets the XML Schema timeDate format used in and #encodeTimeInstant(Document, Element, Date, String, String).
static java.lang.String toString(org.w3c.dom.Element aElement)
          Converts an aElement to a String for printing.
static java.lang.String toString(EPPCodecComponent aComponent)
          Converts an EPPCodecComponent to a String for printing.
static java.lang.String toStringNoIndent(org.w3c.dom.Element aElement)
          Converts an aElement to a String for printing without pretty printing.
static boolean vectorSubset(java.util.Vector aV1, java.util.Vector aV2)
          Determines if one Vector is a subset of another Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIME_INSTANT_FORMAT

public static final java.lang.String DEFAULT_TIME_INSTANT_FORMAT
Default format used for the XML Schema dateTime data type

See Also:
Constant Field Values

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
Format used for the XML Schema date data type.

See Also:
Constant Field Values
Constructor Detail

EPPUtil

public EPPUtil()
Method Detail

getTimeInstantFormat

public static java.lang.String getTimeInstantFormat()
Gets the XML Schema timeDate format used in and #encodeTimeInstant(Document, Element, Date, String, String). The defauLt format is defined by the constant DEFAULT_TIME_INSTANT_FORMAT and it can be overridden using the setTimeInstantFormat(String) method.

Returns:
XML Schema timeDate format used in and #encodeTimeInstant(Document, Element, Date, String, String).

setTimeInstantFormat

public static void setTimeInstantFormat(java.lang.String aTimeInstantFormat)
Sets the XML Schema timeDate format used in and #encodeTimeInstant(Document, Element, Date, String, String). The format must follow the format supported by SimpleDateFormat.

Parameters:
aTimeInstantFormat - XML Schema timeDate format supported by SimpleDateFormat.

appendChildren

public static void appendChildren(org.w3c.dom.Element aSource,
                                  org.w3c.dom.Element aDest)
Appends the children Nodes of aSource as children nodes of aDest.

Parameters:
aSource - Source Element tree to get children from
aDest - Destination Element to append aSource children.

decodeBigDecimal

public static java.math.BigDecimal decodeBigDecimal(org.w3c.dom.Element aElement,
                                                    java.lang.String aNS,
                                                    java.lang.String aTagName)
                                             throws EPPDecodeException
Decode BigDecimal, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:create>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Returns:
BigDecimal value if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeBigDecimal

public static java.math.BigDecimal decodeBigDecimal(org.w3c.dom.Element aElement)
                                             throws EPPDecodeException
Decode BigDecimal, from an XML Element. The aElement element will be decoded and returned. If element is null, null is returned.

Parameters:
aElement - XML Element to decode.
Returns:
BigDecimal value if aElement is not null; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeBoolean

public static java.lang.Boolean decodeBoolean(org.w3c.dom.Element aElement,
                                              java.lang.String aNS,
                                              java.lang.String aTagName)
                                       throws EPPDecodeException
Decode Boolean, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:create>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Returns:
Boolean value if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeBooleanAttr

public static boolean decodeBooleanAttr(org.w3c.dom.Element aElement,
                                        java.lang.String aAttr)
                                 throws EPPDecodeException
Decodes a boolean attribute value given the Element and attribute name.

Parameters:
aElement - Element with the attribute to look for
aAttr - Attribute name
Returns:
Decoded boolean value
Throws:
EPPDecodeException - Cound not find attribute or the attribute value is not a valid boolean value

decodeStringAttr

public static java.lang.String decodeStringAttr(org.w3c.dom.Element aElement,
                                                java.lang.String aAttr)
Decodes a string attribute by name. If the attribute is not found, null is returned.

Parameters:
aElement - Element to search for the attribute
aAttr - Attribute name to search for
Returns:
Attribute String value if exists; null otherwise.

decodeComp

public static EPPCodecComponent decodeComp(org.w3c.dom.Element aElement,
                                           java.lang.String aNS,
                                           java.lang.String aTagName,
                                           java.lang.Class aClass)
                                    throws EPPDecodeException
Decode a EPPCodecComponent, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. There first XML element found will be used to initial and instance of aClass.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:update>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
aClass - Class to instantiate for a found XML element. This must be a class that implements EPPCodecComponent
Returns:
Instance of aClass that represents the found XML elements if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeCompList

public static java.util.List decodeCompList(org.w3c.dom.Element aElement,
                                            java.lang.String aNS,
                                            java.lang.String aTagName,
                                            java.lang.Class aClass)
                                     throws EPPDecodeException
Decode a List of EPPCodecComponent's, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. Each XML element found will result in the instantiation of aClass, which will decode the associated XML element and added to the returned List.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:add>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the contact elements of >domain:add> is "domain:contact".
aClass - Class to instantiate for each found XML element. This must be a class that implements EPPCodecComponent
Returns:
List of EPPCodecComponent elements representing the found XML elements.
Throws:
EPPDecodeException - Error decoding aElement.

decodeCompVector

public static java.util.Vector decodeCompVector(org.w3c.dom.Element aElement,
                                                java.lang.String aNS,
                                                java.lang.String aTagName,
                                                java.lang.Class aClass)
                                         throws EPPDecodeException
Decode a Vector of EPPCodecComponent's, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. Each XML element found will result in the instantiation of aClass, which will decode the associated XML element and added to the returned Vector.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:add>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the contact elements of >domain:add> is "domain:contact".
aClass - Class to instantiate for each found XML element. This must be a class that implements EPPCodecComponent
Returns:
Vector of EPPCodecComponent elements representing the found XML elements.
Throws:
EPPDecodeException - Error decoding aElement.

decodeDate

public static java.util.Date decodeDate(org.w3c.dom.Element aElement,
                                        java.lang.String aNS,
                                        java.lang.String aTagName)
                                 throws EPPDecodeException
Decode Date, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned. The format used for decoding the date is defined by the constant EPPUtil.DATE_FORMAT.

Parameters:
aElement - XML Element to scan. For example, the element could be <trans-id>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:epp".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the transaction Id date is "date".
Returns:
Date value if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeDate

public static java.util.Date decodeDate(java.lang.String aDateValue)
Decode an XML Schema date data type (YYYY-MM-DD) to a Java Date object.

Parameters:
aDateValue - XML Schema date data type string (YYYY-MM-DD).
Returns:
Java Date object.

decodeInteger

public static java.lang.Integer decodeInteger(org.w3c.dom.Element aElement,
                                              java.lang.String aNS,
                                              java.lang.String aTagName)
                                       throws EPPDecodeException
Decode Integer, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:create>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Returns:
Integer value if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeList

public static java.util.List decodeList(org.w3c.dom.Element aElement,
                                        java.lang.String aNS,
                                        java.lang.String aTagName)
                                 throws EPPDecodeException
Decode a List of String's by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. Each XML element found will be decoded and added to the returned List. Empty child elements, will result in empty string ("") return List elements.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:update>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Returns:
List of String elements representing the text nodes of the found XML elements.
Throws:
EPPDecodeException - Error decoding aElement.

decodeString

public static java.lang.String decodeString(org.w3c.dom.Element aElement,
                                            java.lang.String aNS,
                                            java.lang.String aTagName)
                                     throws EPPDecodeException
Decode String, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:create>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Returns:
String value if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeStringValue

public static java.lang.String decodeStringValue(org.w3c.dom.Element aElement)
Decode String value from an XML Element.

Parameters:
aElement - XML Element to get the String value.
Returns:
String value if set; "" other.
Throws:
EPPDecodeException - Error decoding aElement.

decodeTimeInstant

public static java.util.Date decodeTimeInstant(org.w3c.dom.Element aElement,
                                               java.lang.String aNS,
                                               java.lang.String aTagName)
                                        throws EPPDecodeException
Decode Date, as date and time, by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. The first XML element found will be decoded and returned. If no element is found, null is returned. The format used for decoding the date is defined by the constant EPPUtil.TIME_INSTANT_FORMAT.

Parameters:
aElement - XML Element to scan. For example, the element could be <trans-id>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:epp".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the transaction Id date is "date".
Returns:
Date value as date and time if found; null otherwise.
Throws:
EPPDecodeException - Error decoding aElement.

decodeTimeInstant

public static java.util.Date decodeTimeInstant(java.lang.String aTimeInstant)
Decode an XML Schema timeInstant data type to a Java Date object.

Parameters:
aTimeInstant - XML Schema timeInstant data type string.
Returns:
Java Date object if aTimeInstant format is valid; null otherwise

decodeVector

public static java.util.Vector decodeVector(org.w3c.dom.Element aElement,
                                            java.lang.String aNS,
                                            java.lang.String aTagName)
                                     throws EPPDecodeException
Decode a Vector of String's by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. Each XML element found will be decoded and added to the returned Vector. Empty child elements, will result in empty string ("") return Vector elements.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:update>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Returns:
Vector of String elements representing the text nodes of the found XML elements.
Throws:
EPPDecodeException - Error decoding aElement.

encodeBigDecimal

public static void encodeBigDecimal(org.w3c.dom.Document aDocument,
                                    org.w3c.dom.Element aRoot,
                                    java.math.BigDecimal aBigDecimal,
                                    java.lang.String aNS,
                                    java.lang.String aTagName,
                                    java.lang.String aFormat)
                             throws EPPEncodeException
Encode a Double in XML with a given XML namespace and tag name. Takes an optional argument for the format of the Double, if not provided then it uses #0.00 which formats the double to 2 decimal places.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aBigDecimal - Double to add.
aNS - XML namespace of the element. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
aFormat - Format to use following the DecimalFormat format. If null is passed, the default format of "#0.00" is used.
Throws:
EPPEncodeException - Error encoding the Double.

encodeBigDecimal

public static void encodeBigDecimal(org.w3c.dom.Document aDocument,
                                    org.w3c.dom.Element aElement,
                                    java.math.BigDecimal aBigDecimal,
                                    java.lang.String aFormat)
                             throws EPPEncodeException
Encode a Double in XML with a given XML namespace and tag name. Takes an optional argument for the format of the Double, if not provided then it uses #0.00 which formats the double to 2 decimal places.

Parameters:
aElement - XML Element to add the text node encoded with the BigDecimal value.
aBigDecimal - Double to encode into the text node of the element.
aFormat - Format to use following the DecimalFormat format. If null is passed, the default format of "#0.00" is used.
Throws:
EPPEncodeException - Error encoding the Double.

encodeBoolean

public static void encodeBoolean(org.w3c.dom.Document aDocument,
                                 org.w3c.dom.Element aRoot,
                                 java.lang.Boolean aBoolean,
                                 java.lang.String aNS,
                                 java.lang.String aTagName)
                          throws EPPEncodeException
Encode a Boolean in XML with a given XML namespace and tag name. If aBoolean is null an element is not added.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aBoolean - Boolean to add.
aNS - XML namespace of the element. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Throws:
EPPEncodeException - Error encoding the Boolean.

encodeBooleanAttr

public static void encodeBooleanAttr(org.w3c.dom.Element aElement,
                                     java.lang.String aAttr,
                                     boolean aVal)
Encodes a boolean Element attribute value. The attribute is set to "1" with a value of true and is set to "0" with a value of false.

Parameters:
aElement - Element to add attribute to
aAttr - Attribute name
aVal - Attribute boolean value

encodeComp

public static void encodeComp(org.w3c.dom.Document aDocument,
                              org.w3c.dom.Element aRoot,
                              EPPCodecComponent aComp)
                       throws EPPEncodeException
Encode a EPPCodecComponent instance in XML. The component is first checked for not being null, than it will be appended as a child of aRoot.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add to. For example, the root node could be <domain:update>
aComp - EPPCodecComponent's to add.
Throws:
EPPEncodeException - Error encoding EPPCodecComponent.

encodeCompList

public static void encodeCompList(org.w3c.dom.Document aDocument,
                                  org.w3c.dom.Element aRoot,
                                  java.util.List aList)
                           throws EPPEncodeException
Encode a List of EPPCodecComponent's in XML. Each aList element will be encoded and added to aRoot.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aList - List of EPPCodecComponent's to add.
Throws:
EPPEncodeException - Error encoding the List of EPPCodecComponent's.

encodeCompVector

public static void encodeCompVector(org.w3c.dom.Document aDocument,
                                    org.w3c.dom.Element aRoot,
                                    java.util.Vector aVector)
                             throws EPPEncodeException
Encode a Vector of EPPCodecComponent's in XML. Each aVector element will be encoded and added to aRoot.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aVector - Vector of EPPCodecComponent's to add.
Throws:
EPPEncodeException - Error encoding the Vector of EPPCodecComponent's.

encodeDate

public static java.lang.String encodeDate(java.util.Date aDate)
Encode a Java Date into an XML Schema date data type string.

Parameters:
aDate - Java Date to encode into a XML Schema date data type string.
Returns:
Encoded XML Schema date data type string.

encodeDate

public static void encodeDate(org.w3c.dom.Document aDocument,
                              org.w3c.dom.Element aRoot,
                              java.util.Date aDate,
                              java.lang.String aNS,
                              java.lang.String aTagName)
                       throws EPPEncodeException
Encode a Date in XML with a given XML namespace and tag name. The format used for encoding the date is defined by the constant EPPUtil.DATE_FORMAT.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aDate - Date to add.
aNS - XML namespace of the element. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Throws:
EPPEncodeException - Error encoding Date.

encodeList

public static void encodeList(org.w3c.dom.Document aDocument,
                              org.w3c.dom.Element aRoot,
                              java.util.List aList,
                              java.lang.String aNS,
                              java.lang.String aTagName)
                       throws EPPEncodeException
Encode a List of String's in XML with a given XML namespace and tag name.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aList - List of String's to add.
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Throws:
EPPEncodeException - Error encoding the List of String's.

encodeNill

public static void encodeNill(org.w3c.dom.Document aDocument,
                              org.w3c.dom.Element aRoot,
                              java.lang.String aNS,
                              java.lang.String aTagName)
                       throws EPPEncodeException
DOCUMENT ME!

Parameters:
aDocument - DOCUMENT ME!
aRoot - DOCUMENT ME!
aNS - DOCUMENT ME!
aTagName - DOCUMENT ME!
Throws:
EPPEncodeException - DOCUMENT ME!

encodeString

public static void encodeString(org.w3c.dom.Document aDocument,
                                org.w3c.dom.Element aRoot,
                                java.lang.String aString,
                                java.lang.String aNS,
                                java.lang.String aTagName)
                         throws EPPEncodeException
Encode a String in XML with a given XML namespace and tag name.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aString - String to add.
aNS - XML namespace of the element. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name is "domain:name".
Throws:
EPPEncodeException - Error encoding the String.

encodeStringList

public static void encodeStringList(org.w3c.dom.Document aDocument,
                                    org.w3c.dom.Element aRoot,
                                    java.util.List aList,
                                    java.lang.String aNS,
                                    java.lang.String aTagName)

encodeTimeInstant

public static java.lang.String encodeTimeInstant(java.util.Date aDate)
Encode a Java Date into an XML Schema timeInstant data type string. The XML Schema timeInstant data type string has the following format: CCYY-MM-DDThh:mm:ss.ssss can be followed by a Z to indicate Coordinated Universal Time

Parameters:
aDate - Java Date to encode into a XML Schema timeInstant data type string.
Returns:
Encoded XML Schema timeInstant data type string.

encodeTimeInstant

public static void encodeTimeInstant(org.w3c.dom.Document aDocument,
                                     org.w3c.dom.Element aRoot,
                                     java.util.Date aDate,
                                     java.lang.String aNS,
                                     java.lang.String aTagName)
                              throws EPPEncodeException
Encode a Date, as date and time, in XML with a given XML namespace and tag name. The format used for encoding the date is defined by the constant EPPUtil.TIME_INSTANT_FORMAT.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:expire-data>
aDate - Date as date and time to add.
aNS - XML namespace of the element. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain expiration date and time is "domain:expiration-date".
Throws:
EPPEncodeException - Error encoding Date.

encodeVector

public static void encodeVector(org.w3c.dom.Document aDocument,
                                org.w3c.dom.Element aRoot,
                                java.util.Vector aVector,
                                java.lang.String aNS,
                                java.lang.String aTagName)
                         throws EPPEncodeException
Encode a Vector of String's in XML with a given XML namespace and tag name.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aVector - Vector of String's to add.
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Throws:
EPPEncodeException - Error encoding the Vector of String's.

equalLists

public static boolean equalLists(java.util.List aV1,
                                 java.util.List aV2)
compares two List instances. The Java 1.1 List class does not implement the equals methods, so equalLists was written to implement equals of two Lists (aV1 and aV2). This method is not need for Java 2.

Parameters:
aV1 - First List instance to compare.
aV2 - Second List instance to compare.
Returns:
true if List's are equal; false otherwise.

equalVectors

public static boolean equalVectors(java.util.Vector aV1,
                                   java.util.Vector aV2)
compares two Vector instances. The Java 1.1 Vector class does not implement the equals methods, so equalVectors was written to implement equals of two Vectors (aV1 and aV2). This method is not need for Java 2.

Parameters:
aV1 - First Vector instance to compare.
aV2 - Second Vector instance to compare.
Returns:
true if Vector's are equal; false otherwise.

getElementByTagNameNS

public static org.w3c.dom.Element getElementByTagNameNS(org.w3c.dom.Element aElement,
                                                        java.lang.String aNS,
                                                        java.lang.String aTagName)
Gets the first direct child element with a given tag name and XML namespace.

Parameters:
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name to scan for.
Returns:
Matching Element if found; null otherwise.

getElementsByTagNameNS

public static java.util.Vector getElementsByTagNameNS(org.w3c.dom.Element aElement,
                                                      java.lang.String aNS,
                                                      java.lang.String aTagName)
Gets all of the direct child element with a given tag name and XML namespace.

Parameters:
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name to scan for.
Returns:
Vector of Node instances that are elements and have the specified tag name and XML namespace.

getLocalName

public static java.lang.String getLocalName(java.lang.String aQualifiedName)
Gets the local name given the qualified element name. If the local name is passed, it will be simply returned back.R

Parameters:
aQualifiedName - Qualified name of the element like domain:name. A localhost like name can be passed without error.
Returns:
Localname of the qualified name

getPrefix

public static java.lang.String getPrefix(java.lang.String aQualifiedName)
Gets the namespace prefix given a qualified name. If no prefix is found, empty string is returned.

Parameters:
aQualifiedName - Qualified name of the element like domain:name.
Returns:
Namespace prefix of the qualified name if found; empty string ("") if not found.

getFirstElementChild

public static org.w3c.dom.Element getFirstElementChild(org.w3c.dom.Element aElement)
Gets the first DOM Element Node of the aElement DOM Element.

Parameters:
aElement - Element to scan for the first element.
Returns:
Found DOM Element Node if found; null otherwise.

getNextElementSibling

public static org.w3c.dom.Element getNextElementSibling(org.w3c.dom.Element aElement)
Gets the next sibling Element of a provided Element.

Parameters:
aElement - Element to start scan for the next Element.
Returns:
Found DOM Element Node if found; null otherwise.

getTextContent

public static java.lang.String getTextContent(org.w3c.dom.Node node)
                                       throws EPPDecodeException
A pass-thru to the getTextContent() method using a default value of false for the required flag.

Throws:
EPPDecodeException

getTextContent

public static java.lang.String getTextContent(org.w3c.dom.Node node,
                                              boolean allowEmpty)
                                       throws EPPDecodeException
Return the text data within an XML tag.
12345 yields the String "12345"
If the node==null, child==null, value==null, or value=="" => Exception
UNLESS allowEmpty, in which case return ""

For reference:
<tag></tag> => child is null
<tag/> => child is null
<tag> </tag> => value is empty

Throws:
EPPDecodeException

listSubset

public static boolean listSubset(java.util.List aV1,
                                 java.util.List aV2)
Determines if one List is a subset of another List. If every element in aV1 is in aV2 return true; otherwise return false.

Parameters:
aV1 - Subset List to compare against aV2
aV2 - Superset List to compare against aV1
Returns:
true if aV1 is a subset of aV2; false otherwise.

toString

public static java.lang.String toString(EPPCodecComponent aComponent)
Converts an EPPCodecComponent to a String for printing. Each EPPCodecComponent can use this utility method to implement Object.toString().

Parameters:
aComponent - a concrete EPPCodecComponent instance
Returns:
String representation of EPPCodecComponent if successful; "ERROR" String otherwise.

toString

public static java.lang.String toString(org.w3c.dom.Element aElement)
Converts an aElement to a String for printing.

Parameters:
aElement - Element to print
Returns:
String representation of Element if successful; "ERROR" String otherwise.

toStringNoIndent

public static java.lang.String toStringNoIndent(org.w3c.dom.Element aElement)
Converts an aElement to a String for printing without pretty printing.

Parameters:
aElement - Element to print
Returns:
String representation of Element if successful; "ERROR" String otherwise.

vectorSubset

public static boolean vectorSubset(java.util.Vector aV1,
                                   java.util.Vector aV2)
Determines if one Vector is a subset of another Vector. If every element in aV1 is in aV2 return true; otherwise return false.

Parameters:
aV1 - Subset Vector to compare against aV2
aV2 - Superset Vector to compare against aV1
Returns:
true if aV1 is a subset of aV2; false otherwise.

decodeIntegerList

public static java.util.List decodeIntegerList(org.w3c.dom.Element aElement,
                                               java.lang.String aNS,
                                               java.lang.String aTagName)
                                        throws EPPDecodeException
Decode a List of Integer's by XML namespace and tag name, from an XML Element. The children elements of aElement will be searched for the specified aNS namespace URI and the specified aTagName. Each XML element found will be decoded and added to the returned List. Empty child elements, will result in an EPPDecodeException.

Parameters:
aElement - XML Element to scan. For example, the element could be <domain:update>
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Returns:
List of Integer elements representing the text nodes of the found XML elements.
Throws:
EPPDecodeException - Error decoding aElement.

encodeIntegerList

public static void encodeIntegerList(org.w3c.dom.Document aDocument,
                                     org.w3c.dom.Element aRoot,
                                     java.util.List aList,
                                     java.lang.String aNS,
                                     java.lang.String aTagName)
                              throws EPPEncodeException
Encode a List of Integer's in XML with a given XML namespace and tag name.

Parameters:
aDocument - DOM Document of aRoot. This parameter also acts as a factory for XML elements.
aRoot - XML Element to add children nodes to. For example, the root node could be <domain:update>
aList - List of Integer's to add.
aNS - XML namespace of the elements. For example, for domain element this is "urn:iana:xmlns:domain".
aTagName - Tag name of the element including an optional namespace prefix. For example, the tag name for the domain name servers is "domain:server".
Throws:
EPPEncodeException - Error encoding the List of Integer's.

collapseWhitespace

public static java.lang.String collapseWhitespace(java.lang.String inString)
Collapse Whitespace, which means that all leading and trailing whitespace will be stripped, and all internal whitespace collapsed to single space characters. Intended to emulate XML Schema whitespace (collapse) constraining facet: http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace

Parameters:
inString - String to be collapsed
Returns:
String with whitespace collapsed, or null when result is empty

removeWhitespace

public static java.lang.String removeWhitespace(java.lang.String inString)
Remove Whitespace, which means that all whitespace will be stripped.

Parameters:
inString - String from which to remove whitespace
Returns:
String with whitespace removed, or null when result is empty

encodeBase64

public static java.lang.String encodeBase64(org.w3c.dom.Element aElement)
                                     throws java.lang.Exception
Base64 encode the XML Element tree.

Parameters:
aElement - Root element to encode in Base64
Returns:
Base64 encoded value of the XML Element tree.
Throws:
java.lang.Exception - Error encoding the Element


Copyright © VeriSign Inc. All Rights Reserved.