- 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 StringCHARSET_NAMEDefault character set name.static StringREPLACEMENTDefault 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 CharsetgetCharset()Gets the character set.StringgetCharsetName()Gets the character set name.CodingErrorActiongetErrorAction()Gets the specified action for an encoding error.StringgetReplacement()Gets the replacement value used when an error occurs.CharsetDecodernewDecoder()Gets a new decoder configured for the described encoding.CharsetEncodernewEncoder()Gets a new encoder configured for the described encoding.voidset(CharsetEncoding source)Copy the settings from the given character set specificationvoidsetCharset(Charset charset)Sets the character set.voidsetCharsetName(String charsetName)Sets the character set name.voidsetErrorAction(CodingErrorAction errorAction)Sets the action for an encoding error.voidsetReplacement(String replacement)Sets the error policy to be replacement with the specified string.StringtoString()
-
-
-
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 isnullor 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
-
-