Class ClassNameResolver
java.lang.Object
com.inductiveautomation.ignition.common.xmlserialization.ClassNameResolver
Serves as a bidirectional mapping between classes and their names. Supports aliases and package search paths. Also
comes pre-configured with shortened aliases for most common types (primitives, numbers, lists, etc) and search paths
for common java packages like lang, util, awt, swing, beans.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new alias for this class.void
void
addSearchPath
(String path) Deprecated.This functionality is deprecated.final Class
classForName
(String name) Attempts to find the Class for the given name, in the context of any aliases and search paths that have been previously configuredprotected Class
classForNameImpl
(String name) static ClassNameResolver
Returns the inverse ofclassForName(String)
.
-
Constructor Details
-
ClassNameResolver
public ClassNameResolver()
-
-
Method Details
-
createBasic
-
addDefaults
public void addDefaults() -
addAlias
Adds a new alias for this class. This alias takes precedence over a search path. Each alias can only be used once, but an class can have more than one alias. The class will resolve to the first alias (name) added for it. -
addSearchPath
Deprecated.This functionality is deprecated. You can continue to add search paths for the backwards compatibility of de-serializing, but new serialized code will not contain the shortened versions of the classnames.Adds a new search path. For example, if you add the search path of "javax.swing" then the class "javax.swing.JLabel" will map bidirectionally to the string "JLabel" -
getName
Returns the inverse ofclassForName(String)
. That is, the appropriate string for which a call to classForName with the return value of this method would return clazz. Makes use of any configured aliases and search paths, and appropriately encodes array types. -
classForName
Attempts to find the Class for the given name, in the context of any aliases and search paths that have been previously configuredLogic is as follows:
- Look through the aliases for the given name. These can be configured manually (see
addAlias(Class, String)
), and will also be added automatically to act as a cache of any of the following steps find the class. - If the name starts with a "[", get call classForName recursively on name.substring(1) to
find the array component type, and then find the array class using
Array.newInstance(Class, int)
- Try Class.forName(name)
- Look through each search path (see
addSearchPath(String)
, looking for Class.forName(searchPath + "." + name)
- Throws:
ClassNotFoundException
- Look through the aliases for the given name. These can be configured manually (see
-
classForNameImpl
- Throws:
ClassNotFoundException
-