Class Asn1Tag


  • public final class Asn1Tag
    extends Object
    Provides methods for building and analyzing ASN.1 tag bytes.

    Examples of usage:

    • Building a Universal, primitive with number 3 tag:
      Asn1Tag.universal().number(3);
      will return 0x03.
    • Building an application, constructed with number 9 tag:
      Asn1Tag.application().constructed().number(9);
      will return 0x69.
    • Method Detail

      • toString

        public static String toString​(byte tag)
        Returns a string representation of the provided tag.
        Parameters:
        tag - The tag to be represented as a string.
        Returns:
        The string representation of this tag.
      • valueOf

        public static Asn1Tag valueOf​(byte tag)
        Converts the provided byte to an Asn1Tag.
        Parameters:
        tag - The byte to be converted.
        Returns:
        The Asn1Tag corresponding to the provided tag byte.
      • universal

        public static Asn1Tag universal()
        Returns a primitive ASN.1 tag with the universal tag class.
        Returns:
        A primitive ASN.1 tag with the universal tag class.
      • application

        public static Asn1Tag application()
        Returns a primitive ASN.1 tag with the application tag class.
        Returns:
        A primitive ASN.1 tag with the application tag class.
      • contextSpecific

        public static Asn1Tag contextSpecific()
        Returns a primitive ASN.1 tag with the context-specific tag class.
        Returns:
        A primitive ASN.1 tag with the context-specific tag class.
      • privateTag

        public static Asn1Tag privateTag()
        Returns a primitive ASN.1 tag with the private tag class.
        Returns:
        A primitive ASN.1 tag with the private tag class.
      • constructed

        public Asn1Tag constructed()
        Changes this ASN.1 tag from primitive to constructed.
        Returns:
        this ASN.1 tag.
      • number

        public byte number​(int tagNumber)
        Returns the byte representation of this tag having the provided tag number.
        Parameters:
        tagNumber - The tag number.
        Returns:
        The byte representation of this tag having the provided tag number.
      • getClassName

        public Asn1Tag.Class getClassName()
        Returns this tag class name.
        Returns:
        This tag class name.
      • isConstructed

        public boolean isConstructed()
        Returns whether this tag is constructed.
        Returns:
        true if this tag is constructed, false if it is primitive.
      • getTagNumber

        public int getTagNumber()
        Returns this tag number.
        Returns:
        This tag number.
      • toString

        public String toString()
        Returns the string representation of this Asn1 tag. The string value corresponds to the chain of methods that should be called to produce the same Asn1 tag, e.g. "contextSpecific().constructed().number(3)".
        Overrides:
        toString in class Object
        Returns:
        The string representation of this Asn1 tag.