|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object codec.asn1.ASN1AbstractType codec.asn1.ASN1AbstractString
public abstract class ASN1AbstractString
The root class of all ASN.1 string types including but not limited to IA5String, VisibleString, PrintableString, UTCTime, and GeneralizedTime.
Each string type is encoded as if it is declared as [UNIVERSAL x] IMPLICIT OCTET STRING where x is the tag number of the respective string type (see ITU-T Rec. X.690, paragraph 8.20.3).
There are 8 restructed string types of which 4 do not allow escape sequences, namely NumericString, PrintableString, VisibleString (ISO646String) and IA5String. TeletexString (T61String), VideotextString, GraphicString, and GeneralString allow the use of escape sequences. However, the srings must be encoded such as to use the minimum number of octets possible. All these strings use 1-octet representations; IA5String uses 2-octet representations for special characters.
Two unrestricted string types are defined in X.680, namely BMPString and UniversalString. BMPString uses a 2-octet representation per character and UniversalString uses a 4-octet representation.
Each string type represented in this package handles octets
to character and character to octets conversion according to
the general coding scheme of the particular string, but not
neccessarily restriction to a particular character set. This
is to be implemented through constraints
that are added to the respective types on creation (in the
constructors). Restriction of character sets is thus done on
the Unicode character set used by Java.
This class implements plain 1-octet to character conversion
by default. Class BMPString
handles 2-octet
conversion and class UniversalString
handles 4-octets conversion. Without reference to ISO defined
character encodings these implementations assume that the
n-octet tuples represent the least significant bits of
the Unicode characters with the corresponding bits set to zero.
Field Summary | |
---|---|
private static String |
DEFAULT_VALUE
|
private String |
value_
|
Constructor Summary | |
---|---|
ASN1AbstractString()
|
|
ASN1AbstractString(String s)
Creates an instance with the given string value. |
Method Summary | |
---|---|
String |
convert(byte[] b)
Converts the given byte array to a string by filling up each consecutive byte with 0's to the size of the Unicode characters. |
byte[] |
convert(String s)
Converts the given string to a byte array by chopping away all but the least significant byte of each character. |
int |
convertedLength(String s)
Returns the number of bytes required to store the converted string. |
void |
decode(Decoder enc)
|
void |
encode(Encoder enc)
|
String |
getString()
Returns the represented string value. |
Object |
getValue()
Returns the represented string value. |
void |
setString(String s)
Sets the string value. |
protected void |
setString0(String s)
|
String |
toString()
|
Methods inherited from class codec.asn1.ASN1AbstractType |
---|
checkConstraints, getConstraint, getTag, getTagClass, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface codec.asn1.ASN1Type |
---|
checkConstraints, getConstraint, getTag, getTagClass, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
Field Detail |
---|
private static final String DEFAULT_VALUE
private String value_
Constructor Detail |
---|
public ASN1AbstractString()
public ASN1AbstractString(String s)
setString
to set the string value.
The
- string value.Method Detail |
---|
public Object getValue()
getValue
in interface ASN1Type
getValue
in class ASN1AbstractType
public String getString()
getString
in interface ASN1String
public void setString(String s) throws ConstraintException
setString
in interface ASN1String
s
- The string value.
ConstraintException
- if the given string
does not match the constraint set for this
instance.protected void setString0(String s)
public void encode(Encoder enc) throws ASN1Exception, IOException
encode
in interface ASN1Type
encode
in class ASN1AbstractType
ASN1Exception
IOException
public void decode(Decoder enc) throws ASN1Exception, IOException
decode
in interface ASN1Type
decode
in class ASN1AbstractType
ASN1Exception
IOException
public String convert(byte[] b) throws ASN1Exception
convert
in interface ASN1String
b
- The byte array to convert.
ASN1Exception
public byte[] convert(String s) throws ASN1Exception
convert
in interface ASN1String
s
- The string to convert.
ASN1Exception
public int convertedLength(String s) throws ASN1Exception
convertedLength
in interface ASN1String
s
- The string.
ASN1Exception
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |