org.nbnResolving.common
Class Rfc3188Validator

java.lang.Object
  extended by org.nbnResolving.common.Rfc3188Validator
Direct Known Subclasses:
DnbUrnValidator

public class Rfc3188Validator
extends Object

Class for validation of an URN according to RFC. "https://tools.ietf.org/html/rfc3188"

Author:
Kadir Karaca Kocer

Field Summary
static int BAD_COUNTRY_CODE
          Two digit country code is not in ISO 3106 list
static int EMPTY_NBN_STRING
          Assigned NBN string can not be empty
static int EMPTY_SUBNAMESPACE
          Sub-Namespace Code can not be empty
static int INVALID_CHAR_NBN
          Not allowed Character in NBN String
static int INVALID_CHAR_NID
          Not allowed Character in Namespace
static String[] iso3106Codes
          All two digit country codes according to ISO 3166 "http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm"
static int MUST_START_WITH_URN
          NID must start with URN:.
static int NID_TOO_SHORT
          NID too short.
static int NOT_A_NBN
          Only NBNs are allowed
static int NOT_TWO_DIGIT_CODE
          Only two digit country codes defined in ISO 3106 are allowed
static int PART_COUNT_TOO_LOW
          NID must have at least 4 parts.
static int URN_EQUALS_NULL
          URN is NULL
static int URN_IS_EMPTY
          URN is empty
static int URN_IS_VALID
          URN is VALID
static char[] VALID_CHARS
          All in URN:NBN allowed characters
 
Constructor Summary
Rfc3188Validator()
           
 
Method Summary
static boolean charsValid(String str)
          Check if only allowed chars are used.
static int validateUrn(String urn)
          Method to check if the given URN satisfies the syntax defined in RFC 2141.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iso3106Codes

public static String[] iso3106Codes
All two digit country codes according to ISO 3166 "http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm"


VALID_CHARS

public static final char[] VALID_CHARS
All in URN:NBN allowed characters


URN_IS_VALID

public static final int URN_IS_VALID
URN is VALID

See Also:
Constant Field Values

URN_EQUALS_NULL

public static final int URN_EQUALS_NULL
URN is NULL

See Also:
Constant Field Values

URN_IS_EMPTY

public static final int URN_IS_EMPTY
URN is empty

See Also:
Constant Field Values

NID_TOO_SHORT

public static final int NID_TOO_SHORT
NID too short. See RFC 3288

See Also:
Constant Field Values

PART_COUNT_TOO_LOW

public static final int PART_COUNT_TOO_LOW
NID must have at least 4 parts. See RFC 3188

See Also:
Constant Field Values

MUST_START_WITH_URN

public static final int MUST_START_WITH_URN
NID must start with URN:. See RFC 3188

See Also:
Constant Field Values

NOT_A_NBN

public static final int NOT_A_NBN
Only NBNs are allowed

See Also:
Constant Field Values

NOT_TWO_DIGIT_CODE

public static final int NOT_TWO_DIGIT_CODE
Only two digit country codes defined in ISO 3106 are allowed

See Also:
Constant Field Values

BAD_COUNTRY_CODE

public static final int BAD_COUNTRY_CODE
Two digit country code is not in ISO 3106 list

See Also:
Constant Field Values

EMPTY_SUBNAMESPACE

public static final int EMPTY_SUBNAMESPACE
Sub-Namespace Code can not be empty

See Also:
Constant Field Values

EMPTY_NBN_STRING

public static final int EMPTY_NBN_STRING
Assigned NBN string can not be empty

See Also:
Constant Field Values

INVALID_CHAR_NID

public static final int INVALID_CHAR_NID
Not allowed Character in Namespace

See Also:
Constant Field Values

INVALID_CHAR_NBN

public static final int INVALID_CHAR_NBN
Not allowed Character in NBN String

See Also:
Constant Field Values
Constructor Detail

Rfc3188Validator

public Rfc3188Validator()
Method Detail

validateUrn

public static int validateUrn(String urn)
Method to check if the given URN satisfies the syntax defined in RFC 2141. Please note that this method checks only NBN namespace defined in RFC 3188: "https://tools.ietf.org/html/rfc3188" All other registered URN namespaces are out of scope of this java class and must be implemented separetely.

Parameters:
urn - A National Bibliography Number as Uniform Resource Name according to RFC 3188.
Returns:
0 for a valid URN. An integer in case of a violation against RFC 3188. See the predefined constants.

charsValid

public static boolean charsValid(String str)
Check if only allowed chars are used.

Parameters:
str - String to test.
Returns:
TRUE if all the characters are in the given string in VALID_CHARS list. FALSE otherwise.


Copyright © 2013 Deutsche Nationalbibliothek / German National Library. All Rights Reserved.