Datatype Value

The primary purpose of a datatype is to store a value to represent a quantity. This value might be a single item, or it might be composed of a set of items (e.g., Red, Green, and Blue intensities for color). The value is considered to be a single quantity. Isight parameters represent their values through a Value object that is specific to the selected datatype. For more information on creating a Datatype Value, contact your SIMULIA representative.

The Value for a datatype is provided by composing a Java class to get, set, and store the value.

The main requirement that must be adhered to is that your Value must implement an Isight-provided interface com.engineous.sdk.vars.Value, which also requires implementing the Java Cloneable interface (to allow copying the Value) and Comparable interface (to allow comparing Values and sorting them). However, the Isight SDK also provides an abstract class, com.engineous.sdk.vars.AbstractValue, that you can extend to allow you to implement only the methods you need.

It is recommended that you extend the AbstractValue class rather than directly implement the Value interface to minimize the code that you must write and help protect your code from any future changes in the Value interface.

The primary methods that must be implemented are:

  • setDefaultValue. Sets the value of this object to a known valid default value.

  • assignFrom. Assigns the value of this Value object from another Value object.

  • compareTo. Compares this Value to another Value and returns an integer indicating which one is “greater” or if they are “equal.”

  • isNumericallyRepresentable. Returns the following:

  • whether or not this datatype can be represented entirely by a single numeric value.
  • All the getAsReal and getAsInt methods return values and do not throw exceptions.
  • store. Generates a string representation of this value for persistent storage.

  • restore. Restores the state of this Value from a string generated by store().

The following methods are also available to implement depending on whether you want to customize them for your datatype or just use the default implementation:

  • getAsReal/Int/String/Boolean/Object. Returns the value of this Value object represented as a double-precision real, long, string, Boolean, and object. The implementations in AbstractValue throw UnsupportedOperation exceptions, forcing you to implement each one of these that are valid for your datatype.

  • setValue. This method has multiple signatures that take a value in as a real, long, string, Boolean, or object to complement the get methods. The implementations in AbstractValue throw UnsupportedOperation exceptions, forcing you to implement each one of these that are valid for your datatype.

  • mapFrom. Executes the mapping function for this value type. For most common datatypes this method is the same as assignFrom(). The AbstractValue implementation of this method is to call assignFrom(). Most Value objects will not need to override this method.

  • storeBin. Generates an array of binary object values that represent the value of this Value object for database persistent storage. The default implementation uses the String representation returned by the store() method. For some data types this method may result in inefficient database storage. If there is not sufficient database storage, the datatype should override this method and the restoreBin() method to provide binary persisted data formats. See the javadoc descriptions for the Value interface storeBin(), restoreBin(), and storeBinTypes() methods for more details on binary storage formats.

  • restoreBin. Restores the state of this Value from an object array generated by storeBin().

Typically, you will provide other methods specific to your datatype to get and set the various items that compose the Value of your datatype (e.g., setRedIntensity, getRedIntensity for a Color Datatype). Because these methods will be specific to this datatype, components that want to make use of them will need to cast the Value object to the specific Value object for this datatype to have access to these methods. For example,

Value theValue = var.getValueObj();
ColorValue theColorValue = (ColorValue)theValue;
theColorValue.setRedIntensity(123);

The Plate Example

Recall the Material Datatype that you are creating, as described at the beginning of this section. The Value should store the name, density, modulus of elasticity, and the coefficient of thermal expansion. The primary means of addressing a Material should be through its name; the other quantities should be information specific to the named Material. The methods for a Value object are listed above.