]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.jcr/src/org/argeo/jcr/PropertyDiff.java
Add SFTP support to sync
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / PropertyDiff.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.jcr;
17
18 import javax.jcr.Value;
19
20 /** The result of the comparison of two JCR properties. */
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 }