org.peace_tools.workspace
Class DBClassifier

java.lang.Object
  extended by org.peace_tools.workspace.DBClassifier

public class DBClassifier
extends java.lang.Object

Database (DB) Classifier to distinguish ESTs from different databases. This class corresponds to a "DBClassifier" element in a PEACE work space XML data. This class encapsulates the core information associated with a classifier. Users create these entries by specifiying a suitable regular expression to identify ESTs from a data base. The data is persisted in the XML workspace for future reference so that users can repeatedly reuse a classifier.


Field Summary
private  int color
          The RGB color code associated with this entry.
private  java.lang.String description
          A user defined description for this DB classifier enttry.
private  boolean enabled
          Flag to indicate if this classifier is enabled and must be used to classify ESTs.
private  java.util.regex.Pattern pattern
          The pre-compiled pattern corresponding to this regular expression.
private  java.lang.String regExp
          The regular expression that is used to identify a given database name.
 
Constructor Summary
DBClassifier(java.lang.String regExp, java.lang.String description, int color, boolean enabled)
          Constructor to create a classifier object with the fixed value fields initialized to specific values.
 
Method Summary
static DBClassifier create(org.w3c.dom.Element jobNode)
          Helper method to utilize data from a DOM tree to create a suitable DBClassifier entry.
 int getColor()
          Obtain the color code for shading database entry.
 java.lang.String getDescription()
          Obtain the user supplied description for this this classifier.
 java.util.regex.Pattern getPattern()
          This method must be used to obtain the pre-compiled pattern associated with this classifier.
 java.lang.String getRegExp()
          Obtain the raw regular expression set for this classifier.
 boolean isEnabled()
          Determine if this classifier is enabled.
 void marshall(org.w3c.dom.Element dbClassList)
          Method to marshall the data stored in this object to become part of a DOM tree element passed in.
 void marshall(java.io.PrintWriter out)
          Method to marshall the data stored in this object directly to a XML fragment.
 void setColor(int color)
          Set a color to shade ESTs identified by this classifier.
 void setDescription(java.lang.String desc)
          Set a description for this entry The description is persisted in the work space configuration file and loaded when a work space is opened in the GUI.
 void setEnabled(boolean enabled)
          Indicate if this classifier must be used to group/classify ESTs.
 void setRegExp(java.lang.String regExp)
          Set the regular expression for this DB Classifier entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

private java.lang.String description
A user defined description for this DB classifier enttry. This description is set when a new classifier entry is created by the user via the GUI. The information is persisted in the work space configuration for future references.


regExp

private java.lang.String regExp
The regular expression that is used to identify a given database name. This information is set when a new classifier entry is created by the user via the GUI. The information is persisted in the work space configuration for future references.


color

private int color
The RGB color code associated with this entry. The color code is marshalled and unmarshalled into hexadecimal codes corresponding to RGB values.


enabled

private boolean enabled
Flag to indicate if this classifier is enabled and must be used to classify ESTs. If a classifier is not enabled, then it is not used for classifying ESTs.


pattern

private transient java.util.regex.Pattern pattern
The pre-compiled pattern corresponding to this regular expression. The pre-compiled pattern is created in a "lazy" manner the first time the getPattern() method is called. The pattern is reset each time the setRegExp() method is invoked.

Constructor Detail

DBClassifier

public DBClassifier(java.lang.String regExp,
                    java.lang.String description,
                    int color,
                    boolean enabled)
Constructor to create a classifier object with the fixed value fields initialized to specific values.

Parameters:
regExp - The regular expression to be associated with the given classifier.
description - A user-supplied description for this entry. This maybe an empty string (but cannot be null).
color - The RGB color code to be associated with this entry.
enabled - Flag to indicate if this classifier is enabled. Only enabled classifiers are used for classifying ESTs.
Method Detail

create

public static DBClassifier create(org.w3c.dom.Element jobNode)
                           throws java.lang.Exception
Helper method to utilize data from a DOM tree to create a suitable DBClassifier entry. This method is typically used to create a suitable entry when loading a Work space into the GUI.

Parameters:
jobNode - The DOM element to be used for creating the classifier entry and populating with the needed data.
Returns:
The newly created classifier entry based on the DOM data.
Throws:
java.lang.Exception - This method throws an exception when errors occur during reading and processing elements from the DOM node.

getDescription

public java.lang.String getDescription()
Obtain the user supplied description for this this classifier. This value is set when new entries are added. The description is persisted in the work space configuration file and loaded when a work space is opened in the GUI.

Returns:
This method returns the user supplied description set for this job.

setDescription

public void setDescription(java.lang.String desc)
Set a description for this entry The description is persisted in the work space configuration file and loaded when a work space is opened in the GUI.

Parameters:
desc -

setRegExp

public void setRegExp(java.lang.String regExp)
Set the regular expression for this DB Classifier entry. This method must be used to set the regular expression to be associated with this classifier entry.

Note: This method resets the pattern associated with this classifier.

Parameters:
regExp - The regular expression to be set for this entry. It is assumed that the regular expression is valid and this method does not perform any specific validation.

getRegExp

public java.lang.String getRegExp()
Obtain the raw regular expression set for this classifier. This method returns the raw string expression set by the user for this classifier. To utilize the compiled regular expression use the getPattern() method in this class.

Returns:
The raw regular expression set for this classifier.

getColor

public int getColor()
Obtain the color code for shading database entry. This value is set when new entries are added. The color is persisted in the work space configuration file and loaded when a work space is opened in the GUI.

Returns:
This method returns the user supplied color to be used to shade the class of ESTs identified by this classifier.

setColor

public void setColor(int color)
Set a color to shade ESTs identified by this classifier. The color is persisted in the work space configuration file and loaded when a work space is opened in the GUI.

Parameters:
color - The RGB color code for the color to shade this data base entry.

isEnabled

public boolean isEnabled()
Determine if this classifier is enabled. Only classifiers that are enabled are to be used for classifying ESTs.

Returns:
This method returns true to indicate that this classifier is enabled.

setEnabled

public void setEnabled(boolean enabled)
Indicate if this classifier must be used to group/classify ESTs.

Parameters:
enabled - If the parameter is true, then this classifier entry will be used for grouping/classifying ESTs.

getPattern

public java.util.regex.Pattern getPattern()
This method must be used to obtain the pre-compiled pattern associated with this classifier. This method creates and returns patterns in a "lazy" manner. A pattern is created the first time this method is called (after the regular expression is changed) and subsequent calls simply return the same pattern.

Returns:
The pre-compiled pattern to be returned back to the caller.

marshall

public final void marshall(org.w3c.dom.Element dbClassList)
Method to marshall the data stored in this object to become part of a DOM tree element passed in. This method assumes that the element passed in corresponds to the parent ClassifierList node in the DOM tree.

Parameters:
dbClassList - The DOM element corresponding to the "DBClassifier" node that contains this entry.

marshall

public final void marshall(java.io.PrintWriter out)
Method to marshall the data stored in this object directly to a XML fragment. The XML fragment is guaranteed to be compatible with the PEACE work space configuration data.

Parameters:
out - The stream to which the XML must be serialized.