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