]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/PropertyDiff.java
2bc4c09a1f69b2e7403616c70a60829bfe7bcf2a
2 * Copyright (C) 2007-2012 Mathieu Baudier
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 import org
.argeo
.ArgeoException
;
22 /** The result of the comparison of two JCR properties. */
23 public class PropertyDiff
{
24 public final static Integer MODIFIED
= 0;
25 public final static Integer ADDED
= 1;
26 public final static Integer REMOVED
= 2;
28 private final Integer type
;
29 private final String relPath
;
30 private final Value referenceValue
;
31 private final Value newValue
;
33 public PropertyDiff(Integer type
, String relPath
, Value referenceValue
,
37 if (type
== MODIFIED
) {
38 if (referenceValue
== null || newValue
== null)
39 throw new ArgeoException(
40 "Reference and new values must be specified.");
41 } else if (type
== ADDED
) {
42 if (referenceValue
!= null || newValue
== null)
43 throw new ArgeoException(
44 "New value and only it must be specified.");
45 } else if (type
== REMOVED
) {
46 if (referenceValue
== null || newValue
!= null)
47 throw new ArgeoException(
48 "Reference value and only it must be specified.");
50 throw new ArgeoException("Unkown diff type " + type
);
54 throw new ArgeoException("Relative path must be specified");
57 this.relPath
= relPath
;
58 this.referenceValue
= referenceValue
;
59 this.newValue
= newValue
;
62 public Integer
getType() {
66 public String
getRelPath() {
70 public Value
getReferenceValue() {
71 return referenceValue
;
74 public Value
getNewValue() {