KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > map > ClientObjRelationship


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.map;
21
22 /**
23  * A read-only ObjRelationship relationship that caches some information that is
24  * dynamically calculated in a superclass.
25  *
26  * @since 1.2
27  * @author Andrus Adamchik
28  */

29 class ClientObjRelationship extends ObjRelationship {
30
31     String JavaDoc reverseRelationshipName;
32
33     // note that field names are different from the ones defined by super for the same
34
// property... This is needed so that Hessian sreialization mechanism could work.
35
boolean clientReadOnly;
36     boolean clientToMany;
37
38     ClientObjRelationship(String JavaDoc name, String JavaDoc reverseRelationshipName, boolean toMany,
39             boolean readOnly) {
40
41         super(name);
42         this.clientToMany = toMany;
43         this.clientReadOnly = readOnly;
44         this.reverseRelationshipName = reverseRelationshipName;
45     }
46
47     public boolean isToMany() {
48         return clientToMany;
49     }
50
51     public boolean isReadOnly() {
52         return clientReadOnly;
53     }
54
55     public String JavaDoc getReverseRelationshipName() {
56         return reverseRelationshipName;
57     }
58
59     public ObjRelationship getReverseRelationship() {
60         if (reverseRelationshipName == null) {
61             return null;
62         }
63
64         Entity target = getTargetEntity();
65         if (target == null) {
66             return null;
67         }
68
69         return (ObjRelationship) target.getRelationship(reverseRelationshipName);
70     }
71 }
72
Popular Tags