ilog.cpl.model
Class IlpDefaultClassManager

java.lang.Object
  extended by ilog.cpl.model.IlpDefaultClassManager
All Implemented Interfaces:
IlpClassManager, IlpMutableClassManager
Direct Known Subclasses:
IltDefaultClassManager

public class IlpDefaultClassManager
extends Object
implements IlpMutableClassManager

Defines a default implementation for the class manager.

This default implementation stores dynamic classes and makes it possible to load classes from XML files. It supports predefined business classes, that is, Java classes with a static IlpClass getIlpClass() method.

This class manager also creates dynamic classes to represent JavaBean classes using introspection. It automatically creates IlpClass instances to wrap Java classes when the getClass method is called.

It also provides a default class manager reference, which is verified when a dynamic class cannot be found locally.

Since:
JTGO 3.0

Constructor Summary
IlpDefaultClassManager()
          Creates a new class manager for the default application context.
IlpDefaultClassManager(IlpContext c)
          Creates a new class manager for the given context.
 
Method Summary
 void addClass(IlpClass aClass)
          Adds a class to this manager.
protected  void fetchPredefinedClasses()
          Fetches the predefined classes.
protected  void fetchPredefinedClassesOnce()
          This method must be called at the beginning of each get or add method.
 IlpClass getClass(Class aClass)
          Retrieves the dynamic class corresponding to the specified Java class.
 IlpClass getClass(String name)
          Returns the class specified by name.
 Collection getClasses()
          Returns the classes of the model as a Collection.
 IlpClassManager getDefaultClassManager()
          Retrieves the default class manager.
 Collection getRootClasses()
          Returns the root classes of the model in a collection of IlpClass instances.
 boolean hasClass(IlpClass aClass)
          Returns true if the given class belongs to this model.
 boolean hasClass(String name)
          Returns whether a class with the given name is registered or not in the manager.
 void parse(String uri, IlpTypeConverter typeConverter, IlpURLAccessService urlAccessService)
          Parses an XML document containing a model from a system identifier (URI).
 void parse(String uri, IlpTypeConverter typeConverter, IlpURLAccessService urlAccessService, boolean validate)
          Parses an XML document containing a model from a system identifier (URI).
 void removeClass(IlpClass aClass)
          Removes a class from this manager.
 void removeClass(String name)
          Remove the class with the given name from this manager.
 void setDefaultClassManager(IlpClassManager defaultManager)
          Sets the default class manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpDefaultClassManager

public IlpDefaultClassManager()
Creates a new class manager for the default application context.


IlpDefaultClassManager

public IlpDefaultClassManager(IlpContext c)
Creates a new class manager for the given context.

Parameters:
c - Application context
Since:
JTGO 4.0
Method Detail

getDefaultClassManager

public IlpClassManager getDefaultClassManager()
Retrieves the default class manager. This default manager is used to retrieve class information when it cannot be found in this instance.


setDefaultClassManager

public void setDefaultClassManager(IlpClassManager defaultManager)
Sets the default class manager. This default manager is used to retrieve class information when it cannot be found in this instance.


getRootClasses

public Collection getRootClasses()
Returns the root classes of the model in a collection of IlpClass instances. Root classes are classes that do not inherit from another class.

Specified by:
getRootClasses in interface IlpClassManager
Returns:
A Collection containing the root classes of the model.
See Also:
IlpClass

getClasses

public Collection getClasses()
Returns the classes of the model as a Collection.

Specified by:
getClasses in interface IlpClassManager
Returns:
All the classes of the model in a Collection.
See Also:
IlpClass

getClass

public IlpClass getClass(String name)
Returns the class specified by name. If there is no class called name, this method will try to load the corresponding Java class using the Class Loader Service (see (@link ilog.cpl.service.IlpClassLoaderService}). If there is such a Java class: if this Java class has a static IlpClass GetIlpClass() method, the returned IlpClass is added to the current class manager. Otherwise, the class is considered to be a JavaBean and is wrapped in an IlpBeansClass.

Specified by:
getClass in interface IlpClassManager
Parameters:
name - The name of the class to be retrieved.
Returns:
The class specified by name or null if this class does not exist.
See Also:
IlpBeansClass

hasClass

public boolean hasClass(IlpClass aClass)
Returns true if the given class belongs to this model.

Specified by:
hasClass in interface IlpClassManager
Parameters:
aClass - The class being checked.
Returns:
true if the class belongs to the model.
Throws:
IllegalArgumentException - if the given class is null.

addClass

public void addClass(IlpClass aClass)
Adds a class to this manager.

Specified by:
addClass in interface IlpMutableClassManager
Parameters:
aClass - The class being added.

removeClass

public void removeClass(IlpClass aClass)
Removes a class from this manager.

Specified by:
removeClass in interface IlpMutableClassManager
Parameters:
aClass - The class being removed.

getClass

public IlpClass getClass(Class aClass)
Retrieves the dynamic class corresponding to the specified Java class. This method is equivalent to getClass(aClass).

Returns:
The corresponding IlpClass or null.
See Also:
getClass(String)

removeClass

public void removeClass(String name)
Remove the class with the given name from this manager.

Parameters:
name - Name of the class that will be removed
Throws:
IllegalArgumentException - if the given class name is invalid.

hasClass

public boolean hasClass(String name)
Returns whether a class with the given name is registered or not in the manager.

Note that calling this method is not equivalent to getClass(name) != null, as it will not look for a Java class with the given name.

Specified by:
hasClass in interface IlpClassManager
Parameters:
name - The name of the class.
Returns:
true if a class with the given name is registered, or false otherwise.
See Also:
getClass(String)

fetchPredefinedClassesOnce

protected void fetchPredefinedClassesOnce()
This method must be called at the beginning of each get or add method. It calls fetchPredefinedClasses() the first time it is invoked. If you redefine a method of this class, or write new methods that access the classes in your own class manager implementation, call this method before your methods.


fetchPredefinedClasses

protected void fetchPredefinedClasses()
Fetches the predefined classes.

This method is called once before any other method returns.

You may want to redefine this method to register, as soon as possible, your own predefined classes. This method is useful if you need to display a list of whole classes, for example.

To register a Java class as an IlpClass, call the getClass(your class.class.getName()); method.

Note that, if you redefine this method, do not forget to call the super class method.

Note also that usually classes do not need to be registered as soon as possible for the class manager to behave well, except if you need to display a list of them.

See Also:
getClass(String)

parse

public void parse(String uri,
                  IlpTypeConverter typeConverter,
                  IlpURLAccessService urlAccessService)
           throws IOException,
                  SAXException
Parses an XML document containing a model from a system identifier (URI).

If the system identifier is a URL, it does not have to be fully resolved by the application before it is passed to the parser.

Parameters:
uri - The URI.
typeConverter - The type converter used to load the XML document.
urlAccessService - The URL access service used to resolve the URI.
Throws:
SAXException - which is any SAX exception, possibly wrapping another exception.
IOException - which is an IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See Also:
IlpURLAccessService

parse

public void parse(String uri,
                  IlpTypeConverter typeConverter,
                  IlpURLAccessService urlAccessService,
                  boolean validate)
           throws IOException,
                  SAXException
Parses an XML document containing a model from a system identifier (URI).

If the system identifier is a URL, it does not have to be fully resolved by the application before it is passed to the parser.

Parameters:
uri - The URI.
typeConverter - The type converter used to load the XML document.
urlAccessService - The URL access service used to resolve the URI.
validate - Validates or not the XML document.
Throws:
SAXException - which is any SAX exception, possibly wrapping another exception.
IOException - which is an IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
Since:
JViews 8.0
See Also:
IlpURLAccessService


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.