]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/PropertyDiff.java
Add JCR MVC
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / PropertyDiff.java
1 package org.argeo.jcr;
2
3 import javax.jcr.Value;
4
5 import org.argeo.ArgeoException;
6
7 /** The result of the comparison of two JCR properties. */
8 public class PropertyDiff {
9 public final static Integer MODIFIED = 0;
10 public final static Integer ADDED = 1;
11 public final static Integer REMOVED = 2;
12
13 private final Integer type;
14 private final String relPath;
15 private final Value referenceValue;
16 private final Value newValue;
17
18 public PropertyDiff(Integer type, String relPath, Value referenceValue,
19 Value newValue) {
20 super();
21
22 if (type == MODIFIED) {
23 if (referenceValue == null || newValue == null)
24 throw new ArgeoException(
25 "Reference and new values must be specified.");
26 } else if (type == ADDED) {
27 if (referenceValue != null || newValue == null)
28 throw new ArgeoException(
29 "New value and only it must be specified.");
30 } else if (type == REMOVED) {
31 if (referenceValue == null || newValue != null)
32 throw new ArgeoException(
33 "Reference value and only it must be specified.");
34 } else {
35 throw new ArgeoException("Unkown diff type " + type);
36 }
37
38 if (relPath == null)
39 throw new ArgeoException("Relative path must be specified");
40
41 this.type = type;
42 this.relPath = relPath;
43 this.referenceValue = referenceValue;
44 this.newValue = newValue;
45 }
46
47 public Integer getType() {
48 return type;
49 }
50
51 public String getRelPath() {
52 return relPath;
53 }
54
55 public Value getReferenceValue() {
56 return referenceValue;
57 }
58
59 public Value getNewValue() {
60 return newValue;
61 }
62
63 }