de.mguennewig.pobjects.metadata
Class ISRCType

java.lang.Object
  extended by de.mguennewig.pobjects.metadata.AbstractType
      extended by de.mguennewig.pobjects.metadata.ScalarType
          extended by de.mguennewig.pobjects.metadata.StringType
              extended by de.mguennewig.pobjects.metadata.ISRCType
All Implemented Interfaces:
Type

public class ISRCType
extends StringType

Data type for the `International Standard Recording Code' or short `ISRC'.

The `ISRC' consist out of the following sections:

  1. ISO 3166-1 alpha-2 country code (2 characters)
  2. the three character alphanumeric registrant code
  3. the last two digits of the year of registration
  4. designation code, five remaining digits
.

This class does only check the format of an `ISRC' but not whether each section is valid, like in an existing country or registrant.

Author:
Michael Günnewig
See Also:
"ISO 3901"

Field Summary
 
Fields inherited from class de.mguennewig.pobjects.metadata.StringType
RESTRICT_TO_ALPHANUM, RESTRICT_TO_ANYTHING, RESTRICT_TO_CHARSET, RESTRICT_TO_NUMERIC, RESTRICT_TO_REGEXP
 
Fields inherited from interface de.mguennewig.pobjects.metadata.Type
CLASS_NAME, TYPE_NAME
 
Constructor Summary
ISRCType()
          Creates a new ISRC type.
 
Method Summary
 void checkSyntax(java.lang.String value)
          
 java.lang.String formatNative(java.lang.Object value)
          Map value from its `native' string representation to its internal representation based on the type.
static java.lang.String getCountry(java.lang.String isrc)
          Returns the ISO 3166-1 alpha-2 country code (2 characters).
static java.lang.String getDesignationCode(java.lang.String isrc)
          Returns the designation code of the `ISRC'.
static java.lang.String getRegistrantCode(java.lang.String isrc)
          Returns the character alphanumeric registrant code.
static java.lang.String[] getSections(java.lang.String isrc)
          Returns the 4 sections of an `ISRC'.
static java.lang.String getYear(java.lang.String isrc)
          Returns the last two digits of the year of registration.
 
Methods inherited from class de.mguennewig.pobjects.metadata.StringType
checkConstraints, getErrorMsgKey, getJavaClass, getMaxFieldSize, getMinimumLength, getPattern, getRestrictTo, getSize, parseNative, setParam
 
Methods inherited from class de.mguennewig.pobjects.metadata.ScalarType
addMap, expand, getMap, getResult, getResultInc, isScalar, labelToValue, valueToLabel
 
Methods inherited from class de.mguennewig.pobjects.metadata.AbstractType
format, getDescription, getTypeClass, name, parse, setDescription, setTypeClass
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ISRCType

public ISRCType()
Creates a new ISRC type.

Method Detail

formatNative

public java.lang.String formatNative(java.lang.Object value)
Map value from its `native' string representation to its internal representation based on the type.

Any `ISRC' is formated into the form: <country>-<registrant code>-<year>-<designation code>.

Specified by:
formatNative in interface Type
Overrides:
formatNative in class AbstractType
Throws:
java.lang.IllegalArgumentException - if value is not a valid `ISRC'
See Also:
Type.getJavaClass()

checkSyntax

public void checkSyntax(java.lang.String value)
                 throws PObjSyntaxException

Specified by:
checkSyntax in interface Type
Overrides:
checkSyntax in class StringType
Throws:
PObjSyntaxException

getCountry

public static java.lang.String getCountry(java.lang.String isrc)
Returns the ISO 3166-1 alpha-2 country code (2 characters).

Throws:
java.lang.IllegalArgumentException - if the string is not a valid `ISRC'
See Also:
getSections(String)

getRegistrantCode

public static java.lang.String getRegistrantCode(java.lang.String isrc)
Returns the character alphanumeric registrant code.

Throws:
java.lang.IllegalArgumentException - if the string is not a valid `ISRC'
See Also:
getSections(String)

getYear

public static java.lang.String getYear(java.lang.String isrc)
Returns the last two digits of the year of registration.

Throws:
java.lang.IllegalArgumentException - if the string is not a valid `ISRC'
See Also:
getSections(String)

getDesignationCode

public static java.lang.String getDesignationCode(java.lang.String isrc)
Returns the designation code of the `ISRC'.

Throws:
java.lang.IllegalArgumentException - if the string is not a valid `ISRC'
See Also:
getSections(String)

getSections

public static java.lang.String[] getSections(java.lang.String isrc)
Returns the 4 sections of an `ISRC'.
  1. ISO 3166-1 alpha-2 country code (2 characters)
  2. the three character alphanumeric registrant code
  3. the last two digits of the year of registration
  4. designation code, five remaining digits

Throws:
java.lang.IllegalArgumentException - if the string is not a valid `ISRC'