Package com.isode.x400.highlevel
Class BodypartGeneralText
- java.lang.Object
-
- com.isode.x400.highlevel.Bodypart
-
- com.isode.x400.highlevel.BodypartGeneralText
-
public class BodypartGeneralText extends Bodypart
This class represents a General Text bodypart.When creating an instance of this class, you must provide the charset and the content. You must ensure that the content is correct for the charset.
The charset must be one the ones provided by the class Charset E.g. WEST_EUROPEAN (that maps to "1 6 100")
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BodypartGeneralText.Charset
Available charsets to use for General Text bodyparts-
Nested classes/interfaces inherited from class com.isode.x400.highlevel.Bodypart
Bodypart.Bodypart_Type
-
-
Field Summary
-
Fields inherited from class com.isode.x400.highlevel.Bodypart
bodypart_size, bodypart_type
-
-
Constructor Summary
Constructors Constructor Description BodypartGeneralText(boolean iso_8859_1, java.lang.String ct)
Creates a General Text bodypart, with a content suitable for ISO-8895-1 (if iso_8859_1 is true) or ISO-8895-2 (if iso_8859_1 is false).BodypartGeneralText(BodypartGeneralText.Charset cs, java.lang.String ct)
Constructor based on data provided by the user, including the charset and content.BodypartGeneralText(BodyPart bp_obj)
Constructor based on an existing bodypart object, for example, one read from an existing message.BodypartGeneralText(java.lang.String charset, java.lang.String ct)
Constructor based on data provided by the user, including the charset and content.BodypartGeneralText(java.lang.String charset, java.lang.String rawContent, boolean emptyCharset)
Constructor based on data provided by the user, including the charset as a String and the raw content as a String.BodypartGeneralText(java.lang.String fileName, java.nio.charset.Charset sourceCharacterSet, java.lang.String isoCharsets)
Creates a General Text bodypart which will be encoded using the specified ISO character sets, reading the data for the bodypart from the specified file using the selected encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BodypartGeneralText.Charset
getCharset()
Deprecated.callers should usegetCharsetString()
, which returns all possible charset values in a String.java.lang.String
getCharsetString()
Returns the charset string of this General Text bodypartint
getSize()
Returns the size, in bytes, of the message bodypart.java.lang.String
getStringRepresentation()
Returns the string representation of this message bodypart.java.lang.String
getTextContent()
Returns the content of this General Text bodypartvoid
saveBodypartRaw(java.lang.String filename)
Save the bodypart in the given filenamevoid
saveBP(java.lang.String filename)
Save the bodypart in the given filenamevoid
setCharset(BodypartGeneralText.Charset cs)
Sets the charset of this General Text bodypartvoid
setContentFromFile(java.lang.String file)
Deprecated.Assumes that input file is UTF-8 encoded, when this may not be truevoid
setSize(int s)
Sets the size of message bodypart in bytes.void
setTextContent(java.lang.String ct)
Sets the content of this General Text bodypart-
Methods inherited from class com.isode.x400.highlevel.Bodypart
getBodypartObject, getByteParam, getIntParam, getStringParam, getType, getTypeAsString, setByteParam, setIntParam, setStringParam
-
-
-
-
Constructor Detail
-
BodypartGeneralText
public BodypartGeneralText(BodyPart bp_obj) throws X400APIException
Constructor based on an existing bodypart object, for example, one read from an existing message.- Parameters:
bp_obj
-- Throws:
X400APIException
-
BodypartGeneralText
public BodypartGeneralText(BodypartGeneralText.Charset cs, java.lang.String ct) throws X400APIException
Constructor based on data provided by the user, including the charset and content. For ISO-8895-1 and ISO-8895-2 you can use the constructor BodypartGeneralText(boolean iso1, String ct) specifying true for ISO-8895-1 and false for ISO-8895-2- Parameters:
cs
-ct
-- Throws:
X400APIException
-
BodypartGeneralText
public BodypartGeneralText(java.lang.String charset, java.lang.String ct) throws X400APIException
Constructor based on data provided by the user, including the charset and content. For ISO-8895-1 and ISO-8895-2 you can use the constructor BodypartGeneralText(boolean iso1, String ct) specifying true for ISO-8895-1 and false for ISO-8895-2- Parameters:
charset
-ct
-- Throws:
X400APIException
-
BodypartGeneralText
public BodypartGeneralText(java.lang.String charset, java.lang.String rawContent, boolean emptyCharset) throws X400APIException
Constructor based on data provided by the user, including the charset as a String and the raw content as a String. The emptyCharset boolean method indicates if the charset should be set or not- Parameters:
charset
-rawContent
-emptyCharset
-- Throws:
X400APIException
-
BodypartGeneralText
public BodypartGeneralText(boolean iso_8859_1, java.lang.String ct) throws X400APIException
Creates a General Text bodypart, with a content suitable for ISO-8895-1 (if iso_8859_1 is true) or ISO-8895-2 (if iso_8859_1 is false). The advantage of this method is that there's no need to specify the charset.- Parameters:
iso_8859_1
-ct
-- Throws:
X400APIException
-
BodypartGeneralText
public BodypartGeneralText(java.lang.String fileName, java.nio.charset.Charset sourceCharacterSet, java.lang.String isoCharsets) throws X400APIException
Creates a General Text bodypart which will be encoded using the specified ISO character sets, reading the data for the bodypart from the specified file using the selected encoding.- Parameters:
fileName
- name of file to read data fromsourceCharacterSet
- identifies the encoding which the input file usesisoCharsets
- identifies the ISO-2022 character sets to be used by the bodypart- Throws:
X400APIException
-
-
Method Detail
-
getCharset
public BodypartGeneralText.Charset getCharset() throws X400APIException
Deprecated.callers should usegetCharsetString()
, which returns all possible charset values in a String.Returns the Charset of this General Text bodypart- Throws:
X400APIException
-
getCharsetString
public java.lang.String getCharsetString() throws X400APIException
Returns the charset string of this General Text bodypart- Throws:
X400APIException
-
setCharset
public void setCharset(BodypartGeneralText.Charset cs) throws X400APIException
Sets the charset of this General Text bodypart- Parameters:
cs
-- Throws:
X400APIException
-
getTextContent
public java.lang.String getTextContent() throws X400APIException
Returns the content of this General Text bodypart- Throws:
X400APIException
-
setTextContent
public void setTextContent(java.lang.String ct) throws X400APIException
Sets the content of this General Text bodypart- Parameters:
ct
-- Throws:
X400APIException
-
setContentFromFile
public void setContentFromFile(java.lang.String file) throws X400APIException
Deprecated.Assumes that input file is UTF-8 encoded, when this may not be trueSets the content of this General Text bodypart- Parameters:
file
-- Throws:
X400APIException
-
getStringRepresentation
public java.lang.String getStringRepresentation() throws X400APIException
Returns the string representation of this message bodypart.- Throws:
X400APIException
-
getSize
public int getSize()
Returns the size, in bytes, of the message bodypart.- Overrides:
getSize
in classBodypart
- Throws:
X400APIException
-
setSize
public void setSize(int s)
Sets the size of message bodypart in bytes.
-
saveBP
public void saveBP(java.lang.String filename) throws X400APIException
Save the bodypart in the given filename- Overrides:
saveBP
in classBodypart
- Parameters:
filename
-- Throws:
X400APIException
-
saveBodypartRaw
public void saveBodypartRaw(java.lang.String filename) throws X400APIException, java.io.IOException
Save the bodypart in the given filename- Parameters:
filename
-- Throws:
java.io.IOException
X400APIException
-
-