Home Up

Pattern
Pattern Data Node and Model Map Algorithm Parameters Events

 

The Pattern Interface

 

The Pattern interface represents a basic unit of data in JSOMap.  Traditionally, a pattern is a numerical vector, like .  However, JSOMap uses a more abstract notion of a pattern.  Thus, things that don’t fit well into a vector, such as a string of characters or a generic set of objects, can use their own custom data structures that implement Pattern.

Figure 1.  UML diagram for the Pattern interface.

To be totally flexible, JSOMap uses an abstract concept of a pattern, represented by the Pattern interface.  An implementation of Pattern is some specific type of pattern.  For instance, DoublePattern could store a double[], IntPattern could store an int[], and any other implementation could store any other type of data unit.  For example, GraphPattern could store some concept of a graph, and could be used in graph matching.

Since Pattern represents an abstract pattern, it cannot specify any type-specific methods, like public double[] getPattern().  Instead, Pattern simply serves as the root interface for any data unit in JSOMap.

Implementations of Pattern should generally be immutable value classes.  This means that once an instance is created it cannot be changed in any way.  To be immutable, a class must

Be declared as final
Have all fields declared as private final
Use defensive copies in constructors and accessor methods

By being immutable, you’re guaranteed that the class is never going to change.  However, this isn’t a strict guideline; immutable classes may be necessary in some cases, like when it’s very expensive to create a new instance.

Implementations of Pattern should generally provide two constructors:

Value constructor
String constructor

The value constructor specifies arguments that can be used to create the Pattern instance.  The string constructor accepts a string representation of the pattern.  Providing the value constructor is commonsense.  Providing the String constructor is an easy way to create patterns from a text data file.

The JSOMap package comes with two implementations of Pattern: DoublePattern and IntegerPattern.  These are basic vector-based implementations that store the actual data in arrays of type double and int, respectively.

Figure 2.  UML diagram for the DoublePattern and IntegerPattern classes. 

 

 

SourceForge.net Logo

Send mail to zcox@iastate.edu with questions or comments about this web site.
Last modified: March 03, 2002