XCMS Toolkit

schemajic.schema
Class Tag

java.lang.Object
  extended by schemajic.schema.Tag
All Implemented Interfaces:
Encodable

public class Tag
extends java.lang.Object
implements Encodable

Processing support necessary to provide an ASN.1 tagged-type capability. Excerpted from X.680-0207...

 30 Notation for tagged types
 A tagged type (see 3.6.70) is a new type which is isomorphic with an old type, but which has a different tag. The tagged
 type is mainly of use where this Recommendation | International Standard requires the use of types with distinct tags
 (see 24.5 to 24.6, 26.3 and 28.3). The use of a "TagDefault" of AUTOMATIC TAGS in a module allows this to be
 accomplished without the explicit appearance of tagged type notation in that module.
 
 NOTE – Where a protocol determines that values from several data types may be transmitted at any moment in time, distinct tags
 may be needed to enable the recipient to correctly decode the value.

 30.1 The notation for a tagged type shall be "TaggedType":

                TaggedType ::=
                          Tag Type
                        | Tag IMPLICIT Type
                        | Tag EXPLICIT Type
                
                Tag ::= "[" Class ClassNumber "]"
                
                ClassNumber ::=
                          number
                        | DefinedValue
                        
                Class ::=
                          UNIVERSAL
                        | APPLICATION
                        | PRIVATE
                        | empty
        

 
        30.2 The "valuereference" in "DefinedValue" shall be of type integer, and assigned a non-negative value.
        
        30.3 The new type is isomorphic with the old type, but has a tag with class "Class" and number "ClassNumber",
        except when "Class" is "empty", in which case the tag is context-specific class and number is "ClassNumber".
        
        30.4 The "Class" shall not be UNIVERSAL except for types defined in this Recommendation | International Standard.
        
        NOTE 1 – Use of universal class tags are agreed from time-to-time by ITU-T and ISO.
        
        NOTE 2 – Subclause E.2.12 contains guidance and hints on stylistic use of tag classes.
        
        30.5 All application of tags is either implicit tagging or explicit tagging. Implicit tagging indicates, for those
        encoding rules which provide the option, that explicit identification of the original tag of the "Type" in the
        "TaggedType" is not needed during transfer.
        NOTE – It can be useful to retain the old tag where this was universal class, and hence unambiguously identifies the old type
        without knowledge of the ASN.1 definition of the new type. Minimum transfer octets is, however, normally achieved by the use
        of IMPLICIT. An example of an encoding using IMPLICIT is given in ITU-T Rec. X.690 | ISO/IEC 8825-1.
        
        30.6 The tagging construction specifies explicit tagging if any of the following holds:
                a) the "Tag EXPLICIT Type" alternative is used;
                b) the "Tag Type" alternative is used and the value of "TagDefault" for the module is either EXPLICIT
                TAGS or is empty;
                c) the "Tag Type" alternative is used and the value of "TagDefault" for the module is IMPLICIT TAGS or
                AUTOMATIC TAGS, but the type defined by "Type" is an untagged choice type, an untagged open type, or
                an untagged "DummyReference" (see ITU-T Rec. X.683 | ISO/IEC 8824-4, 8.3).
                The tagging construction specifies implicit tagging otherwise.
        
        30.7 If the "Class" is "empty", there are no restrictions on the use of "Tag", other than those implied by the
        requirement for distinct tags in 24.5 to 24.6, 26.3 and 28.3.
        
        30.8 The IMPLICIT alternative shall not be used if the type defined by "Type" is an untagged choice type or an
        untagged open type or an untagged "DummyReference" (see ITU-T Rec. X.683 | ISO/IEC 8824-4, 8.3).
        
        30.9 The notation for a value of a "TaggedType" shall be "TaggedValue", or when used as an "XMLValue",
        "XMLTaggedValue". These productions are:

        
                TaggedValue ::= Value
                XMLTaggedValue ::= XMLValue
        
where "Value" or "XMLValue" is a notation for a value of the "Type" in the "TaggedType".

NOTE: _tagMode is only relevant when the tag is part of a Type's metadata.

Version:
1.00 - 2006/01/21
Author:
support@phillipgriffin.com

Field Summary
static byte CONSTRUCTED
           
static byte CONTEXT_SPECIFIC
           
static byte PRIMITIVE
           
static byte UNIVERSAL
           
 
Constructor Summary
Tag(int tclass, int pc, int number)
          Constructor for Tag with initialization parameters.
Tag(java.lang.String s)
          Constructor for Tag with string initialization parameter.
 
Method Summary
static Tag decode(java.io.InputStream in)
          Decodes an ASN.1 tag from an input stream.
 void encode(java.io.OutputStream out)
          Encodes the current encoding value to an output stream.
 int getTagClass()
          returns the tag class assigned to a type in the ASN.1 standards
 int getTagNumber()
          returns the tag number assigned to a type in the ASN.1 standards
 int getTagPC()
          returns the tagPC
 boolean isConstructed()
          Determines if an ASN.1 tag is constructed.
 boolean isContextSpecific()
          Determines if the current class of ASN.1 tag is context specific.
 boolean isExplicit()
          Return true if the tagging mode for this tag is EXPLICIT.
 boolean isPrimitive()
          Determines if an ASN.1 tag is primitive.
 boolean isVisible()
          Based on whether the tag modifier is EXPLICIT or IMPLICIT, and the default tagging for the module, return true if the tag is visible in a DER encoding.
 boolean matches(java.io.InputStream in)
          Determines if a given ASN.1 tag matches the data in an input stream.
 java.lang.String toString()
          Returns the hexadecimal representation of an ASN.1 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNIVERSAL

public static final byte UNIVERSAL
See Also:
Constant Field Values

CONTEXT_SPECIFIC

public static final byte CONTEXT_SPECIFIC
See Also:
Constant Field Values

PRIMITIVE

public static final byte PRIMITIVE
See Also:
Constant Field Values

CONSTRUCTED

public static final byte CONSTRUCTED
See Also:
Constant Field Values
Constructor Detail

Tag

public Tag(java.lang.String s)
    throws java.text.ParseException
Constructor for Tag with string initialization parameter.

Parameters:
s - initialization value
Throws:
java.text.ParseException

Tag

public Tag(int tclass,
           int pc,
           int number)
Constructor for Tag with initialization parameters.

Parameters:
tclass - class of this ASN.1 tag
pc - tag counter
number - tag number
Method Detail

isExplicit

public boolean isExplicit()
Return true if the tagging mode for this tag is EXPLICIT.

Note that this condition is only relevant when the given tag is part of a schema.

Returns:
the current tagging default

getTagClass

public int getTagClass()
returns the tag class assigned to a type in the ASN.1 standards

Returns:
integer indicating the tag class

getTagNumber

public int getTagNumber()
returns the tag number assigned to a type in the ASN.1 standards

Returns:
integer tag number

getTagPC

public int getTagPC()
returns the tagPC

Returns:
int

matches

public boolean matches(java.io.InputStream in)
                throws java.io.IOException
Determines if a given ASN.1 tag matches the data in an input stream.

Parameters:
in - an input stream
Returns:
boolean true or false
Throws:
java.io.IOException

isContextSpecific

public boolean isContextSpecific()
Determines if the current class of ASN.1 tag is context specific.

Returns:
boolean true or false

isPrimitive

public boolean isPrimitive()
Determines if an ASN.1 tag is primitive.

Returns:
boolean true or false

isConstructed

public boolean isConstructed()
Determines if an ASN.1 tag is constructed.

Returns:
boolean true or false

isVisible

public boolean isVisible()
Based on whether the tag modifier is EXPLICIT or IMPLICIT, and the default tagging for the module, return true if the tag is visible in a DER encoding.

Returns:
boolean true if visible

toString

public java.lang.String toString()
Returns the hexadecimal representation of an ASN.1 encoding.

Overrides:
toString in class java.lang.Object

decode

public static Tag decode(java.io.InputStream in)
                  throws java.io.IOException
Decodes an ASN.1 tag from an input stream.

Parameters:
in - an input stream
Returns:
an ASN.1 tag
Throws:
java.io.IOException

encode

public void encode(java.io.OutputStream out)
            throws EncodingException
Encodes the current encoding value to an output stream.

Specified by:
encode in interface Encodable
Parameters:
out - provided output stream encoding target
Throws:
EncodingException

XCMS Toolkit


Copyright © 2005-2006 GRIFFIN Consulting. All Rights Reserved.