1 /*
2 * Copyright 2006 Werner Guttman
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.exolab.castor.xml;
17
18 import org.exolab.castor.mapping.FieldDescriptor;
19
20 /**
21 * Internal class used to save state for reference resolution.
22 * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a>
23 * @version $Revision: 0000 $ $Date:$
24 */
25 class ReferenceInfo {
26
27 /** The ID(REF) value of the target object instance. */
28 private final String id;
29 /** The target object referenced by this IDREF instance. */
30 private final Object target;
31 /** XML Field descriptor referenced by this IDREF instance. */
32 private final XMLFieldDescriptor descriptor;
33
34 /** The 'next' ReferenceInfo instance. */
35 private ReferenceInfo next = null;
36
37 /**
38 * Creates a new {@link ReferenceInfo}.
39 * @param id The identity of this XML ID reference instance.
40 * @param target The target object referenced by this IDREF instance.
41 * @param descriptor The {@link XMLFieldDescriptor} for the target object.
42 */
43 public ReferenceInfo(final String id, final Object target, final XMLFieldDescriptor descriptor) {
44 this.id = id;
45 this.target = target;
46 this.descriptor = descriptor;
47 }
48
49 /**
50 * Sets a reference to the 'next' ReferenceInfo instance.
51 * @param info The 'next' ReferenceInfo instance.
52 */
53 public void setNext(ReferenceInfo info) {
54 this.next = info;
55 }
56
57 /**
58 * Returns the field descriptor referenced by this IDREF instance.
59 * @return the field descriptor referenced by this IDREF instance.
60 */
61 public FieldDescriptor getDescriptor() {
62 return this.descriptor;
63 }
64
65 /**
66 * Returns the target object referenced by this IDREF instance.
67 * @return the target object referenced by this IDREF instance.
68 */
69 public Object getTarget() {
70 return this.target;
71 }
72
73 /**
74 * Returns the next 'ReferenceInfo' instance.
75 * @return the next 'ReferenceInfo' instance.
76 */
77 public ReferenceInfo getNext() {
78 return this.next;
79 }
80
81 /**
82 * Returns the ID value of the target object instance.
83 * @return the ID value of the target object instance.
84 */
85 public String getId() {
86 return this.id;
87 }
88
89 }