]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.server.jcr/src/org/argeo/jcr/PropertyDiff.java
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.jcr
;
18 import javax
.jcr
.Value
;
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;
26 private final Integer type
;
27 private final String relPath
;
28 private final Value referenceValue
;
29 private final Value newValue
;
31 public PropertyDiff(Integer type
, String relPath
, Value referenceValue
,
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.");
48 throw new ArgeoJcrException("Unkown diff type " + type
);
52 throw new ArgeoJcrException("Relative path must be specified");
55 this.relPath
= relPath
;
56 this.referenceValue
= referenceValue
;
57 this.newValue
= newValue
;
60 public Integer
getType() {
64 public String
getRelPath() {
68 public Value
getReferenceValue() {
69 return referenceValue
;
72 public Value
getNewValue() {