Package com.mxgraph.io
Class mxCodecRegistry
- java.lang.Object
-
- com.mxgraph.io.mxCodecRegistry
-
public class mxCodecRegistry extends java.lang.Object
Singleton class that acts as a global registry for codecs. SeemxCodec
for an example.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Hashtable<java.lang.String,java.lang.String>
aliases
Maps from classnames to codecnames.protected static java.util.Hashtable<java.lang.String,mxObjectCodec>
codecs
Maps from constructor names to codecs.protected static java.util.List<java.lang.String>
packages
Holds the list of known packages.
-
Constructor Summary
Constructors Constructor Description mxCodecRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addAlias(java.lang.String classname, java.lang.String codecname)
Adds an alias for mapping a classname to a codecname.static void
addPackage(java.lang.String packagename)
Adds the given package name to the list of known package names.static java.lang.Class<?>
getClassForName(java.lang.String name)
Returns a class that corresponds to the given name.static mxObjectCodec
getCodec(java.lang.String name)
Returns a codec that handles the given object, which can be an object instance or an XML node.static java.lang.Object
getInstanceForName(java.lang.String name)
Creates and returns a new instance for the given class name.static java.lang.String
getName(java.lang.Object instance)
Returns the name that identifies the codec associated with the given instance..static mxObjectCodec
register(mxObjectCodec codec)
Registers a new codec and associates the name of the template constructor in the codec with the codec object.
-
-
-
Field Detail
-
codecs
protected static java.util.Hashtable<java.lang.String,mxObjectCodec> codecs
Maps from constructor names to codecs.
-
aliases
protected static java.util.Hashtable<java.lang.String,java.lang.String> aliases
Maps from classnames to codecnames.
-
packages
protected static java.util.List<java.lang.String> packages
Holds the list of known packages. Packages are used to prefix short class names (eg. mxCell) in XML markup.
-
-
Method Detail
-
register
public static mxObjectCodec register(mxObjectCodec codec)
Registers a new codec and associates the name of the template constructor in the codec with the codec object. Automatically creates an alias if the codename and the classname are not equal.
-
addAlias
public static void addAlias(java.lang.String classname, java.lang.String codecname)
Adds an alias for mapping a classname to a codecname.
-
getCodec
public static mxObjectCodec getCodec(java.lang.String name)
Returns a codec that handles the given object, which can be an object instance or an XML node.- Parameters:
name
- Java class name.
-
addPackage
public static void addPackage(java.lang.String packagename)
Adds the given package name to the list of known package names.- Parameters:
packagename
- Name of the package to be added.
-
getInstanceForName
public static java.lang.Object getInstanceForName(java.lang.String name)
Creates and returns a new instance for the given class name.- Parameters:
name
- Name of the class to be instantiated.- Returns:
- Returns a new instance of the given class.
-
getClassForName
public static java.lang.Class<?> getClassForName(java.lang.String name)
Returns a class that corresponds to the given name.- Parameters:
name
-- Returns:
- Returns the class for the given name.
-
getName
public static java.lang.String getName(java.lang.Object instance)
Returns the name that identifies the codec associated with the given instance.. The I/O system uses unqualified classnames, eg. for acom.mxgraph.model.mxCell
this returnsmxCell
.- Parameters:
instance
- Instance whose node name should be returned.- Returns:
- Returns a string that identifies the codec.
-
-