XCMS Toolkit

schemajic.encoder
Class BXEREncoder

java.lang.Object
  extended by schemajic.codec.Encoder
      extended by schemajic.encoder.BXEREncoder
All Implemented Interfaces:
ValueVisitor
Direct Known Subclasses:
CXEREncoder, Printer

public class BXEREncoder
extends Encoder
implements ValueVisitor

Encoder for Basic XML Encoding Rules (BXER) of ASN.1.

Note that XML Comments and Processing Instructions are NOT standardized in BXER/CXER.

Version:
1.00 - 2006/02/12
Author:
support@phillipgriffin.com

Field Summary
protected  BinaryFormat _binaryFormat
           
protected  java.lang.StringBuffer _buffer
           
protected  Schema _currentSchema
           
protected  java.lang.String _curXmlFormat
           
protected  GeneralizedTimeFormat _gtFormat
           
protected  XmlWriter _output
          The stream that the value will be encoded into.
protected  Type _type
          The meta schemajic.model of the value that is currently being encoded.
protected  boolean _useNamedIntegers
           
 
Constructor Summary
BXEREncoder()
           
 
Method Summary
protected  XmlWriter createXmlWriter(java.io.OutputStream out)
           
 void encode(ASN1Value value, java.io.OutputStream out)
          Abstract definition of a method for encoding a value of an ASN.1 type to a target output stream.
protected  void printArcs(int[] arcs, java.lang.String name)
           
protected  void printDefaultValue(ASN1Value value, Field fieldInfo)
           
 void setUseNamedIntegers(boolean b)
           
 void setWriteProlog(boolean b)
           
 java.lang.Object visit(ASN1BitString value, java.lang.Object object)
          Currently we only support the basic BIT STRING type, no NamedBitList toolkit support at this point in time.
 java.lang.Object visit(ASN1BMPString value, java.lang.Object object)
          An ASN.1 type BMPString visit method with value and object parameters.
 java.lang.Object visit(ASN1Boolean value, java.lang.Object object)
          The only valid values for a BOOLEAN are 'true' or 'false'.
 java.lang.Object visit(ASN1Choice value, java.lang.Object object)
          Encode the value of the chosen field.
 java.lang.Object visit(ASN1Enumerated value, java.lang.Object object)
          Always print the named number as an empty tag.
 java.lang.Object visit(ASN1GeneralizedTime value, java.lang.Object object)
          An ASN.1 type GeneralizedTime visit method with value and object parameters.
 java.lang.Object visit(ASN1GeneralString value, java.lang.Object object)
          An ASN.1 type GeneralString visit method with value and object parameters.
 java.lang.Object visit(ASN1IA5String value, java.lang.Object object)
          An ASN.1 type IA5String visit method with value and object parameters.
 java.lang.Object visit(ASN1Integer value, java.lang.Object object)
          An integer value that is not part of a NamedNumberList must be of the format SignedNumber: 0 | -n | n.
 java.lang.Object visit(ASN1ISO646String value, java.lang.Object object)
          An ASN.1 type ISO646String visit method with value and object parameters.
 java.lang.Object visit(ASN1Null value, java.lang.Object object)
          An ASN.1 type NULL visit method with value and object parameters.
 java.lang.Object visit(ASN1NumericString value, java.lang.Object object)
          An ASN.1 type NumericString visit method with value and object parameters.
 java.lang.Object visit(ASN1ObjectIdentifier value, java.lang.Object object)
          We always encode the value of an OBJECT-IDENTIFIER using the XMLNumberForm ( dot notation ).
 java.lang.Object visit(ASN1OctetString value, java.lang.Object object)
          Print as a string of hex characters.
 java.lang.Object visit(ASN1OpenType value, java.lang.Object object)
          If the OpenType contains a decoded ASN.1 value, then encode the contained value, otherwise assume that the user has provided a correctly encoded value and copy that value into the output stream.
 java.lang.Object visit(ASN1PrintableString value, java.lang.Object object)
          An ASN.1 type PrintableString visit method with value and object parameters.
 java.lang.Object visit(ASN1RelativeOID value, java.lang.Object object)
          We always encode the value of an OBJECT-IDENTIFIER using the XMLNumberForm ( dot notation ).
 java.lang.Object visit(ASN1Sequence value, java.lang.Object object)
          BXER: Components of a sequence which have a default value set may or may not be encoded at the sender's option.
 java.lang.Object visit(ASN1SequenceOf value, java.lang.Object object)
          An ASN.1 SEQUENCE OF type visit method with value and object parameters.
 java.lang.Object visit(ASN1SetOf value, java.lang.Object object)
          An ASN.1 SET OF type visit method with value and object parameters.
 java.lang.Object visit(ASN1T61String value, java.lang.Object object)
          An ASN.1 type T61String visit method with value and object parameters.
 java.lang.Object visit(ASN1TeletexString value, java.lang.Object object)
          An ASN.1 type TeletexString visit method with value and object parameters.
 java.lang.Object visit(ASN1UniversalString value, java.lang.Object object)
          An ASN.1 type UniversalString visit method with value and object parameters.
 java.lang.Object visit(ASN1UTF8String value, java.lang.Object object)
          An ASN.1 type UTF8String visit method with value and object parameters.
 java.lang.Object visit(ASN1VideotexString value, java.lang.Object object)
          An ASN.1 type VideotexString visit method with value and object parameters.
 java.lang.Object visit(ASN1VisibleString value, java.lang.Object object)
          An ASN.1 type VisibleString visit method with value and object parameters.
 java.lang.Object visit(XEROctetString value, java.lang.Object object)
          TODO: description goes here
protected  void writeProlog()
          The prolog is not required, but we default to writing it into the encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_output

protected XmlWriter _output
The stream that the value will be encoded into.


_useNamedIntegers

protected boolean _useNamedIntegers

_gtFormat

protected GeneralizedTimeFormat _gtFormat

_binaryFormat

protected BinaryFormat _binaryFormat

_curXmlFormat

protected java.lang.String _curXmlFormat

_currentSchema

protected Schema _currentSchema

_type

protected Type _type
The meta schemajic.model of the value that is currently being encoded.


_buffer

protected java.lang.StringBuffer _buffer
Constructor Detail

BXEREncoder

public BXEREncoder()
Method Detail

setWriteProlog

public void setWriteProlog(boolean b)

setUseNamedIntegers

public void setUseNamedIntegers(boolean b)

encode

public void encode(ASN1Value value,
                   java.io.OutputStream out)
            throws EncodingException
Description copied from class: Encoder
Abstract definition of a method for encoding a value of an ASN.1 type to a target output stream.

Specified by:
encode in class Encoder
Parameters:
value - the value of an ASN.1 type to be encoded
out - target of an encoding transform
Throws:
EncodingException

createXmlWriter

protected XmlWriter createXmlWriter(java.io.OutputStream out)

writeProlog

protected void writeProlog()
The prolog is not required, but we default to writing it into the encoding.


visit

public java.lang.Object visit(ASN1Boolean value,
                              java.lang.Object object)
                       throws VisitorException
The only valid values for a BOOLEAN are 'true' or 'false'.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of an ASN.1 type BOOLEAN in its encoded form
object - visit an object of ASN.1 type BOOLEAN
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1BitString value,
                              java.lang.Object object)
                       throws VisitorException
Currently we only support the basic BIT STRING type, no NamedBitList toolkit support at this point in time. Encode the bits of the BIT STRING as a string of ones and zeroes with no trailing bits.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type BIT STRING in its encoded form
object - visit an object of ASN.1 type BIT STRING
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1Choice value,
                              java.lang.Object object)
                       throws VisitorException
Encode the value of the chosen field.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of some ASN.1 CHOICE type in its encoded form
object - visit an object of the ASN.1 CHOICE type
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1Enumerated value,
                              java.lang.Object object)
                       throws VisitorException
Always print the named number as an empty tag.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type ENUMERATED in its encoded form
object - visit an object of ASN.1 type ENUMERATED
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1GeneralizedTime value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type GeneralizedTime visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type GeneralizedTime in its encoded form
object - visit an object of ASN.1 type GeneralizedTime
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1Integer value,
                              java.lang.Object object)
                       throws VisitorException
An integer value that is not part of a NamedNumberList must be of the format SignedNumber: 0 | -n | n. The minus sign must not be present if the value of the Number is 0.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type INTEGER in its encoded form
object - visit an object of ASN.1 type INTEGER
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1Null value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type NULL visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type NULL in its encoded form
object - visit an object of ASN.1 type NULL
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1ObjectIdentifier value,
                              java.lang.Object object)
                       throws VisitorException
We always encode the value of an OBJECT-IDENTIFIER using the XMLNumberForm ( dot notation ). i.e.: 1.2.3.4

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type OBJECT IDENTIFIER in its encoded form
object - visit an object of ASN.1 type OBJECT IDENTIFIER
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1OctetString value,
                              java.lang.Object object)
                       throws VisitorException
Print as a string of hex characters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type OCTET STRING in its encoded form
object - visit an object of ASN.1 type OCTET STRING
Throws:
VisitorException

visit

public java.lang.Object visit(XEROctetString value,
                              java.lang.Object object)
                       throws VisitorException
TODO: description goes here

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type OCTET STRING in its XER encoded form
object - visit an object of ASN.1 type OCTET STRING
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1RelativeOID value,
                              java.lang.Object object)
                       throws VisitorException
We always encode the value of an OBJECT-IDENTIFIER using the XMLNumberForm ( dot notation ). i.e.: 1.2.3.4

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type RELATIVE_OID in its encoded form
object - visit an object of ASN.1 type RELATIVE_OID
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1Sequence value,
                              java.lang.Object object)
                       throws VisitorException
BXER: Components of a sequence which have a default value set may or may not be encoded at the sender's option. Currently, we default to always encoding default values. CXER: All components of a sequence which have default values, and which have an abstract value set to those default values, shall have the encoding of the default value textually present. There shall always be an encoding for those components. NOTE: DEFAULT values are ALWAYS OPTIONAL if optional: if default: if value == null: encode default value else: encode value else: if value == null: do nothing else: encode value else: if value != null: encode value else: throw exception

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type SEQUENCE in its encoded form
object - visit an object of ASN.1 type SEQUENCE
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1SequenceOf value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 SEQUENCE OF type visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type SEQUENCE OF in its encoded form
object - visit an object of ASN.1 type SEQUENCE OF
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1SetOf value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 SET OF type visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type SET OF in its encoded form
object - visit an object of ASN.1 type SET OF
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1OpenType value,
                              java.lang.Object object)
                       throws VisitorException
If the OpenType contains a decoded ASN.1 value, then encode the contained value, otherwise assume that the user has provided a correctly encoded value and copy that value into the output stream.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of an ASN.1 type in its encoded form (an open type)
object - visit an object of the ASN.1 open type
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1VisibleString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type VisibleString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type VisibleString in its encoded form
object - visit an object of ASN.1 type VisibleString
Throws:
VisitorException

printDefaultValue

protected void printDefaultValue(ASN1Value value,
                                 Field fieldInfo)
                          throws EncodingException
Throws:
EncodingException

printArcs

protected void printArcs(int[] arcs,
                         java.lang.String name)

visit

public java.lang.Object visit(ASN1BMPString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type BMPString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type BMPString in its encoded form
object - visit an object of ASN.1 type BMPString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1GeneralString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type GeneralString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type GeneralString in its encoded form
object - visit an object of ASN.1 type GeneralString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1IA5String value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type IA5String visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type IA5String in its encoded form
object - visit an object of ASN.1 type IA5String
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1ISO646String value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type ISO646String visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type ISO646String in its encoded form
object - visit an object of ASN.1 type ISO646String
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1NumericString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type NumericString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type NumericString in its encoded form
object - visit an object of ASN.1 type NumericString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1PrintableString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type PrintableString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type PrintableString in its encoded form
object - visit an object of ASN.1 type PrintableString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1T61String value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type T61String visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type T61String in its encoded form
object - visit an object of ASN.1 type T61String
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1TeletexString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type TeletexString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type TeletexString in its encoded form
object - visit an object of ASN.1 type TeletexString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1UniversalString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type UniversalString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type UniversalString in its encoded form
object - visit an object of ASN.1 type UniversalString
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1UTF8String value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type UTF8String visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type UTF8String in its encoded form
object - visit an object of ASN.1 type UTF8String
Throws:
VisitorException

visit

public java.lang.Object visit(ASN1VideotexString value,
                              java.lang.Object object)
                       throws VisitorException
Description copied from interface: ValueVisitor
An ASN.1 type VideotexString visit method with value and object parameters.

Specified by:
visit in interface ValueVisitor
Parameters:
value - a value of ASN.1 type VideotexString in its encoded form
object - visit an object of ASN.1 type VideotexString
Throws:
VisitorException

XCMS Toolkit


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