Class ASN1PrintableString

  • All Implemented Interfaces:
    java.io.Serializable

    @NotMutable
    @ThreadSafety(level=COMPLETELY_THREADSAFE)
    public final class ASN1PrintableString
    extends ASN1Element
    This class provides an ASN.1 printable string element that can hold any empty or non-empty string comprised only of the characters listed below.
    • The uppercase ASCII letters A through Z.
    • The lowercase ASCII letters a through z.
    • The ASCII digits 0 through 9.
    • The ASCII space.
    • The ASCII apostrophe (aka single quote).
    • The ASCII left parenthesis.
    • The ASCII right parenthesis.
    • The ASCII plus sign.
    • The ASCII comma.
    • The ASCII minus sign (aka hyphen).
    • The ASCII period (aka full stop).
    • The ASCII forward slash (aka solidus).
    • The ASCII colon.
    • The ASCII equal sign.
    • The ASCII question mark.
    See Also:
    Serialized Form
    • Constructor Detail

      • ASN1PrintableString

        public ASN1PrintableString​(java.lang.String stringValue)
                            throws ASN1Exception
        Creates a new ASN.1 printable string element with the default BER type and the provided value.
        Parameters:
        stringValue - The string value to use for this element. It may be null or empty if the value should be empty. It must only contain characters allowed in printable strings.
        Throws:
        ASN1Exception - If the provided string does not represent a valid printable string.
      • ASN1PrintableString

        public ASN1PrintableString​(byte type,
                                   java.lang.String stringValue)
                            throws ASN1Exception
        Creates a new ASN.1 printable string element with the specified BER type and the provided value.
        Parameters:
        type - The BER type for this element.
        stringValue - The string value to use for this element. It may be null or empty if the value should be empty. It must only contain characters allowed in printable strings.
        Throws:
        ASN1Exception - If the provided string does not represent a valid printable string.
    • Method Detail

      • stringValue

        public java.lang.String stringValue()
        Retrieves the string value for this element.
        Returns:
        The string value for this element.
      • decodeAsPrintableString

        public static ASN1PrintableString decodeAsPrintableString​(byte[] elementBytes)
                                                           throws ASN1Exception
        Decodes the contents of the provided byte array as a printable string element.
        Parameters:
        elementBytes - The byte array to decode as an ASN.1 printable string element.
        Returns:
        The decoded ASN.1 printable string element.
        Throws:
        ASN1Exception - If the provided array cannot be decoded as a printable string element.
      • decodeAsPrintableString

        public static ASN1PrintableString decodeAsPrintableString​(ASN1Element element)
                                                           throws ASN1Exception
        Decodes the provided ASN.1 element as a printable string element.
        Parameters:
        element - The ASN.1 element to be decoded.
        Returns:
        The decoded ASN.1 printable string element.
        Throws:
        ASN1Exception - If the provided element cannot be decoded as a printable string element.
      • toString

        public void toString​(java.lang.StringBuilder buffer)
        Appends a string representation of the value for this ASN.1 element to the provided buffer.
        Overrides:
        toString in class ASN1Element
        Parameters:
        buffer - The buffer to which to append the information.