|
Maatri 0.4 (Build 905) Embeddable Database Engine |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MaatriPersistable
Maatri Embeddable Database Engine
provides a minimally intrusive mechanism for primary applications to enable object persistance via the MaatriPersistable
interface.
Objects deemed to be persisted need to implement this interface.
The interface offers granular degree of control on object persistance.
Designers can pick-and-choose persistable fields in the target class, relevant to the requirement.
declareXXX
methods.
import com.bittecsystems.Maatri.*; public class dataObject implements MaatriPersistable { //persistable data private String digits = "", numbers = ""; ...
The candidate class intends to persist a number expressed as digit(s) and its corresponding english word(s), as two separate String
fields, that is, digits
and numbers
.
//helper data private String[] sNumbers = {"ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"}; private String[] sDigits = {"0","1","2","3","4","5","6","7","8","9"}; public dataObject(){} public dataObject(int iD){ init(iD);} private void init(int iD) { String s = new Integer(iD).toString(); for(int i=0; i < s.length(); i++){ numbers = numbers + sNumbers[ Integer.parseInt( s.substring(i,i+1) ) ] + " "; }//for for(int i=0; i < s.length(); i++){ digits = digits + sDigits[ Integer.parseInt( s.substring(i,i+1) ) ]; }//for } ...
The class is passed an integer and it converts the same into persistable fields by looking-up in the corresponding String
arrays.
... //setters public void setNumbers(String s){ numbers = s; } public void setDigits(String s){ digits = s; } //getters public String getNumbers(){ return numbers; } public String getDigits(){ return digits; } ...
The methods, stated above, either populate the object with data retrieved from persistance or return data from the object for persistance.
The Maatri Embeddable Database Engine
eventually calls these methods to provide storage and query functionalities.
... //implemented methods of interface public String[] declareGetDataMethods() { String[] s = {"getDigits","getNumbers"}; return s; } public String[] declareSetDataMethods() { String[] s = {"setDigits","setNumbers"}; return s; } public String[] declareIndexMethods() { String[] s = {"getDigits"}; return s; } ...
The declareXXX
methods must return String
arrays of method-names from the candidate class.
In this example, these method-names are "setDigits", "setDesc", "getDigits"
and "getDesc"
.
Method Summary | |
---|---|
java.lang.String[] |
declareGetDataMethods()
Implement persistable data via list of getter method-name(s). |
java.lang.String[] |
declareIndexMethods()
Implement index-candidate persistable data via list of getter method-names. |
java.lang.String[] |
declareSetDataMethods()
Implement persistable data via list of setter method-name(s). |
Method Detail |
---|
java.lang.String[] declareGetDataMethods()
Implement persistable data via list of getter method-name(s).
The implementation must return a String
array of getter method-name(s).
public String[] declareGetDataMethods() { String[] s = {"getDigits","getNumbers"}; //multiple getter method return s; }
The return data-type of the getter-method(s) must be one of the valid data-types.
byte
- Byte primitive.character
- Character primitive.short
- Short primitive.int
- Integer primitive.long
- Long primitive.float
- Float primitive.double
- Double primitive.Byte
- Object of the type java.lang.Byte
.Character
- Object of the type java.lang.Character
.Short
- Object of the type java.lang.Short
.Integer
- Object of the type java.lang.Integer
.Long
- Object of the type java.lang.Long
.Float
- Object of the type java.lang.Float
.Double
- Object of the type java.lang.Double
.String
- Object of the type java.lang.String
.Java Primitive
- Arrays of Java primitive data-types listed under Valid data-types: Java Primitives
.Java Object
- Arrays of Java object data-types listed in Valid data-types: Java Objects
.
The returned array cannot not be null
and cannot be of zero length.
Getter method must not have any parameters.
String
array of getter method-namesjava.lang.String[] declareSetDataMethods()
Implement persistable data via list of setter method-name(s).
The implementation must return a String
array of setter method-name(s).
public String[] declareSetDataMethods() { String[] s = {"setDigits","setNumbers"}; //multiple setter methods return s; }
The data-type of the parameter in setter-method(s) must be one of the valid data-types.
Typically setter methods are functional reciprocals of getter methods.
Since getter methods return only one set of data, it is expected that setter methods are passed only one parameter.
Valid data-types are listed under declareGetDataMethods
.
The returned array cannot not be null
and cannot be of zero length.
Setter method must have only one parameter.
String
array of setter method-namesdeclareGetDataMethods
java.lang.String[] declareIndexMethods()
Implement index-candidate persistable data via list of getter method-names.
The implementation must return a String
array of getter method-names.
public String[] declareIndexMethods() { String[] s = {"getDigits"}; //single getter method return s; }
The return data-types of the index-candidate getter-methods must be one of the valid data-types.
Valid data-types are listed under declareGetDataMethods
.
declareIndexMethods
does not allow following as the index-candidates:Long
and Double
data-types
However, it is allowable to return multiple getter methods added into the return String
array, as listed in the code for declareGetDataMethods
.
Indexing logic parses the data returned by each getter method, in the sequence arranged in the returned String
array - left to right, and creates an appropriate hash key.
It is allowable to mix return data-types where declareIndexMethods
is required to return multiple getter methods.
All return data-types must be valid data-types as stated under declareGetDataMethods
.
null
and cannot be of zero length. Getter method must not have any parameters.
String
array of getter method-name(s)declareGetDataMethods
|
Maatri 0.4 (Build 905) Embeddable Database Engine |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |