com.ibm.commerce.component.servicemapper

Class ServiceMapping

  • java.lang.Object
    • com.ibm.commerce.component.servicemapper.ServiceMapping


  • public class ServiceMapping
    extends java.lang.Object
    This class represents a single mapping between an incoming request attribute (called source) and the targeted service request attribute (called target).
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CLASS_NAME
      The name of this class
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ServiceMapping(java.lang.String source, java.lang.String target, VerbAction action, java.lang.Class nounType)
      Constructs a mapping
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      VerbAction getAction() 
      java.lang.Class getNounType()
      Gets the type of the noun on which the mapping is based.
      java.lang.String getSource() 
      java.lang.String getTarget() 
      java.util.List getVariableNames() 
      static java.util.List getVariables(java.lang.String source)
      Gets a list of variable strings in the given source string.
      static java.util.List getVariableValues(java.lang.String source)
      Get potential variable values of a source.
      boolean hasVariables()
      Determines if this mapping contains variables
      boolean matchesVariables(java.lang.String source)
      Determines if the given source has values matching the variables in this mapping
      java.lang.String resolveTarget(java.lang.String param)
      Replaces the variables in a target string with the value in the given parameter
      void setAction(VerbAction action)
      Sets the action of the mapping
      void setNounType(java.lang.Class nounType)
      Sets the type of the noun on which the mapping is based.
      void setSource(java.lang.String source)
      Sets the source of the mapping
      void setTarget(java.lang.String target)
      Sets the mapping target
      static java.lang.String stripVariable(java.lang.String source)
      Strips variables from a source used for service mapping
      static java.lang.String stripVariableValue(java.lang.String source)
      Strips the possible variable value from a given source.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

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

      • CLASS_NAME

        public static final java.lang.String CLASS_NAME
        The name of this class
      • COPYRIGHT

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

      • ServiceMapping

        public ServiceMapping(java.lang.String source,
                              java.lang.String target,
                              VerbAction action,
                              java.lang.Class nounType)
        Constructs a mapping
        Parameters:
        source - the source to be mapped from
        target - the target to be mapped to from the source
        action - the action for the mapped target
        nounType - the type of the noun that this mapping is based on
    • Method Detail

      • getVariableNames

        public java.util.List getVariableNames()
        Returns:
        a List of Strings. Each string is a variable name.
      • getSource

        public java.lang.String getSource()
        Returns:
        the source of the mapping
      • getTarget

        public java.lang.String getTarget()
        Returns:
        the target of the mapping
      • setSource

        public void setSource(java.lang.String source)
        Sets the source of the mapping
        Parameters:
        source - the source of the mapping to be set
      • setTarget

        public void setTarget(java.lang.String target)
        Sets the mapping target
        Parameters:
        target - the target of the mapping to set
      • getAction

        public VerbAction getAction()
        Returns:
        the action of the mapping
      • setAction

        public void setAction(VerbAction action)
        Sets the action of the mapping
        Parameters:
        action - action of the mapping to be set
      • setNounType

        public void setNounType(java.lang.Class nounType)
        Sets the type of the noun on which the mapping is based.
        Parameters:
        nounType - the type of the noun
      • getNounType

        public java.lang.Class getNounType()
        Gets the type of the noun on which the mapping is based.
        Returns:
        the type of a noun. Null if the type is not set
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation of the mapping
      • stripVariable

        public static java.lang.String stripVariable(java.lang.String source)
        Strips variables from a source used for service mapping
        Parameters:
        source - the source string for process
        Returns:
        the source used for service mapping
      • stripVariableValue

        public static java.lang.String stripVariableValue(java.lang.String source)
        Strips the possible variable value from a given source. For example, if the source is name_1, then the "_1" will be stripped, as it can be a variable value for the parameter name_$index.
        Parameters:
        source - the source to be stripped
        Returns:
        a string that has no possible variable values
      • getVariables

        public static java.util.List getVariables(java.lang.String source)
        Gets a list of variable strings in the given source string. The method is static because it represents the rule which service mappings use to get variables.
        Parameters:
        source - the source string from which the list of variables is retrieved
        Returns:
        A list of variables. Empty list if there is no variable in the given source
      • getVariableValues

        public static java.util.List getVariableValues(java.lang.String source)
        Get potential variable values of a source. For example, name_1 has a potential variable value 1.
        Parameters:
        source - the source to be examined
        Returns:
        a list of variable values. Empty list if no values found
      • matchesVariables

        public boolean matchesVariables(java.lang.String source)
        Determines if the given source has values matching the variables in this mapping
        Parameters:
        source, - the source to be examined
        Returns:
        true if variable patterns are matching. False otherwise.
      • hasVariables

        public boolean hasVariables()
        Determines if this mapping contains variables
        Returns:
        true if this mapping has no variables. Otherwise false.
      • resolveTarget

        public java.lang.String resolveTarget(java.lang.String param)
        Replaces the variables in a target string with the value in the given parameter
        Parameters:
        param - the param that the target is corresponding to
        Returns:
        a target string that has no variables