Skip to content

Instantly share code, notes, and snippets.

@mbruch
Last active December 17, 2015 00:59
Show Gist options
  • Save mbruch/5525065 to your computer and use it in GitHub Desktop.
Save mbruch/5525065 to your computer and use it in GitHub Desktop.
Forms and Database Services API For each class in here: # Copy the raw text of the class, # Select the src folder of com.example.miniscout.shared, # Press ctrl+v to get the class inserted correctly by Eclipse.
package com.example.miniscout.shared;
public class Field {
public Field(String type, String name, String value) {
super();
this.type = type;
this.name = name;
this.value = value;
}
public Field() {
}
public String type;
public String name;
public String value;
}
package com.example.miniscout.shared;
public class Form {
public String name;
public Field[] fields = new Field[0];
}
package com.example.miniscout.shared;
import java.net.URI;
public interface IDatabaseService {
public Form load(URI source) throws Exception;
public void save(Form form, URI target) throws Exception;
}
package com.example.miniscout.client.editor;
import java.net.URI;
import com.example.miniscout.shared.Field;
import com.example.miniscout.shared.Form;
import com.example.miniscout.shared.IDatabaseService;
public class Services {
private static final IDatabaseService INSTANCE = new IDatabaseService() {
// simple "in memory" database. will be replaced by an OSGI service later
@Override
public Form load(URI source) throws Exception {
Form form = new Form();
form.name = "In Memory Form";
form.fields = new Field[] { new Field("string", "forename", "Max"),
new Field("string", "lastname", "Mustermann"),
new Field("string", "street", "Seestraße 7") };
return form;
}
@Override
public void save(Form form, URI target) throws Exception {
// do nothing.
}
};
public static IDatabaseService getDatbaseService() {
return INSTANCE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment