org.jscience.ml.openmath.codec
Class Codec

java.lang.Object
  extended by org.jscience.ml.openmath.codec.Codec

public abstract class Codec
extends java.lang.Object

A String based codec that translates (XML-encoded) OpenMath objects to their backengine equivalent.


Field Summary
protected  java.util.Hashtable mCDs
          Stores the CD's supported by the codec.
 
Constructor Summary
Codec()
          Constructor.
 
Method Summary
 void addCD(java.lang.String name, java.lang.String location, java.lang.String className)
          Adds a CD to the Codec.
abstract  java.lang.String decode(java.lang.String syntax)
          Decodes the backengine syntax to an OpenMath object in XML encoding.
abstract  OMObject decodeOMObject(java.lang.String syntax)
          Decodes the backengine-syntax to an OM-object.
abstract  java.lang.String encode(java.lang.String object)
          Encodes the XML-encoded OM-object.
abstract  java.lang.String encodeOMObject(OMObject object)
          Encodes the OM-object to backengine-syntax.
 void removeCD(java.lang.String name)
          Removes a CD from the Codec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCDs

protected java.util.Hashtable mCDs
Stores the CD's supported by the codec.

This hashtable is used to support CD's that are not defined in the core set of CD's. Note that if you put a CD which belongs to the core in this hashtable it IS used.

Constructor Detail

Codec

public Codec()
Constructor.

Method Detail

addCD

public void addCD(java.lang.String name,
                  java.lang.String location,
                  java.lang.String className)
           throws CodecException
Adds a CD to the Codec.

Parameters:
name - the name of the CD.
location - the URL of the CD, if none is given it is assume to be on the classpath
className - the Codec of the CD.
Throws:
CodecException - when adding the CD (Codec) failed.

removeCD

public void removeCD(java.lang.String name)
              throws CodecException
Removes a CD from the Codec.

Parameters:
name - the name of the CD.
Throws:
CodecException - when removing the CD (Codec) failed.

encode

public abstract java.lang.String encode(java.lang.String object)
                                 throws CodecEncodeException
Encodes the XML-encoded OM-object.

Parameters:
object - the OpenMath object in XML encoding to encode.
Returns:
the encoding for the command.
Throws:
CodecEncodeException - when a problem arises during encoding.

encodeOMObject

public abstract java.lang.String encodeOMObject(OMObject object)
                                         throws CodecEncodeException
Encodes the OM-object to backengine-syntax.

Parameters:
object - the OpenMath object to encode.
Returns:
the encoding for the OpenMath object.
Throws:
CodecEncodeException - when a problem arises during encoding.

decode

public abstract java.lang.String decode(java.lang.String syntax)
                                 throws CodecDecodeException
Decodes the backengine syntax to an OpenMath object in XML encoding.

Parameters:
syntax - the syntax to decode to an OpenMath object in XML encoding.
Returns:
the OpenMath object in XML encoding.
Throws:
CodecDecodeException - when a problem arises during decoding.

decodeOMObject

public abstract OMObject decodeOMObject(java.lang.String syntax)
                                 throws CodecDecodeException
Decodes the backengine-syntax to an OM-object.

Parameters:
syntax - the syntax to decode to an OpenMath object.
Returns:
the OpenMath object.
Throws:
CodecDecodeException - when a problem arises during decoding.