1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.jcr;
17
18 import javax.jcr.Value;
19
20
21 public class PropertyDiff {
22 public final static Integer MODIFIED = 0;
23 public final static Integer ADDED = 1;
24 public final static Integer REMOVED = 2;
25
26 private final Integer type;
27 private final String relPath;
28 private final Value referenceValue;
29 private final Value newValue;
30
31 public PropertyDiff(Integer type, String relPath, Value referenceValue,
32 Value newValue) {
33 super();
34
35 if (type == MODIFIED) {
36 if (referenceValue == null || newValue == null)
37 throw new ArgeoJcrException(
38 "Reference and new values must be specified.");
39 } else if (type == ADDED) {
40 if (referenceValue != null || newValue == null)
41 throw new ArgeoJcrException(
42 "New value and only it must be specified.");
43 } else if (type == REMOVED) {
44 if (referenceValue == null || newValue != null)
45 throw new ArgeoJcrException(
46 "Reference value and only it must be specified.");
47 } else {
48 throw new ArgeoJcrException("Unkown diff type " + type);
49 }
50
51 if (relPath == null)
52 throw new ArgeoJcrException("Relative path must be specified");
53
54 this.type = type;
55 this.relPath = relPath;
56 this.referenceValue = referenceValue;
57 this.newValue = newValue;
58 }
59
60 public Integer getType() {
61 return type;
62 }
63
64 public String getRelPath() {
65 return relPath;
66 }
67
68 public Value getReferenceValue() {
69 return referenceValue;
70 }
71
72 public Value getNewValue() {
73 return newValue;
74 }
75
76 }