Class Codec

java.lang.Object
org.episteme.core.mathematics.loaders.openmath.codec.Codec

public abstract class Codec extends Object
A String based codec that translates (XML-encoded) OpenMath objects to their backengine equivalent.

Version:
$Revision: 1.2 $
Author:
Manfred N. Riem (mriem@manorrock.org)
  • Field Details

    • mCDs

      protected Hashtable<String,String> 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 Details

    • Codec

      public Codec()
      Constructor.

  • Method Details

    • addCD

      public void addCD(String name, String location, 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(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 String encode(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 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 String decode(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(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.