01: /*
02: * Created on Nov 22, 2004
03: */
04: package uk.org.ponder.mapping;
05:
06: /**
07: * Encodes a primitive operation on an abstract bean model, consisting of either
08: * the attachment or detachment of an object appearing at a particular bean
09: * path.
10: * @author Antranig Basman (antranig@caret.cam.ac.uk)
11: *
12: */
13: public class DataAlterationRequest {
14: public static final String ADD = "add";
15: public static final String DELETE = "delete";
16:
17: /** A Distinguished value for the field "data" which determines that the
18: * the value will not apply. However the DAR will proceed through the applier
19: * in order that any guards may execute.
20: */
21: public static final Object INAPPLICABLE_VALUE = new String(
22: "Inapplicable Value");
23: /** The EL path to which the object value is to be delivered, or to be
24: * deleted from.
25: */
26: public String path;
27: /** In the case of an ADD request, the value to be added. In the case of a
28: * DELETE request, can be null if the path designates a Map property,
29: * in which case the final path component will be used as the key to be deleted.
30: * If the path designates a java.util.Collection, the object will be used as
31: * the argument to the remove() method, in which case reasonable Object
32: * equality semantics must have been provided.
33: */
34: public Object data;
35: /** Whether any data conversions should be considered when applying the
36: * request */
37: public boolean applyconversions = true;
38: /** The type of the request, either an ADD (default) or DELETE.
39: */
40: public String type = ADD;
41:
42: public DataAlterationRequest(String path, Object data) {
43: this .path = path;
44: this .data = data;
45: }
46:
47: public DataAlterationRequest(String path, Object data, String type) {
48: this .path = path;
49: this .data = data;
50: this .type = type;
51: }
52:
53: public static String flattenData(Object data) {
54: String leafdata = data instanceof String[] ? ((String[]) data)[0]
55: : (String) data;
56: return leafdata;
57: }
58: }
|