public interface ValuesCodable
This is an interface you can use to convert a non-codable object to codable. Codable is defined as the ability of an Object to be encoded to an OutputStream or decoded from an InputStream to the original Object value, using the coder classes in the com.wm.util.coder package. You must provide a specific format that allows your derived class to be encoded as a Values object and decoded from a Values object.
Note: Your provided format must contain codable objects. For more information about codable objects, refer to the coder classes in the com.wm.util.coder package.
XMLCoder
,
Codable
,
IDataCodable
,
StringCodable
,
ValuesCodable
Modifier and Type | Method and Description |
---|---|
Values |
getValues()
Generates a Values object that represents the current state of the implementing class.
|
void |
setValues(Values values)
Initializes all class variables from the data values in the specified Values object.
|
Values getValues()
EXAMPLE of a getValues implementation:
public Values getValues() { // convert all the member variables to object types supported by // XMLCoder Object o[][] = { {"type", ienum.getString(getNodeType(),"unknown") }, {"name", nsName != null ? nsName.toString() : null }, {"package", pkg != null ? pkg.getName() : null }, {"comment", comment } }; return new Values(o); }
void setValues(Values values)
The following is an example of a setValues implementation:
public void setValues(Values values) { if (values == null) return; setNodeType (ienum.getInt(values.getString("type"),NODE_UNKNOWN)); // do not call setNSName(nm) since it could trigger an event nsName = NSName.create(values.getString("name")); // set Package if we belong to a Namespace (otherwise meaningless) if (ns != null) setPackage (ns.getPackage(values.getString("package"))); setComment (values.getString("comment")); }The following is a code sample that calls the setValues method.
ValuesCodableClass original = new ValuesCodableClass(myparam1, myparam2) Values v = original.getValues(); ValuesCodableClass newone = new ValuesCodableClass(); newone.setValues(v);
values
- A Values object representing the encoded form of the implementing class.