com.ibm.commerce.promotion.uniquecode.generator

Class RandomPattern

  • java.lang.Object
    • com.ibm.commerce.promotion.uniquecode.generator.RandomPattern
    • Constructor Summary

      Constructors 
      Constructor and Description
      RandomPattern()
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String getCode()
      This method gets the generated random code
      char[] getCodeset()
      This method gets the character set
      char getMaskCharacter()
      This method gets the mask character
      java.lang.String getPatternDefinition()
      This method gets the pattern definition
      java.math.BigDecimal getPatternSpace()
      This method calculates the total number of all random codes
      void setCharacterSet(char[] charactersetIn)
      This method sets the character set
      void setMaskCharacter(char maskIn)
      This method sets the mask character
      void setPatternDefinition(java.lang.String patternDefIn)
      This method sets the pattern definition
      boolean validatePattern()
      This method validates the pattern definition
      • Methods inherited from class java.lang.Object

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

      • RandomPattern

        public RandomPattern()
        Default constructor
    • Method Detail

      • getCode

        public java.lang.String getCode()
        This method gets the generated random code
        Specified by:
        getCode in interface Pattern
        Returns:
        The code string
        See Also:
        Pattern.getCode()
      • getPatternSpace

        public java.math.BigDecimal getPatternSpace()
        This method calculates the total number of all random codes
        Specified by:
        getPatternSpace in interface Pattern
        Returns:
        The total number of codes.
        See Also:
        Pattern.getPatternSpace()
      • validatePattern

        public boolean validatePattern()
        This method validates the pattern definition

        If the pattern definition is null or the length of the pattern definition is zero, it will return false.

        If any character inside the pattern is not the mask character, it will return false.

        If all above conditions are not satisfied, the method will read the length of the pattern and return true.

        Specified by:
        validatePattern in interface Pattern
        Returns:
        The validation result.
        See Also:
        Pattern.validatePattern()
      • setMaskCharacter

        public void setMaskCharacter(char maskIn)
        This method sets the mask character
        Parameters:
        maskIn - The mask character
      • getCodeset

        public char[] getCodeset()
        This method gets the character set
        Returns:
        The character set used for code generation
      • setCharacterSet

        public void setCharacterSet(char[] charactersetIn)
        This method sets the character set
        Parameters:
        charactersetIn - The input character set