jp.co.jprs.idnkit
Interface IDNA

All Known Implementing Classes:
IDNA2008

public interface IDNA

The jp.co.jprs.idnkit.IDNA interface defines manipulations of internationalized domain names using idnkit.

This interface defines almost the same methods as idnkit library provides. Its main functions are encoding (conversion to ASCII) and decoding (conversion to UTF-8) domain names.

Currently, the package provides IDNA2008 class as an implementation of the jp.co.jprs.idnkit.IDNA interface. To create an IDNA2008 instance, IDNAFactory class is used instead of a constructor of IDNA2008 class.

Version:
2.1
Author:
Japan Registry Services Co., Ltd.(JPRS)
See Also:
IDNAFactory, IDNA2008

Field Summary
static int CHECK_LOOKUP
          Action value to validate a domain name with the domain name lookup protocol.
static int CHECK_REGIST
          Action value to validate a domain name with the domain name registration protocol.
static int COMPARE_LOOKUP
          Action value to compare two domain names with the domain name lookup protocol.
static int COMPARE_REGIST
          Action value to compare two domain names with the domain name registration protocol.
static int DECODE_LOOKUP
          Action value to decode a domain name with the domain name lookup protocol.
static int DECODE_REGIST
          Action value to decode a domain name with the domain name registration protocol.
static int ENCODE_LOOKUP
          Action value to encode a domain name with the domain name lookup protocol.
static int ENCODE_REGIST
          Action value to encode a domain name with the domain name registration protocol.
 
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'.
 

Field Detail

ENCODE_REGIST

static final int ENCODE_REGIST
Action value to encode a domain name with the domain name registration protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

ENCODE_LOOKUP

static final int ENCODE_LOOKUP
Action value to encode a domain name with the domain name lookup protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

DECODE_REGIST

static final int DECODE_REGIST
Action value to decode a domain name with the domain name registration protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

DECODE_LOOKUP

static final int DECODE_LOOKUP
Action value to decode a domain name with the domain name lookup protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

COMPARE_REGIST

static final int COMPARE_REGIST
Action value to compare two domain names with the domain name registration protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

COMPARE_LOOKUP

static final int COMPARE_LOOKUP
Action value to compare two domain names with the domain name lookup protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

CHECK_REGIST

static final int CHECK_REGIST
Action value to validate a domain name with the domain name registration protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values

CHECK_LOOKUP

static final int CHECK_LOOKUP
Action value to validate a domain name with the domain name lookup protocol. Also local-check is performed if the conversion context has code point set.

See Also:
Constant Field Values
Method Detail

init

void init()
          throws IDNException
Initializes the conversion context instance. Upon return, the instance will have the default settings.

Throws:
IDNException - Initialization failed.

init

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

Parameters:
filename - Configuration file to be read.
Throws:
IDNException - Initialization failed.

init

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

Parameters:
conf - Configurations to be set.
Throws:
IDNException - Initialization failed.

setLocalCheckFile

void setLocalCheckFile(java.lang.String filename)
                       throws IDNException
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.

Parameters:
filename - Code point set file to be read.
Throws:
IDNException - Failed to read the file.

encode

java.lang.String encode(java.lang.String name)
                        throws IDNException
Converts a domain name 'name' to ASCII, and returns the result. The method performs ENCODE_REGIST action to convert 'name'.

Parameters:
name - A domain name to be encoded.
Returns:
An encoded domain name.
Throws:
IDNException - Conversion failed.

encode

java.lang.String encode(int actions,
                        java.lang.String name)
                        throws IDNException
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.

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

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

Parameters:
name - A domain name to be decoded.
Returns:
A decoded domain name.
Throws:
IDNException - Conversion failed.

decode

java.lang.String decode(int actions,
                        java.lang.String name)
                        throws IDNException
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.

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

boolean compare(java.lang.String name1,
                java.lang.String name2)
                throws IDNException
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'.

Parameters:
name1 - A domain name #1.
name2 - A domain name #2.
Throws:
IDNException - Conversion of domain names failed.

compare

boolean compare(int actions,
                java.lang.String name1,
                java.lang.String name2)
                throws IDNException
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'.

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

boolean compare(int actions1,
                java.lang.String name1,
                int actions2,
                java.lang.String name2)
                throws IDNException
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.

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

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

Parameters:
name - A domain name to be validated.
Returns:
True if the domain name is valid.
Throws:
IDNException - Conversion of domain names failed.

check

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

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

getUnicodeVersion

java.lang.String getUnicodeVersion()
Gets a version of Unicode tables the context instance supports.

Returns:
Version (e.g. "5.2.0" in case of Unicode 5.2.0).

getIdnaTableVersion

java.lang.String getIdnaTableVersion()
Gets a version of IDNA tables the context instance supports.

Returns:
Version (e.g. "rfc5892 (2010-08-04)").

getLibIDNVersion

java.lang.String getLibIDNVersion()
Gets a version of idnkit library.

Returns:
Version (e.g. "2.0" for idnkit version 2.0).

getVersion

java.lang.String getVersion()
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.

Returns:
Version string.