com.starteam.util
Class Encoding

java.lang.Object
  extended by com.starteam.util.Encoding

public final class Encoding
extends java.lang.Object

A platform-independent representation of a character encoding, with methods for enumerating encodings, determining which are supported by the current platform, etc.


Field Summary
static int CODEPAGE_UNKNOWN
          Used to represent a code page that is unknown or undefined.
static int ID_UNKNOWN
          Used to represent an encoding ID that is unknown or undefined.
static Encoding ISO_8859_1
          ISO Latin Alphabet 1 (ISO-LATIN-1).
static java.lang.String STARTEAM_PROPERTY
          Set this system property at startup to override the default StarTeam encoding for the current process.
static Encoding US_ASCII
          Seven-bit ASCII (ISO646-US, the Basic Latin block of the Unicode character set).
static Encoding UTF_16
          Sixteen-bit UCS Transformation Format, byte-order identified by an optional byte-order mark.
static Encoding UTF_16BE
          Sixteen-bit UCS Transformation Format, big-endian byte-order.
static Encoding UTF_16LE
          Sixteen-bit UCS Transformation Format, little-endian byte-order.
static Encoding UTF_32
          32-bit UCS Transformation Format, byte-order identified by an optional byte-order mark.
static Encoding UTF_32BE
          32-bit UCS Transformation Format, big-endian byte-order.
static Encoding UTF_32LE
          32-bit UCS Transformation Format, little-endian byte-order.
static Encoding UTF_8
          Eight-bit UCS Transformation Format.
 
Method Summary
static Encoding forCodePage(int cp)
          Gets the encoding corresponding to the given code page.
static Encoding forID(int id)
          Gets the encoding registered under the given unique ID with the Internet Assigned Numbers Authority (IANA).
static Encoding forName(java.lang.String name)
          Gets the encoding with the given name.
static Encoding[] getAllKnownEncodings()
          Gets a list of all known encodings.
 java.lang.String[] getAllNames()
          Gets all known names for this encoding.
 int getCodePage()
          Gets the codePage of this encoding.
static Encoding getDefaultPlatformEncoding()
          Gets the default platform encoding.
static Encoding getDefaultStarTeamEncoding()
          Gets the default StarTeam encoding.
 java.lang.String getMimeName()
          Gets the preferred MIME name of this encoding.
 java.lang.String getName()
          Gets the common name of this encoding.
 java.lang.String getPlatformName()
          Gets the name by which this encoding is known on this platform.
 java.lang.String getPlatformNameForReading()
          Gets a name that can be used to read this encoding on this platform.
 java.lang.String getPlatformNameForWriting()
          Gets a name that can be used to write this encoding on this platform.
static Encoding[] getReadableEncodings()
          Gets a list of all encodings supported for reading by the current platform.
 int getRegisteredID()
          Gets the unique ID of this encoding, as registered with the Internet Assigned Numbers Authority (IANA).
 java.lang.String getRegisteredName()
          Gets the name of this encoding, as registered with the Internet Assigned Numbers Authority (IANA).
static Encoding[] getSupportedEncodings()
          Gets a list of all encodings supported by the current platform.
static Encoding[] getWritableEncodings()
          Gets a list of all encodings supported for writing by the current platform.
 boolean isNamed(java.lang.String name)
          Determines whether or not the given name refers to this encoding.
 boolean isReadingSupported()
          Determines whether or not this encoding is supported for reading by the current platform.
 boolean isSupported()
          Determines whether or not this encoding is fully supported by the current platform.
 boolean isWritingSupported()
          Determines whether or not this encoding is supported for writing by the current platform.
static void setDefaultStarTeamEncoding(Encoding e)
          Sets the default StarTeam encoding.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STARTEAM_PROPERTY

public static final java.lang.String STARTEAM_PROPERTY
Set this system property at startup to override the default StarTeam encoding for the current process.

See Also:
Constant Field Values

ID_UNKNOWN

public static final int ID_UNKNOWN
Used to represent an encoding ID that is unknown or undefined. Value is -1.

See Also:
Encoding.getRegisteredID(), Constant Field Values

CODEPAGE_UNKNOWN

public static final int CODEPAGE_UNKNOWN
Used to represent a code page that is unknown or undefined. Value is -1.

See Also:
Encoding.getCodePage(), Constant Field Values

US_ASCII

public static final Encoding US_ASCII
Seven-bit ASCII (ISO646-US, the Basic Latin block of the Unicode character set).


ISO_8859_1

public static final Encoding ISO_8859_1
ISO Latin Alphabet 1 (ISO-LATIN-1).


UTF_8

public static final Encoding UTF_8
Eight-bit UCS Transformation Format.


UTF_16BE

public static final Encoding UTF_16BE
Sixteen-bit UCS Transformation Format, big-endian byte-order.


UTF_16LE

public static final Encoding UTF_16LE
Sixteen-bit UCS Transformation Format, little-endian byte-order.


UTF_16

public static final Encoding UTF_16
Sixteen-bit UCS Transformation Format, byte-order identified by an optional byte-order mark.


UTF_32BE

public static final Encoding UTF_32BE
32-bit UCS Transformation Format, big-endian byte-order.


UTF_32LE

public static final Encoding UTF_32LE
32-bit UCS Transformation Format, little-endian byte-order.


UTF_32

public static final Encoding UTF_32
32-bit UCS Transformation Format, byte-order identified by an optional byte-order mark.

Method Detail

getDefaultStarTeamEncoding

public static Encoding getDefaultStarTeamEncoding()
Gets the default StarTeam encoding.

Returns:
The default StarTeam encoding. Never returns null.

setDefaultStarTeamEncoding

public static void setDefaultStarTeamEncoding(Encoding e)
Sets the default StarTeam encoding.

Parameters:
e - The default StarTeam encoding, or null to restore the platform default.

getDefaultPlatformEncoding

public static Encoding getDefaultPlatformEncoding()
Gets the default platform encoding.

Returns:
The default platform encoding. Never returns null.

forName

public static Encoding forName(java.lang.String name)
Gets the encoding with the given name.

Parameters:
name - An encoding name. May be the common name, the registered IANA name, or any known alias. Encoding names are not case sensitive.
Returns:
The corresponding encoding, or null if there is no such encoding.
See Also:
Encoding.getAllNames()

forID

public static Encoding forID(int id)
Gets the encoding registered under the given unique ID with the Internet Assigned Numbers Authority (IANA).

Parameters:
id - The MIBenum of the desired encoding, as registered with IANA.
Returns:
The corresponding encoding, or null if there is no such encoding.
See Also:
Encoding.getRegisteredID()

forCodePage

public static Encoding forCodePage(int cp)
Gets the encoding corresponding to the given code page.

Parameters:
cp - The code page of the desired encoding.
Returns:
The corresponding code page, or null if there is no such encoding.
See Also:
Encoding.getCodePage()

getAllKnownEncodings

public static Encoding[] getAllKnownEncodings()
Gets a list of all known encodings.

Returns:
A list of all known encodings, including ones that are not supported by the current platform. The encodings are sorted by name.
See Also:
Encoding.getName(), Encoding.getSupportedEncodings()

getSupportedEncodings

public static Encoding[] getSupportedEncodings()
Gets a list of all encodings supported by the current platform.

Returns:
A list of all known encodings that are fully supported (for both reading and writing) by the current platform. The encodings are sorted by the name they are known by on this platform.
See Also:
Encoding.getPlatformName(), Encoding.getAllKnownEncodings(), Encoding.getReadableEncodings(), Encoding.getWritableEncodings()

getReadableEncodings

public static Encoding[] getReadableEncodings()
Gets a list of all encodings supported for reading by the current platform. It is possible (bit rare) that an encoding is supported for reading but not for writing. Thus, the list of readable encodings may be different from the list of fully supported encodings.

Returns:
A list of all known encodings that are supported for reading (and possibly also writing) by the current platform. The encodings are sorted by the name used for reading on this platform.
See Also:
Encoding.getPlatformNameForReading(), Encoding.getSupportedEncodings(), Encoding.getWritableEncodings()

getWritableEncodings

public static Encoding[] getWritableEncodings()
Gets a list of all encodings supported for writing by the current platform. It is possible (bit rare) that an encoding is supported for writing but not for reading. Thus, the list of writable encodings may be different from the list of fully supported encodings.

Returns:
A list of all known encodings that are supported for writing (and possibly also reading) by the current platform. The encodings are sorted by the name used for writing on this platform.
See Also:
Encoding.getPlatformNameForWriting(), Encoding.getSupportedEncodings(), Encoding.getReadableEncodings()

getName

public java.lang.String getName()
Gets the common name of this encoding.

Returns:
The common name of this encoding. If this encoding has a preferred MIME name, then that is always used as the common name. Otherwise, if the encoding is registered with IANA, then that is used as the common name. Otherwise, the common name is the preferred Java alias for this encoding.
See Also:
Encoding.forName(java.lang.String), Encoding.getMimeName(), Encoding.getRegisteredName(), Encoding.getAllNames()

getMimeName

public java.lang.String getMimeName()
Gets the preferred MIME name of this encoding. See http://www.iana.org/assignments/character-sets.

Returns:
The preferred MIME name of this encoding, or null if this encoding does not have a preferred MIME name.
See Also:
Encoding.getName()

getRegisteredName

public java.lang.String getRegisteredName()
Gets the name of this encoding, as registered with the Internet Assigned Numbers Authority (IANA). See http://www.iana.org/assignments/character-sets.

Returns:
The registered name of this encoding, or null if this encoding is not registered with IANA.
See Also:
Encoding.getName()

getAllNames

public java.lang.String[] getAllNames()
Gets all known names for this encoding.

Returns:
The list of known names for this encoding. The first name is always the common name. If this encoding has both a preferred MIME name and a regsitered IANA name, and they are different, then the second entry is the regsitered IANA name. Other names appear in an arbitrary order.
See Also:
Encoding.getName()

isNamed

public boolean isNamed(java.lang.String name)
Determines whether or not the given name refers to this encoding.

Parameters:
name - The name to be tested. Encoding names are not case sensitive.
Returns:
true if the given name refers to this encoding; false otherwise.
See Also:
Encoding.getAllNames()

getRegisteredID

public int getRegisteredID()
Gets the unique ID of this encoding, as registered with the Internet Assigned Numbers Authority (IANA). See http://www.iana.org/assignments/character-sets.

Returns:
The registered name of this encoding, or ID_UNKNOWN (-1) if this encoding is not registered with IANA, or was not assigned a unique ID.
See Also:
Encoding.forID(int), Encoding.getRegisteredName()

getCodePage

public int getCodePage()
Gets the codePage of this encoding.

Returns:
The code page of this encoding, or CODEPAGE_UNKNOWN (-1) if this encoding does not have a corresponding code page, or if the code page cannot be represented by a number (e.g., "Cp949C").
See Also:
Encoding.forCodePage(int)

isSupported

public boolean isSupported()
Determines whether or not this encoding is fully supported by the current platform.

Returns:
true if this encoding is fully supported (for both reading and writing) by this platform; false otherwise.
See Also:
Encoding.getSupportedEncodings(), Encoding.getPlatformName(), Encoding.isReadingSupported(), Encoding.isWritingSupported()

getPlatformName

public java.lang.String getPlatformName()
Gets the name by which this encoding is known on this platform.

Returns:
The name by which this encoding is known on this platform. If the encoding is known by multiple names, then the preferred name is returned. Returns null if this encoding is not fully supported (for both reading and writing) by this platform.
See Also:
Encoding.isSupported(), Encoding.getPlatformNameForReading(), Encoding.getPlatformNameForWriting()

isReadingSupported

public boolean isReadingSupported()
Determines whether or not this encoding is supported for reading by the current platform.

Returns:
true if this encoding is supported for reading by this platform; false otherwise.
See Also:
Encoding.getPlatformNameForReading(), Encoding.isSupported(), Encoding.isWritingSupported()

getPlatformNameForReading

public java.lang.String getPlatformNameForReading()
Gets a name that can be used to read this encoding on this platform.

Returns:
A name that can be used to read this encoding on this platform. If multiple names can be used to read this encoding, then the preferred name for reading is returned. Returns null if reading is not supported for this encoding by this platform.
See Also:
Encoding.isReadingSupported(), Encoding.getPlatformNameForWriting()

isWritingSupported

public boolean isWritingSupported()
Determines whether or not this encoding is supported for writing by the current platform.

Returns:
true if this encoding is supported for writing by this platform; false otherwise.
See Also:
Encoding.getPlatformNameForWriting(), Encoding.isSupported(), Encoding.isReadingSupported()

getPlatformNameForWriting

public java.lang.String getPlatformNameForWriting()
Gets a name that can be used to write this encoding on this platform.

Returns:
A name that can be used to write this encoding on this platform. If multiple names can be used to write this encoding, then the preferred name for writing is returned. Returns null if writing is not supported for this encoding by this platform.
See Also:
Encoding.isWritingSupported(), Encoding.getPlatformNameForReading()


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.