As J2ME developers we couldn't handle anymore the idea of writing so many code lines to persist so few attributes. For each class we want to persist we had to generate the source code to transform an object into a byte array and vice-versa. We have tried to find free persistence frameworks for this technology on the internet, but we couldn't find one that fitted our needs. So,floggy is your selection.
How to use it ? it is very easy.see below,
public static void saveObject() {
Person person = new Person();
person.setName("LaoLi");
person.setBirthday("1988/8/8");
person.setGender("man");
person.setPhones("13169563289");
try {
int id = PersistableManager.getInstance().save(person);
// Editing and saving a previously saved object
PersistableManager.getInstance().load(person, id);
person.setName("LiLao");
id = PersistableManager.getInstance().save(person);
// Deleting a previously saved object
PersistableManager.getInstance().load(person, id);
PersistableManager.getInstance().delete(person);
}
catch (FloggyException e) {
System.out.println("throw a exception");
e.printStackTrace();
}
// Listing all objects
ObjectSet persons;
try {
persons = PersistableManager.getInstance().find(Person.class, null, null);
for ( int i = 0 ; i < persons.size() ; i++) {
Person person2 = (Person) persons.get(i);
System.out.println("name: " + person2.getName());
}
}
catch (FloggyException e) {
e.printStackTrace();
}
// Using a filter to find specific objects
try {
persons = PersistableManager.getInstance().find(Person.class, new MacFilter(), null);
for ( int i = 0; i< persons.size(); i++) {
Person pers = (Person) persons.get(i);
}
}
catch (FloggyException e) {
e.printStackTrace();
}
// Sorting persons by their age (younger first)
try {
persons = PersistableManager.getInstance().find(Person.class, null, new AgeCompator());
}
catch (FloggyException e) {
e.printStackTrace();
}
}
}
class MacFilter implements Filter{
public boolean matches(Persistable persistable) {
Person person = (Person) persistable;
return person.getGender() == "M";
}
}
class AgeCompator implements Comparator{
public int compare(Persistable p1, Persistable p2) {
Person per = (Person) p1;
Person pers = (Person) p2;
if ( per.getBirthday().length() < pers.getBirthday().length()) { return PRECEDES; }
if ( per.getBirthday().length() > pers.getBirthday().length()) { return FOLLOWS; }
return EQUIVALENT;
}
- floggy1.1.1.rar (616 KB)
- 描述: encourage the usage of the Floggy Eclipse plugin,see http://floggy.sourceforge.net/configuration/eclipse.html
- 下载次数: 8
分享到:
相关推荐
maven-floggy-plugin-1.4.0.jar
maven-floggy-plugin-1.3.1.jar
maven-floggy-plugin-1.3.0.jar
maven-floggy-plugin-1.2.0.jar
maven-floggy-plugin-1.1.1.jar
maven-floggy-plugin-1.1.0.jar
maven-floggy-plugin-1.0.jar
maven-floggy-plugin-1.0.1.jar
maven-floggy-plugin-1.4.0-sources.jar
maven-floggy-plugin-1.3.1-sources.jar
maven-floggy-plugin-1.3.0-sources.jar
maven-floggy-plugin-1.2.0-sources.jar
maven-floggy-plugin-1.1.1-sources.jar
maven-floggy-plugin-1.1.0-sources.jar
maven-floggy-plugin-1.0-sources.jar
maven-floggy-plugin-1.0.1-sources.jar
Floggy is a free object persistence framework for J2ME/MIDP applications. The main goal of this framework is to abstract the data persistence details from the developer, reducing the development and ...
jar包,官方版本,自测可用
jar包,官方版本,自测可用
jar包,官方版本,自测可用