com.ibm.commerce.tools.epromotion.util

Class XmlHelper

  • java.lang.Object
    • com.ibm.commerce.tools.epromotion.util.XmlHelper


  • public class XmlHelper
    extends java.lang.Object
    The XmlHelper class provides helper methods to deal with XML transformations and read XML node values etc.
    • Constructor Summary

      Constructors 
      Constructor and Description
      XmlHelper()
      XmlHelper constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String generateCategoryXMLStringByCatgroupId(java.lang.String identifierTag, java.lang.String dNTag, java.lang.String catgroupId)
      This method is used to generate the XML representation of a catalog group by identifier and
      java.lang.String generateCustomerProfileXmlStringByMbrGrpId(java.lang.String mbrGrpId)
      This method is using to generate the XML representation of a member group by member group id.
      java.lang.String generateProductXMLStringByCatentryId(java.lang.String partNumberTag, java.lang.String dNTag, java.lang.String catentryId)
      This method is using to generate the XML representation of a catalog entry by part number and
      java.lang.String generateShippingModeXMLStringByShipModeId(java.lang.String codeTag, java.lang.String carrierTag, java.lang.String storeNameTag, java.lang.String ownerDNTag, java.lang.String shipModeId)
      This method is using to generate the XML representation of ship mode by code and carrier.
      java.lang.String generateStoreKeyXMLStringByStoreId(java.lang.String storeKeyTag, java.lang.String dNTag, java.lang.String identifierTag, java.lang.String storeId)
      This method is using to generate the XML representation of a store key by store's identifier and
      java.lang.String getDNByStoreId(java.lang.String storeId)
      Get
      static java.util.Vector getElementTextValue(org.w3c.dom.Document document, java.lang.String elementTagName)
      This method returns a text node String Value.
      static java.util.Vector getElementTextValue(org.w3c.dom.Node node, java.lang.String elementTagName)
      This method returns a Vector of all the possible text values under the same element tag name.
      static java.util.Vector getElementTextValue(java.lang.String xmlString, java.lang.String elementTagName)
      This method returns a Vector of all possible text values which match the given element tag name.
      static java.util.Vector getElementTextValueInNode(org.w3c.dom.Document document, java.lang.String nodeName, java.lang.String elementTagName)
      This method returns a Vector of all the possible text values, which match the given element tag name.
      java.lang.String getLocaleByLanguageId(java.lang.String languageId)
      Get locale by language id
      java.lang.String getUserIdByUserLogonId(java.lang.String userLogonId)
      Get user id by user logon id
      java.lang.String getUserLogonIdByUserId(java.lang.String userId)
      Get user logon id by user id
      static org.w3c.dom.Document getXMLDocument(java.lang.String xmlString)
      Generator the XML Document object based on the XML String input.
      static java.lang.String normalizeXmlValue(java.lang.String s)
      Normalizes the given string for XML parser.
      static java.lang.String normalizeXmlValueForBlaze(java.lang.String s)
      Normalizes the given string.
      static void printDocTree(org.w3c.dom.Node node, java.lang.String indent)
      This method will print a DOM Node out and then recursion on its children.
      static java.lang.String readXmlCharData(java.lang.String s)
      This method will transform predefined XML entity references into the normal character data.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • EFFECTIVE_DATE_FORMAT

        public static final java.lang.String EFFECTIVE_DATE_FORMAT
        Effective date format, this is locale independent. ie. Modified to adopt "31-12-9999" format.
        See Also:
        Constant Field Values
      • EFFECTIVE_DATE_FORMAT_BLAZE

        public static final java.lang.String EFFECTIVE_DATE_FORMAT_BLAZE
        Effective date format in XML presentation, for Blaze rule engine only.
        See Also:
        Constant Field Values
      • EFFECTIVE_TIME_FORMAT

        public static final java.lang.String EFFECTIVE_TIME_FORMAT
        Effective time format in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • SCHEDULING_TIME_FORMAT

        public static final java.lang.String SCHEDULING_TIME_FORMAT
        Scheduling time format in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • MAX_EFFECTIVE_DATE_VALUE

        public static final java.lang.String MAX_EFFECTIVE_DATE_VALUE
        Maximum effective date value, which is locale independent.
        See Also:
        Constant Field Values
      • MAX_EFFECTIVE_DATE_VALUE_BLAZE

        public static final java.lang.String MAX_EFFECTIVE_DATE_VALUE_BLAZE
        Maximum effective date value in XML presentation, for Blaze rule engine only.
        See Also:
        Constant Field Values
      • MAX_EFFECTIVE_TIME_VALUE

        public static final java.lang.String MAX_EFFECTIVE_TIME_VALUE
        Maximum effective time value in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • MIN_EFFECTIVE_DATE_VALUE

        public static final java.lang.String MIN_EFFECTIVE_DATE_VALUE
        Minimum effective date value, which is locale independent.
        See Also:
        Constant Field Values
      • MIN_EFFECTIVE_DATE_VALUE_BLAZE

        public static final java.lang.String MIN_EFFECTIVE_DATE_VALUE_BLAZE
        Minimum effective date value in XML presentation, for Blaze rule engine only.
        See Also:
        Constant Field Values
      • MIN_EFFECTIVE_TIME_VALUE

        public static final java.lang.String MIN_EFFECTIVE_TIME_VALUE
        Minimum effective time value in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • MIN_EFFECTIVE_TIMESTAMP

        public static final java.lang.String MIN_EFFECTIVE_TIMESTAMP
        Minimum effective timestamp in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • MAX_EFFECTIVE_TIMESTAMP

        public static final java.lang.String MAX_EFFECTIVE_TIMESTAMP
        Maximum effective timestamp in XML presentation, for rules based discount only.
        See Also:
        Constant Field Values
      • EFFECTIVE_TIMESTAMP_FORMAT

        public static final java.lang.String EFFECTIVE_TIMESTAMP_FORMAT
        Effective timestamp format, which is locale independent.
        See Also:
        Constant Field Values
      • EFFECTIVE_TIMESTAMP_FORMAT_BLAZE

        public static final java.lang.String EFFECTIVE_TIMESTAMP_FORMAT_BLAZE
        Effective timestamp format in XML presentation, for Blaze rule script only.
        See Also:
        Constant Field Values
      • TEXT_AMPERSAND

        public static final java.lang.String TEXT_AMPERSAND
        Ampersand in XML presentation.
        See Also:
        Constant Field Values
      • TEXT_DOUBLE_QUOTE

        public static final java.lang.String TEXT_DOUBLE_QUOTE
        Double quote in XML presentation
        See Also:
        Constant Field Values
      • TEXT_DOUBLE_QUOTE_FOR_BLAZE

        public static final java.lang.String TEXT_DOUBLE_QUOTE_FOR_BLAZE
        Double quote for XML presentation and Blaze presentation.
        See Also:
        Constant Field Values
      • TEXT_LEFT_ANGLE_BRACKET

        public static final java.lang.String TEXT_LEFT_ANGLE_BRACKET
        Left angle bracket in XML presentation.
        See Also:
        Constant Field Values
      • TEXT_RIGHT_ANGLE_BRACKET

        public static final java.lang.String TEXT_RIGHT_ANGLE_BRACKET
        Right angle bracket in XML presentation.
        See Also:
        Constant Field Values
      • TEXT_SINGLE_QUOTE

        public static final java.lang.String TEXT_SINGLE_QUOTE
        Single quote in XML presentation.
        See Also:
        Constant Field Values
    • Constructor Detail

      • XmlHelper

        public XmlHelper()
        XmlHelper constructor
    • Method Detail

      • getElementTextValue

        public static java.util.Vector getElementTextValue(java.lang.String xmlString,
                                                           java.lang.String elementTagName)
        This method returns a Vector of all possible text values which match the given element tag name. It searches in the Document Object generated from the given XML String.
        Parameters:
        xmlString - a String in XML format
        elementTagName - java.lang.String the tag name for search
        Returns:
        java.util.Vector of all possible text values which match the given element tag name.
      • getElementTextValue

        public static java.util.Vector getElementTextValue(org.w3c.dom.Document document,
                                                           java.lang.String elementTagName)
        This method returns a text node String Value. It is searched by the given parent element tag name from the given Document object. The text node and element node should be one-one match. This will return a Vector of all possible text values which match the given element tag name in the given Document. Creation date: (5/2/2001 1:47:51 PM)
        Parameters:
        document - org.w3c.dom.Document
        elementTagName - java.lang.String the tag name
        Returns:
        java.util.Vector
      • getElementTextValue

        public static java.util.Vector getElementTextValue(org.w3c.dom.Node node,
                                                           java.lang.String elementTagName)
        This method returns a Vector of all the possible text values under the same element tag name. It is searched by the given element tag name from the given Node object. The text node and element node should be one-one match.
        Parameters:
        node - the node in DOM
        elementTagName - the tag name
        Returns:
        Vector containing all the possible text values under the same element tag name.
      • getElementTextValueInNode

        public static java.util.Vector getElementTextValueInNode(org.w3c.dom.Document document,
                                                                 java.lang.String nodeName,
                                                                 java.lang.String elementTagName)
        This method returns a Vector of all the possible text values, which match the given element tag name. It is searched from a node, which name matches a given node name in a given document. For example, a Vector of {
        value1, value3
        } will be returned by passing
        document1, node1, elementName1
        .
         

        <document1> <node1><node4><elementName1>value1</elementName1></node4></node1> <node2><elementName1>value2</elementName1></node2> <node1><elementName1>value3</elementName1></node1> </document1>

        Parameters:
        document - a given document
        nodeName - the node in DOM
        elementTagName - the tag name.
        Returns:
        Vector containing all the possible text values, which match the given element tag name.
      • getXMLDocument

        public static org.w3c.dom.Document getXMLDocument(java.lang.String xmlString)
        Generator the XML Document object based on the XML String input.
        Parameters:
        xml - java.lang.String the XML input in string format
        Returns:
        org.w3c.dom.Document
      • normalizeXmlValue

        public static java.lang.String normalizeXmlValue(java.lang.String s)
        Normalizes the given string for XML parser.
        Parameters:
        s - java.lang.String XML to be normalized.
        Returns:
        Normalized XML String.
      • normalizeXmlValueForBlaze

        public static java.lang.String normalizeXmlValueForBlaze(java.lang.String s)
        Normalizes the given string. This is for XML parser and Blaze rule project, skip their limitation. Blaze could only read '\"' as double quote.
        Parameters:
        s - java.lang.String
        Returns:
        Normalized XML String.
      • readXmlCharData

        public static java.lang.String readXmlCharData(java.lang.String s)
        This method will transform predefined XML entity references into the normal character data. XML predefined exactly five entity references as below: < > & " ' This method will be using to read the character data inside the XML elements and attributes.
        Parameters:
        s - java.lang.String XML input
        Returns:
        Original Char Data.
      • printDocTree

        public static void printDocTree(org.w3c.dom.Node node,
                                        java.lang.String indent)
        This method will print a DOM Node out and then recursion on its children.
        Parameters:
        node - org.w3c.dom.Node
        indent - java.lang.String
      • generateShippingModeXMLStringByShipModeId

        public java.lang.String generateShippingModeXMLStringByShipModeId(java.lang.String codeTag,
                                                                          java.lang.String carrierTag,
                                                                          java.lang.String storeNameTag,
                                                                          java.lang.String ownerDNTag,
                                                                          java.lang.String shipModeId)
                                                                   throws ECException
        This method is using to generate the XML representation of ship mode by code and carrier. The storeEntityId will be getting from commandContext, this will be the unique index of
        shipmode_id
        . This method is for mass loading purpose only, replaces the ship mode primary key with its unique index.
        Parameters:
        codeTag - java.lang.String tag of code
        carrierTag - java.lang.String tag of carrier
        storeNameTag - java.lang.String tag of store name
        ownerDNTag - java.lang.String tag of user DN
        shipModeId - java.lang.String shippment mode ID
        Returns:
        xmlString java.lang.String
        Throws:
        ECException
      • generateProductXMLStringByCatentryId

        public java.lang.String generateProductXMLStringByCatentryId(java.lang.String partNumberTag,
                                                                     java.lang.String dNTag,
                                                                     java.lang.String catentryId)
                                                              throws ECException
        This method is using to generate the XML representation of a catalog entry by part number and
        DN
        . This method is for mass loading purpose only, replaces the
        catentry_id
        primary key with its unique index.
        Parameters:
        partNumberTag - java.lang.String tag for SKU number
        dNTag - java.lang.String tag for DN
        catentryId - java.lang.String catentry id
        Returns:
        XML String
        Throws:
        ECException
      • generateCategoryXMLStringByCatgroupId

        public java.lang.String generateCategoryXMLStringByCatgroupId(java.lang.String identifierTag,
                                                                      java.lang.String dNTag,
                                                                      java.lang.String catgroupId)
                                                               throws ECException
        This method is used to generate the XML representation of a catalog group by identifier and
        DN
        . This method is for mass loading purpose only, replaces the
        catgroup_id
        primary key with its unique index.
        Parameters:
        identifierTag - java.lang.String tag for identifier
        dNTag - java.lang.String tag for DN
        catgroupId - java.lang.String catgroup id
        Returns:
        XML String java.lang.String
        Throws:
        ECException
      • generateStoreKeyXMLStringByStoreId

        public java.lang.String generateStoreKeyXMLStringByStoreId(java.lang.String storeKeyTag,
                                                                   java.lang.String dNTag,
                                                                   java.lang.String identifierTag,
                                                                   java.lang.String storeId)
                                                            throws ECException
        This method is using to generate the XML representation of a store key by store's identifier and
        DN
        . This method is for new promotion infrastructure XML, replaces the
        store_id
        primary key with its unique index.
        Parameters:
        storeKeyTag - java.lang.String tag for store key
        dNTag - java.lang.String tag for DN
        identifierTag - java.lang.String tag for identifier
        storeId - java.lang.String store id
        Returns:
        XML String java.lang.String
        Throws:
        ECException
      • getLocaleByLanguageId

        public java.lang.String getLocaleByLanguageId(java.lang.String languageId)
                                               throws ECException
        Get locale by language id
        Parameters:
        languageId - the language id in string format
        Returns:
        String locale
        Throws:
        ECException
      • getUserLogonIdByUserId

        public java.lang.String getUserLogonIdByUserId(java.lang.String userId)
                                                throws ECException
        Get user logon id by user id
        Parameters:
        userId - the user id
        Returns:
        String userLogonId
        Throws:
        ECException
      • getUserIdByUserLogonId

        public java.lang.String getUserIdByUserLogonId(java.lang.String userLogonId)
                                                throws ECException
        Get user id by user logon id
        Parameters:
        userLogonId - the user logon id
        Returns:
        String userId the user id
        Throws:
        ECException
      • getDNByStoreId

        public java.lang.String getDNByStoreId(java.lang.String storeId)
                                        throws ECException
        Get
        DN
        by store ID
        Parameters:
        storeId - the store id
        Returns:
        String
        DN
        Throws:
        ECException
      • generateCustomerProfileXmlStringByMbrGrpId

        public java.lang.String generateCustomerProfileXmlStringByMbrGrpId(java.lang.String mbrGrpId)
        This method is using to generate the XML representation of a member group by member group id. This method is for new promotion infrastructure XML.
        Parameters:
        mbrGrpId - java.lang.String the member group id.
        Returns:
        XML String java.lang.String