- java.lang.Object
-
- com.pervasive.datarush.io.CharsetEncoding
-
- All Implemented Interfaces:
Serializable
public class CharsetEncoding extends Object implements Serializable
Describes the encoding format of character data. This encompasses not only the character set used, but also the error handling for unencodable characters. The default settings are:- The ISO-8859-1 character set is used.
- Encoding errors are resolved by replacement with the '?' character.
- See Also:
Charset
,CodingErrorAction
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHARSET_NAME
Default character set name.static String
REPLACEMENT
Default replacement character.
-
Constructor Summary
Constructors Constructor Description CharsetEncoding()
Creates a container with default settings.CharsetEncoding(CharsetEncoding source)
Creates a container initialized using the given character set specification.CharsetEncoding(String charsetName)
Creates a container initialized the named character set and the default error policy.CharsetEncoding(String charsetName, String replacement)
Creates a container initialized with the named character set, using a replacement error policy with the specified string.CharsetEncoding(String charsetName, CodingErrorAction errorAction)
Creates a container initialized with the named character set, using the specified error policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Charset
getCharset()
Gets the character set.String
getCharsetName()
Gets the character set name.CodingErrorAction
getErrorAction()
Gets the specified action for an encoding error.String
getReplacement()
Gets the replacement value used when an error occurs.CharsetDecoder
newDecoder()
Gets a new decoder configured for the described encoding.CharsetEncoder
newEncoder()
Gets a new encoder configured for the described encoding.void
set(CharsetEncoding source)
Copy the settings from the given character set specificationvoid
setCharset(Charset charset)
Sets the character set.void
setCharsetName(String charsetName)
Sets the character set name.void
setErrorAction(CodingErrorAction errorAction)
Sets the action for an encoding error.void
setReplacement(String replacement)
Sets the error policy to be replacement with the specified string.String
toString()
-
-
-
Field Detail
-
CHARSET_NAME
public static final String CHARSET_NAME
Default character set name.- See Also:
- Constant Field Values
-
REPLACEMENT
public static final String REPLACEMENT
Default replacement character.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CharsetEncoding
public CharsetEncoding()
Creates a container with default settings.
-
CharsetEncoding
public CharsetEncoding(String charsetName)
Creates a container initialized the named character set and the default error policy.- Parameters:
charsetName
- name of the charset. This must be a name which is recognized byCharset.forName(String)
.
-
CharsetEncoding
public CharsetEncoding(String charsetName, CodingErrorAction errorAction)
Creates a container initialized with the named character set, using the specified error policy. If a policy of replacement is selected, the default replacement string will be used.- Parameters:
charsetName
- name of the charset. This must be a name which is recognized byCharset.forName(String)
.errorAction
- specifies how encoding errors are to be handled
-
CharsetEncoding
public CharsetEncoding(String charsetName, String replacement)
Creates a container initialized with the named character set, using a replacement error policy with the specified string.- Parameters:
charsetName
- name of the charset. This must be a name which is recognized byCharset.forName(String)
.replacement
- replacement string to be used when handling encoding errors
-
CharsetEncoding
public CharsetEncoding(CharsetEncoding source)
Creates a container initialized using the given character set specification.- Parameters:
source
- character set data from which to initialize the settings
-
-
Method Detail
-
set
public void set(CharsetEncoding source)
Copy the settings from the given character set specification- Parameters:
source
- specifier containing the desired settings
-
getCharset
public Charset getCharset()
Gets the character set.- Returns:
- the character set to use
-
setCharset
public void setCharset(Charset charset)
Sets the character set.- Parameters:
charset
- the character set to use
-
getCharsetName
public String getCharsetName()
Gets the character set name.- Returns:
- the character set to use
-
setCharsetName
public void setCharsetName(String charsetName)
Sets the character set name.- Parameters:
charsetName
- name of the charset- Throws:
UnsupportedCharsetException
- if the named charset is not supported.
-
getErrorAction
public CodingErrorAction getErrorAction()
Gets the specified action for an encoding error.- Returns:
- error action
-
setErrorAction
public void setErrorAction(CodingErrorAction errorAction)
Sets the action for an encoding error.- Parameters:
errorAction
- error action
-
getReplacement
public String getReplacement()
Gets the replacement value used when an error occurs. This value is only used if the error action is set to replacement.- Returns:
- replacement value used for encoding errors
-
setReplacement
public void setReplacement(String replacement)
Sets the error policy to be replacement with the specified string.- Parameters:
replacement
- replacement value to use for encoding errors- Throws:
IllegalArgumentException
- if the replacement isnull
or empty
-
newEncoder
public CharsetEncoder newEncoder()
Gets a new encoder configured for the described encoding.- Returns:
- a encoder matching the encoding configuration
-
newDecoder
public CharsetDecoder newDecoder()
Gets a new decoder configured for the described encoding.- Returns:
- a decoder matching the encoding configuration
-
-