jp.co.jprs.idnkit
Class IDNA2008

java.lang.Object
  extended by jp.co.jprs.idnkit.IDNA2008
All Implemented Interfaces:
IDNA

public final class IDNA2008
extends java.lang.Object
implements IDNA

An instance of IDNA2008 class represents IDNA2008 version of IDNA conversion context. IDNA2008 instances are created using IDNAFactory class, like 'IDNAFactory.create(IDNAFactory.IDNA2008)'.

Version:
2.1
Author:
Japan Registry Services Co., Ltd.(JPRS)

Field Summary
static int ASCLOWER
          Atomic ASCLOWER action.
static int BIDICHECK
          Atomic BIDICHECK action.
static int COMBCHECK
          Atomic COMBCHECK action.
static int CTXJCHECK
          Atomic CTXJCHECK action.
static int CTXOCHECK
          Atomic CTXOCHECK action.
static int CTXOLITECHECK
          Atomic CTXOLITECHECK action.
static int HYPHCHECK
          Atomic HYPHCHECK action.
static int IDNCONV
          Atomic IDNCONV action.
static int LENCHECK
          Atomic LENCHECK action.
static int LOCALCHECK
          Atomic LOCALCHECK action.
static int MAP
          Atomic MAP action.
static int NFCCHECK
          Atomic NFCCHECK action.
static int PREFCHECK
          Atomic PREFCHECK action.
static int PROHCHECK
          Atomic PROHCHECK action.
static int RTCHECK
          Atomic RTCHECK action.
static int RTCONV
          Atomic RTCONV action.
static int UNASCHECK
          Atomic UNASCHECK action.
static int UNDOIFERR
          UNDOIFERR special action.
 
Fields inherited from interface jp.co.jprs.idnkit.IDNA
CHECK_LOOKUP, CHECK_REGIST, COMPARE_LOOKUP, COMPARE_REGIST, DECODE_LOOKUP, DECODE_REGIST, ENCODE_LOOKUP, ENCODE_REGIST
 
Method Summary
 boolean check(int actions, java.lang.String name)
          Validates a domain name.
 boolean check(java.lang.String name)
          Validates a domain name.
 boolean compare(int actions1, java.lang.String name1, int actions2, java.lang.String name2)
          Compares two domain names.
 boolean compare(int actions, java.lang.String name1, java.lang.String name2)
          Compares two domain names.
 boolean compare(java.lang.String name1, java.lang.String name2)
          Compares two domain names.
 java.lang.String decode(int actions, java.lang.String name)
          Converts a domain name 'name' to UTF-8 and returns the result.
 java.lang.String decode(java.lang.String name)
          Converts a domain name 'name' to UTF-8 and returns the result.
 java.lang.String encode(int actions, java.lang.String name)
          Converts a domain name 'name' to ASCII and returns the result.
 java.lang.String encode(java.lang.String name)
          Converts a domain name 'name' to ASCII, and returns the result.
 java.lang.String getIdnaTableVersion()
          Gets a version of IDNA tables the context instance supports.
 java.lang.String getLibIDNVersion()
          Gets a version of idnkit library.
 java.lang.String getUnicodeVersion()
          Gets a version of Unicode tables the context instance supports.
 java.lang.String getVersion()
          Returns version information.
 void init()
          Initializes the conversion context instance.
 void init(java.lang.String filename)
          Initializes the conversion context instance.
 void init(java.lang.String[] conf)
          Initializes the conversion context instance.
 void setLocalCheckFile(java.lang.String filename)
          Reads a code point set for local-check from a file 'filename'.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP

public static final int MAP
Atomic MAP action. It performs mappings (NFC, Lowercase conversion, etc.).

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

ASCLOWER

public static final int ASCLOWER
Atomic ASCLOWER action. It converts ASCII uppercase letters (A..Z) to lowercase (a..z).

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

RTCONV

public static final int RTCONV
Atomic RTCONV action. It converts a domain name from Punycode to UTF-8.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

PROHCHECK

public static final int PROHCHECK
Atomic PROHCHECK action. It checks prohibited code points.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

UNASCHECK

public static final int UNASCHECK
Atomic UNASCHECK action. It checks unassigned code points.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

NFCCHECK

public static final int NFCCHECK
Atomic NFCCHECK action. It checks labels are in NFC.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

PREFCHECK

public static final int PREFCHECK
Atomic PREFCHECK action. It checks labels containing "--" in the 3rd and 4th characters.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

HYPHCHECK

public static final int HYPHCHECK
Atomic HYPHCHECK action. It checks labels beginning/ending with "-".

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

COMBCHECK

public static final int COMBCHECK
Atomic COMBCHECK action. It checks labels beginning with a combining mark.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

CTXJCHECK

public static final int CTXJCHECK
Atomic CTXJCHECK action. It checks CONTEXTJ code points.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

CTXOCHECK

public static final int CTXOCHECK
Atomic CTXOCHECK action. It checks CONTEXTO code points for the registration protocol.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

CTXOLITECHECK

public static final int CTXOLITECHECK
Atomic CTXOLITECHECK action. It checks CONTEXTO code points for the lookup protocol.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

BIDICHECK

public static final int BIDICHECK
Atomic BIDICHECK action. It checks requirements specified in [IDNA2008-BIDI].

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

LOCALCHECK

public static final int LOCALCHECK
Atomic LOCALCHECK action. Perform local check.

See Also:
encode(int actions, String name), decode(int actions, String name), Constant Field Values

IDNCONV

public static final int IDNCONV
Atomic IDNCONV action. Convert labels in UTF-8 to Punycode.

See Also:
#decode(int actions, String name), Constant Field Values

LENCHECK

public static final int LENCHECK
Atomic LENCHECK action. It checks length of each label.

See Also:
#decode(int actions, String name), Constant Field Values

RTCHECK

public static final int RTCHECK
Atomic RTCHECK action. Perform round trip check for each label.

See Also:
#decode(int actions, String name), Constant Field Values

UNDOIFERR

public static final int UNDOIFERR
UNDOIFERR special action. If any step fails, the original input name is returned.

See Also:
#decode(int actions, String name), Constant Field Values
Method Detail

init

public void init()
          throws IDNException
Description copied from interface: IDNA
Initializes the conversion context instance. Upon return, the instance will have the default settings.

Specified by:
init in interface IDNA
Throws:
IDNException - Initialization failed.

init

public void init(java.lang.String filename)
          throws IDNException
Description copied from interface: IDNA
Initializes the conversion context instance. The context will be initialized according with the configuration file specified by the argument 'filename'.

Specified by:
init in interface IDNA
Parameters:
filename - Configuration file to be read.
Throws:
IDNException - Initialization failed.

init

public void init(java.lang.String[] conf)
          throws IDNException
Description copied from interface: IDNA
Initializes the conversion context instance. The context will be initialized according with the configuration strings specified by the argument 'conf'.

Specified by:
init in interface IDNA
Parameters:
conf - Configurations to be set.
Throws:
IDNException - Initialization failed.

setLocalCheckFile

public void setLocalCheckFile(java.lang.String filename)
                       throws IDNException
Description copied from interface: IDNA
Reads a code point set for local-check from a file 'filename'. If 'filename' is null, the local code point set the conversion context memories is cleared.

Specified by:
setLocalCheckFile in interface IDNA
Parameters:
filename - Code point set file to be read.
Throws:
IDNException - Failed to read the file.

encode

public java.lang.String encode(java.lang.String name)
                        throws IDNException
Description copied from interface: IDNA
Converts a domain name 'name' to ASCII, and returns the result. The method performs ENCODE_REGIST action to convert 'name'.

Specified by:
encode in interface IDNA
Parameters:
name - A domain name to be encoded.
Returns:
An encoded domain name.
Throws:
IDNException - Conversion failed.

encode

public java.lang.String encode(int actions,
                               java.lang.String name)
                        throws IDNException
Description copied from interface: IDNA
Converts a domain name 'name' to ASCII and returns the result. The argument 'actions' specifies which steps in the entire encoding process should be performed.

Specified by:
encode in interface IDNA
Parameters:
actions - An action value to encode 'name'.
name - A domain name to be encoded.
Returns:
An encoded domain name.
Throws:
IDNException - Conversion failed.

decode

public java.lang.String decode(java.lang.String name)
                        throws IDNException
Description copied from interface: IDNA
Converts a domain name 'name' to UTF-8 and returns the result. The method performs DECODE_REGIST action to convert 'name'.

Specified by:
decode in interface IDNA
Parameters:
name - A domain name to be decoded.
Returns:
A decoded domain name.
Throws:
IDNException - Conversion failed.

decode

public java.lang.String decode(int actions,
                               java.lang.String name)
                        throws IDNException
Description copied from interface: IDNA
Converts a domain name 'name' to UTF-8 and returns the result. The argument 'actions' specifies which steps in the entire decoding process should be performed.

Specified by:
decode in interface IDNA
Parameters:
actions - An action value to decode 'name'.
name - A domain name to be decoded.
Returns:
A decoded domain name.
Throws:
IDNException - Conversion failed.

compare

public boolean compare(java.lang.String name1,
                       java.lang.String name2)
                throws IDNException
Description copied from interface: IDNA
Compares two domain names. It encodes domain names 'name1' and 'name2' as the 'encode' method does, and then compares them. If they are equivalent, it returns true. Otherwise, it returns false. The method performs COMPARE_LOOKUP action to encode 'name1' and 'name2'.

Specified by:
compare in interface IDNA
Parameters:
name1 - A domain name #1.
name2 - A domain name #2.
Throws:
IDNException - Conversion of domain names failed.

compare

public boolean compare(int actions,
                       java.lang.String name1,
                       java.lang.String name2)
                throws IDNException
Description copied from interface: IDNA
Compares two domain names. It encodes domain names 'name1' and 'name2' as the 'encode' method does, and then compares them. If they are equivalent, it returns true. Otherwise, it returns false. The method performs 'actions' to encode 'name1' and 'name2'.

Specified by:
compare in interface IDNA
Parameters:
actions - An Action value to encode 'name1' and 'name2'.
name1 - A domain name #1.
name2 - A domain name #2.
Returns:
True if two domain names are equivalent.
Throws:
IDNException - Conversion of domain names failed.

compare

public boolean compare(int actions1,
                       java.lang.String name1,
                       int actions2,
                       java.lang.String name2)
                throws IDNException
Description copied from interface: IDNA
Compares two domain names. It encodes domain names 'name1' and 'name2' as the 'encode' method does, and then compares them. If they are equivalent, it returns true. Otherwise, it returns false. The method performs 'actions1' to encode 'name1', and 'actions2' to encode 'name2' respectively.

Specified by:
compare in interface IDNA
Parameters:
actions1 - An Action value to encode 'name1'.
name1 - A domain name #1.
actions2 - An Action value to encode 'name2'.
name2 - A domain name #2.
Returns:
True if two domain names are equivalent.
Throws:
IDNException - Conversion of domain names failed.

check

public boolean check(java.lang.String name)
              throws IDNException
Description copied from interface: IDNA
Validates a domain name. It tries to encode 'name' with CHECK_REGIST action. If succeeded, it returns true. Otherwise, it returns false.

Specified by:
check in interface IDNA
Parameters:
name - A domain name to be validated.
Returns:
True if the domain name is valid.
Throws:
IDNException - Conversion of domain names failed.

check

public boolean check(int actions,
                     java.lang.String name)
              throws IDNException
Description copied from interface: IDNA
Validates a domain name. It tries to encode 'name' with an action value 'actions'. If succeeded, it returns true. Otherwise, it returns false.

Specified by:
check in interface IDNA
Parameters:
actions - An Action value to encode 'name'.
name - A domain name to be validated.
Returns:
True if the domain name is valid.
Throws:
IDNException - Conversion of domain names failed.

getUnicodeVersion

public java.lang.String getUnicodeVersion()
Description copied from interface: IDNA
Gets a version of Unicode tables the context instance supports.

Specified by:
getUnicodeVersion in interface IDNA
Returns:
Version (e.g. "5.2.0" in case of Unicode 5.2.0).

getIdnaTableVersion

public java.lang.String getIdnaTableVersion()
Description copied from interface: IDNA
Gets a version of IDNA tables the context instance supports.

Specified by:
getIdnaTableVersion in interface IDNA
Returns:
Version (e.g. "rfc5892 (2010-08-04)").

getLibIDNVersion

public java.lang.String getLibIDNVersion()
Description copied from interface: IDNA
Gets a version of idnkit library.

Specified by:
getLibIDNVersion in interface IDNA
Returns:
Version (e.g. "2.0" for idnkit version 2.0).

getVersion

public java.lang.String getVersion()
Description copied from interface: IDNA
Returns version information. It returns a string which consists of a version of Unicode tables, a version of IDNA tables and a version of idnkit library.

Specified by:
getVersion in interface IDNA
Returns:
Version string.