Asn1OpenType Class Reference
Classes | |
class | SaxHandler |
Public Member Functions | |
Asn1OpenType (char[] data, int encoding) | |
Asn1OpenType (string data, int encoding) | |
Asn1OpenType (Asn1EncodeBuffer buffer) | |
Asn1OpenType (byte[] data, int offset, int nbytes, int encoding) | |
Asn1OpenType (byte[] data, int offset, int nbytes) | |
Asn1OpenType (byte[] data, int encoding) | |
Asn1OpenType (byte[] data) | |
Asn1OpenType () | |
override void | Decode (Asn1JsonDecodeBuffer buffer) |
override void | Decode (Asn1OerDecodeBuffer buffer) |
override void | Decode (Asn1PerDecodeBuffer buffer) |
override void | Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) |
void | DecodeExtension (Asn1JsonDecodeBuffer buffer, String name) |
override void | Encode (Asn1PerOutputStream outs) |
override void | Encode (Asn1BerOutputStream outs, bool explicitTagging) |
override void | Encode (Asn1JsonOutputStream outstream) |
override void | Encode (Asn1XerEncoder buffer) |
override void | Encode (Asn1XerEncoder buffer, String elemName) |
override void | Encode (Asn1XmlEncoder buffer) |
override void | Encode (Asn1XmlEncoder buffer, String elemName, String nsPrefix) |
override void | Encode (Asn1OerEncodeBuffer buffer) |
override void | Encode (Asn1PerEncodeBuffer buffer) |
override int | Encode (Asn1BerEncodeBuffer buffer, bool explicitTagging) |
void | EncodeAsExtension (Asn1JsonOutputStream outstream) |
void | EncodeAsExtension (Asn1XerEncoder buffer) |
void | EncodeAsExtension (Asn1XmlEncoder buffer) |
char[] | GetCharData () |
int | GetDataEncoding () |
virtual Asn1XerSaxHandler | GetSaxHandler (bool captureOuterElem) |
virtual Asn1XerSaxHandler | GetSaxHandler () |
void | SetBinaryData (byte[] data, int encoding) |
void | SetCharData (char[] data, int encoding) |
void | SetCharData (String data, int encoding) |
override System.String | ToString () |
Protected Attributes | |
int | dataEncoding |
internal Asn1EncodeBuffer | mEncodeBuffer |
internal int | mLength |
Properties | |
override string | AsnTypeName [get] |
Detailed Description
This is a container class for holding an ASN.1 open type value.
Where the data is internally stored and how it is interpreted is controlled by a "dataEncoding" field. You can specify the data encoding when creating the object. It will also be set when decoding. The following explains the possible data encodings:
- UNKNOWN: "mValue" is used to hold byte data. It is interpreted as the encoding of the actual value according to some unknown encoding rules (BER, PER, OER, XER, JSON, or some other).
- BER, PER, OER: "mValue" is used to hold byte data. It is interpreted as the encoding of the actual value according to BER, PER, or OER, respectively.
- XER: "mValue" is used to hold byte data. It is interpreted as the the encoding of the actual value in XML (whether X.693 or Obj-Sys rules), where the XML characters are encoded to bytes using the UTF-8 character encoding.
- JSON: a private field is used to hold character data. The character data is the encoding of the actual value in JSON.
Note especially that the data encoding indicates the encoding rules used to encode the actual value. That result is typically encoded as part of some larger encoding. The data encoding does NOT indicate the rules used for that larger encoding. For example, using an xmlhstring representation, XER and JSON will encode an open type that was previously encoded using any arbitrary encoding rules. When decoding such data, the data encoding will be UNKNOWN, not XER nor JSON.
Constructor & Destructor Documentation
Asn1OpenType | ( | ) |
This constructor creates an empty type that can be used in a Decode method call to receive an encoded value. The data encoding is UNKNOWN.
Asn1OpenType | ( | byte[] | data | ) |
This constructor initializes an open type from the given byte array. The array is assumed to contain a previously encoded message component. The data encoding is UNKNOWN.
- Parameters:
-
data Byte array containing a previously encoded message component.
Asn1OpenType | ( | byte[] | data, | |
int | encoding | |||
) |
This constructor initializes an open type from the given byte array. The array is assumed to contain a previously encoded message component.
- Parameters:
-
data Byte array containing a previously encoded value. encoding The encoding that describes the meaning of data. Any of the encodings other than JSON.
Asn1OpenType | ( | byte[] | data, | |
int | offset, | |||
int | nbytes | |||
) |
This constructor initializes the open type from a portion of the given byte array. A new byte array is created starting at the given offset and consisting of the given number of bytes. The encoding is UNKNOWN.
- Parameters:
-
data Byte array containing a previously encoded value. offset The offset in array at which to begin copy. nbytes Number of bytes to copy from target array
Asn1OpenType | ( | byte[] | data, | |
int | offset, | |||
int | nbytes, | |||
int | encoding | |||
) |
This constructor initializes the open type from a portion of the given byte array. A new byte array is created starting at the given offset and consisting of the given number of bytes. /p>
- Parameters:
-
data Byte array containing a previously encoded value. encoding Starting offset in data from which to copy bytes nbytes Number of bytes to copy from target array offset The encoding that describes the meaning of data. Any of the encodings other than JSON.
Asn1OpenType | ( | Asn1EncodeBuffer | buffer | ) |
This constructor initializes an open type using an encoded component. This can be used if a header (for example, a ROSE header) is being prepended to a pre-encoded component. The data encoding is derived from the type of Asn1EncodeBuffer given, and is possibly UNKNOWN.
- Parameters:
-
buffer Reference to encode buffer into which component type was encoded.
Asn1OpenType | ( | string | data, | |
int | encoding | |||
) |
Convenience constructor. Same as Asn1OpenType(data.ToCharArray(), encoding)
Asn1OpenType | ( | char[] | data, | |
int | encoding | |||
) |
Create Asn1OpenType on the given character data. /p>
- Parameters:
-
data The character data array. encoding The encoding. Either XER or JSON. If JSON, data is taken to be the JSON encoding of the actual value. The array is not copied, so beware using it after passing it here. The "mValue" field will be assigned null. If XER, data is taken to be the XER encoding of the actual value. The "mValue" field will be assigned the UTF-8 character encoding of the given characters.
Member Function Documentation
override void Decode | ( | Asn1JsonDecodeBuffer | buffer | ) | [virtual] |
Decode ASN.1 open type value from JSON. If the JSON value was a JSONNestedValue, the data encoding will be JSON, and the data will be character data. If the JSON value was a JSON string (a quoted xmlhstring), the data encoding will be UNKNOWN and the data will be byte data.
For decoding an unknown extension element, use decodeExtension.
Reimplemented from Asn1OctetString.
override void Decode | ( | Asn1OerDecodeBuffer | buffer | ) | [virtual] |
This method decodes an ASN.1 open type value using the Octet Encoding Rules (OER). This object will subsequently contain the encoding of the open type (which should be OER).
Reimplemented from Asn1OctetString.
override void Decode | ( | Asn1PerDecodeBuffer | buffer | ) | [virtual] |
This method decodes an ASN.1 open type value using the packed encoding rules (PER). The data encoding will be set to PER.
- Parameters:
-
buffer Decode message buffer object
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
override void Decode | ( | Asn1BerDecodeBuffer | buffer, | |
bool | explicitTagging, | |||
int | implicitLength | |||
) | [virtual] |
This method decodes an ASN.1 open type value. The data encoding will be set to BER.
- Parameters:
-
buffer Decode message buffer object explicitTagging Flag indicating element is explicitly tagged implicitLength Length of contents if implicit
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
void DecodeExtension | ( | Asn1JsonDecodeBuffer | buffer, | |
String | name | |||
) |
Decode an extension from JSON. There should be, possibly after some leading whitespace, a JSON value on the input. After decoding, this object's data encoding will be JSON and the character data will be the a JSONNamedValue, formed from the given (previously decoded) name and the decoded value.
override void Encode | ( | Asn1PerOutputStream | outs | ) | [virtual] |
This method encodes an ASN.1 open type value using the Packed Encoding Rules (PER). The data should be the value pre-encoded in PER.
Also throws any exception thrown by the underlying Asn1PerOutputStream.
- Parameters:
-
outs PER Output Stream object
- Exceptions:
-
Asn1Exception Thrown, if operation is failed.
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
override void Encode | ( | Asn1BerOutputStream | outs, | |
bool | explicitTagging | |||
) | [virtual] |
This method encodes and writes to the stream an ASN.1 open type value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER). The data should be the value pre-encoded in BER.
Throws, Exception thrown by C# System.IO.Stream for I/O error
- Parameters:
-
outs BER Output Stream object explicitTagging Flag indicating explicit tagging should be done
- Exceptions:
-
Asn1Exception Thrown, if operation is failed.
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
override void Encode | ( | Asn1JsonOutputStream | outstream | ) | [virtual] |
override void Encode | ( | Asn1XerEncoder | buffer | ) | [virtual] |
This method encodes an ASN.1 open type value using the XML Encoding Rules (XER).
If the data encoding is XER, the data is written as-is. Otherwise, the data's hexadecimal representation is encoded (i.e. xmlhstring).
- Parameters:
-
buffer Encode message buffer object
Reimplemented from Asn1Type.
override void Encode | ( | Asn1XerEncoder | buffer, | |
String | elemName | |||
) |
This method encodes an ASN.1 open type value using the XML Encoding as specified in the XML schema standard(asn2xsd).
If the data encoding is XER, the data is written as-is. Otherwise, the data's hexadecimal representation is encoded (i.e. xmlhstring).
- Parameters:
-
buffer Encode message buffer object elemName Ignored
override void Encode | ( | Asn1XmlEncoder | buffer | ) | [virtual] |
This method encodes an ASN.1 open type value using the XML Encoding as specified in the XML schema standard(asn2xsd).
If the data encoding is XER, the data is written as-is. Otherwise, the data's hexadecimal representation is encoded (i.e. xmlhstring).
- Parameters:
-
buffer Encode message buffer object
Reimplemented from Asn1Type.
override void Encode | ( | Asn1XmlEncoder | buffer, | |
String | elemName, | |||
String | nsPrefix | |||
) |
This method encodes an ASN.1 open type value using the XML Encoding as specified in the XML schema standard(asn2xsd). If the data encoding is XER, the data is written as-is. Otherwise, the data's hexadecimal representation is encoded (i.e. xmlhstring).
- Parameters:
-
buffer Encode message buffer object elemName Ignored nsPrefix Ignored
override void Encode | ( | Asn1OerEncodeBuffer | buffer | ) | [virtual] |
This method encodes an ASN.1 open type value using the Octet Encoding Rules (OER). The data should be the value pre-encoded in OER.
- Parameters:
-
buffer Encode message buffer object
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
override void Encode | ( | Asn1PerEncodeBuffer | buffer | ) | [virtual] |
This method encodes an ASN.1 open type value using the Packed Encoding Rules (PER). The data should be the value pre-encoded encoded in PER.
- Parameters:
-
buffer Encode message buffer object
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
override int Encode | ( | Asn1BerEncodeBuffer | buffer, | |
bool | explicitTagging | |||
) | [virtual] |
This method encodes an ASN.1 open type value. The value is assumed to be an already-encoded BER message component and will be copied to the encoded buffer. An optimization is available in which no copy will performed if the encoded component is already present in the encode buffer. This is done if the form of constructor specifiying only a component length is used.
- Parameters:
-
buffer Encode message buffer object explicitTagging Flag indicating element is explicitly tagged
- Returns:
- Length of encoded component
Reimplemented from Asn1OctetString.
Reimplemented in Asn1ChoiceExt.
void EncodeAsExtension | ( | Asn1JsonOutputStream | outstream | ) |
This method encodes an extension element to JSON. If the data encoding is other than JSON, it cannot be encoded and the data is dropped.
void EncodeAsExtension | ( | Asn1XerEncoder | buffer | ) |
This method encodes an extension element to XML. If the data encoding is other than XER, its hexadecimal representation is encoded inside an XML comment.
- Parameters:
-
buffer
void EncodeAsExtension | ( | Asn1XmlEncoder | buffer | ) |
This method encodes an extension element to XML. If the data encoding is other than XER, the hexadecimal representation of the data is encoded inside an XML comment.
- Parameters:
-
buffer Encode message buffer object
char [] GetCharData | ( | ) |
Returns the character data for the open type. Currently, this is only supported when getDataEncoding() returns JSON.
- Returns:
- The char data. The actual internal array is returned; a copy is not made.
- Exceptions:
-
RuntimeException if data encoding indicates there is no char data
int GetDataEncoding | ( | ) |
Return the data encoding of the data.
virtual Asn1XerSaxHandler GetSaxHandler | ( | bool | captureOuterElem | ) | [virtual] |
This method returns the Asn1XerOpenType.SaxHandler class instance used for ASN.1 XER encoding.
- Parameters:
-
captureOuterElem Pass true if the outer element start and end tags (if present) should be captured. The outer element is the element for which startElement is called when the level is the start level. Note that this parameter is ignored if you have previously invoked one of the getSaxHandler methods on this object.
- Returns:
- Asn1XerOpenType.SaxHandler object
virtual Asn1XerSaxHandler GetSaxHandler | ( | ) | [virtual] |
This method returns the Asn1XerOpenType.SaxHandler class instance used for ASN.1 XER encoding. If this is the first invocation of any of the GetSaxHandler methods on this object, the returned handler will capture the outer element start/end tags. Otherwise, this will simply return the same SAX handler as previously returned.
- Returns:
- Asn1XerOpenType.SaxHandler object
void SetBinaryData | ( | byte[] | data, | |
int | encoding | |||
) |
Sets the binary data for the open type and assigns the data encoding to the given encoding.
- Parameters:
-
data The binary data that make up an encoding of the actual value. encoding Identifies the encoding rules for which data is an encoding. This can be any of the encodings except JSON.
void SetCharData | ( | char[] | data, | |
int | encoding | |||
) |
Sets the character data for the open type and assigns the data encoding to the given encoding.
- Parameters:
-
data The character data that make up an encoding of the actual value. encoding Permissible values are JSON and XER. If XER, the given data will be converted to bytes using UTF-8 and held in the "mValue" field. If JSON, the given data will be held as-is. The array will not be copied. The "mValue" field will be assigned null.
void SetCharData | ( | String | data, | |
int | encoding | |||
) |
Convenience method; same as
SetCharData(mValue.toCharArray(), encoding)
override System.String ToString | ( | ) |
This method will return a string representation of the open type value. If the data encoding is XER or JSON, the string will consist of the corresponding characters (in the case of XER, the byte data is converted to characters using UTF-8). In all other cases, the hexadecimal representation of the byte data is returned.
- Returns:
- Stringified representation of the value
Reimplemented from Asn1OctetString.
Member Data Documentation
int dataEncoding [protected] |
Specifies the nature of the data held by this object. /p>
internal Asn1EncodeBuffer mEncodeBuffer [protected] |
The encode buffer into which component type will be encoded. /p>
internal int mLength [protected] |
Length of the pre-encoded component. /p>
Property Documentation
override string AsnTypeName [get] |
Gets the ASN.1 type name that is associated with this type. The ASN.1 type name is derived from the input specification and cannot be set by users of the class.
Value:
The ASN.1 type name for this type.
Reimplemented from Asn1Type.