com.jp.protection.priv.pro
Class SerialNumber2

java.lang.Object
  extended by com.jp.protection.priv.pro.SerialNumberBase
      extended by com.jp.protection.priv.pro.SerialNumber2

public class SerialNumber2
extends SerialNumberBase

This class represents simplified license encoded into the textual form similar to: BUK3X-9AY4Z-O7NM2-D65WG-UKRXC. This simple form allows licenses to be printed on product boxes etc. This version S/N allows holding of the following license attributes:

As license alias provides ability to hold all available license attribute this form of S/N is far superior to SerialNumber. It's possible to use Protection! implementation of aliases or use alias to make necessary custom association with required license attributes.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jp.protection.priv.pro.SerialNumberBase
SerialNumberBase.KeyCharsGenerator
 
Field Summary
protected  long fAlias
           
protected static int FIELD_INDEX_ALIAS
           
protected static int FIELD_INDEX_CRC
           
protected static int FIELD_INDEX_LICENSE_NUMBER
           
protected static int FIELD_INDEX_NUMBER_COPIES
           
protected static int[] FIELD_LENGTH_ARRAY
           
protected  long fLicenseNumber
           
protected  long fNumberCopies
           
protected static java.text.NumberFormat INTEGER_FORMAT
           
static long MAX_ALIAS
           
static int MAX_ALIAS_CHARS
           
static long MAX_CRC
           
static int MAX_CRC_CHARS
           
static long MAX_LICENSE_NUMBER
           
static int MAX_LICENSE_NUMBER_CHARS
           
static long MAX_NUMBER_COPIES
           
static int MAX_NUMBER_COPIES_CHARS
           
protected static java.text.MessageFormat SERIAL_NUMBER_FORMAT
           
 
Fields inherited from class com.jp.protection.priv.pro.SerialNumberBase
fKeyChars, fKeyCharsStartOffset, N_A, PATTERN, PATTERN_CHAR, PATTERN_DELIMITER
 
Constructor Summary
SerialNumber2()
          Creates a new instance of the SerialNumber
SerialNumber2(char[] aKeyChars)
          Creates a new instance of the SerialNumber and assigns key characters to it
 
Method Summary
protected  void checkValue(java.lang.String aProperty, long aValue, long aMin, long aMax)
           
 void decode(java.lang.String aSerialNumber)
          Parses textual representation of the Serial Number
 java.lang.String encode()
          Generates textual representation of the Serial Number
protected  java.lang.String excludeCRC(java.lang.String aValue)
           
 long getAlias()
          Returns alias
 long getLicenseNumber()
          Returns license number
 long getNumberCopies()
          Return number of copies
protected  int[] parseFields(java.lang.String aSerialNumber)
           
 void setAlias(long aAlias)
          Specifies alias
 void setLicenseNumber(long aLicenseNumber)
          Specifies license number
 void setNumberCopies(long aNumberCopies)
          Specifies number of copies
protected  long trancateCRC(long aCRC)
           
 
Methods inherited from class com.jp.protection.priv.pro.SerialNumberBase
checkValidChars, contains, decode, encode, encode, generateCRC, getKeyChars, getOffset, invalidSerialNumberError, keyCharsNotSpecifiedError, setKeyChars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CRC

public static final long MAX_CRC
See Also:
Constant Field Values

MAX_LICENSE_NUMBER

public static final long MAX_LICENSE_NUMBER
See Also:
Constant Field Values

MAX_ALIAS

public static final long MAX_ALIAS
See Also:
Constant Field Values

MAX_NUMBER_COPIES

public static final long MAX_NUMBER_COPIES
See Also:
Constant Field Values

MAX_CRC_CHARS

public static final int MAX_CRC_CHARS
See Also:
Constant Field Values

MAX_LICENSE_NUMBER_CHARS

public static final int MAX_LICENSE_NUMBER_CHARS
See Also:
Constant Field Values

MAX_ALIAS_CHARS

public static final int MAX_ALIAS_CHARS
See Also:
Constant Field Values

MAX_NUMBER_COPIES_CHARS

public static final int MAX_NUMBER_COPIES_CHARS
See Also:
Constant Field Values

fAlias

protected long fAlias

fLicenseNumber

protected long fLicenseNumber

fNumberCopies

protected long fNumberCopies

SERIAL_NUMBER_FORMAT

protected static java.text.MessageFormat SERIAL_NUMBER_FORMAT

FIELD_LENGTH_ARRAY

protected static int[] FIELD_LENGTH_ARRAY

FIELD_INDEX_CRC

protected static final int FIELD_INDEX_CRC
See Also:
Constant Field Values

FIELD_INDEX_LICENSE_NUMBER

protected static final int FIELD_INDEX_LICENSE_NUMBER
See Also:
Constant Field Values

FIELD_INDEX_NUMBER_COPIES

protected static final int FIELD_INDEX_NUMBER_COPIES
See Also:
Constant Field Values

FIELD_INDEX_ALIAS

protected static final int FIELD_INDEX_ALIAS
See Also:
Constant Field Values

INTEGER_FORMAT

protected static java.text.NumberFormat INTEGER_FORMAT
Constructor Detail

SerialNumber2

public SerialNumber2()
Creates a new instance of the SerialNumber


SerialNumber2

public SerialNumber2(char[] aKeyChars)
Creates a new instance of the SerialNumber and assigns key characters to it

Parameters:
aKeyChars - key characters
Method Detail

checkValue

protected void checkValue(java.lang.String aProperty,
                          long aValue,
                          long aMin,
                          long aMax)
                   throws SerialNumberException
Throws:
SerialNumberException

getAlias

public long getAlias()
Returns alias

Returns:
alias

setAlias

public void setAlias(long aAlias)
Specifies alias

Parameters:
aAlias - alias
Throws:
SerialNumberException - if alias has an invalid value

getNumberCopies

public long getNumberCopies()
Return number of copies

Returns:
number of copies

setNumberCopies

public void setNumberCopies(long aNumberCopies)
Specifies number of copies

Parameters:
aNumberCopies - number of copies

getLicenseNumber

public long getLicenseNumber()
Returns license number

Returns:
license number

setLicenseNumber

public void setLicenseNumber(long aLicenseNumber)
                      throws SerialNumberException
Specifies license number

Parameters:
aLicenseNumber - license number
Throws:
SerialNumberException - if license number has an invalid value

encode

public java.lang.String encode()
                        throws SerialNumberException
Generates textual representation of the Serial Number

Specified by:
encode in class SerialNumberBase
Returns:
textual representation of the Serial Number
Throws:
SerialNumberException - on any errors

excludeCRC

protected java.lang.String excludeCRC(java.lang.String aValue)

trancateCRC

protected long trancateCRC(long aCRC)

decode

public void decode(java.lang.String aSerialNumber)
            throws SerialNumberException
Parses textual representation of the Serial Number

Specified by:
decode in class SerialNumberBase
Parameters:
aSerialNumber - textual representation of the Serial Number
Throws:
SerialNumberException - if provided textual representation of the Serial Number is invalid

parseFields

protected int[] parseFields(java.lang.String aSerialNumber)