codec.asn1
Interface ASN1String

All Superinterfaces:
ASN1Type
All Known Implementing Classes:
ASN1AbstractString

public interface ASN1String
extends ASN1Type

The common interface of all ASN.1 string types. This interface specifies setter and getter methods for string values and methods for string to octet and octet to string conversion. See ASN1AbstractString for details on strings.

Version:
"$Id: ASN1String.java,v 1.2 2000/12/06 17:47:26 vroth Exp $"
Author:
Volker Roth
See Also:
ASN1AbstractString

Method Summary
 String convert(byte[] b)
          Converts the given byte array to a string.
 byte[] convert(String s)
          Converts the given string to a byte array.
 int convertedLength(String s)
          Returns the number of octets required to encode the given string according to the basic encoding scheme of this type.
 String getString()
          Returns the represented string value.
 void setString(String s)
          Sets the string value.
 
Methods inherited from interface codec.asn1.ASN1Type
checkConstraints, decode, encode, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional
 

Method Detail

getString

public String getString()
Returns the represented string value.
Returns:
The string value of this type.

setString

public void setString(String s)
               throws ConstraintException
Sets the string value.
Parameters:
s - The string value.

convert

public String convert(byte[] b)
               throws ASN1Exception
Converts the given byte array to a string.
Parameters:
b - The byte array to convert.

convert

public byte[] convert(String s)
               throws ASN1Exception
Converts the given string to a byte array.
Parameters:
s - The string to convert.

convertedLength

public int convertedLength(String s)
                    throws ASN1Exception
Returns the number of octets required to encode the given string according to the basic encoding scheme of this type. For restricted string types this likely equals the number of characters in the string unless special characters or escape sequences are allowed. For BMPStrings this is twice the number of characters and for UniversalStrings it is four times the number of characters in the string.

The number returned must equal the number returned by the method call convert(s). This method is required for DER encoding of string types in order to determine the number of octets required for encoding the given string. For BER encoding this method is not and the encoding of the string may be broken up into consecutive OCTET STRINGS.

Parameters:
s - The string whose encoding length is determined.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.