01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.compass.core.mapping.osem;
18:
19: import org.compass.core.mapping.Mapping;
20: import org.compass.core.mapping.OverrideByNameMapping;
21:
22: /**
23: * @author kimchy
24: */
25: public class ReferenceMapping extends AbstractRefAliasMapping implements
26: OverrideByNameMapping, HasRefAliasMapping {
27:
28: private String refCompAlias;
29:
30: private ClassMapping refCompMapping;
31:
32: protected void copy(ReferenceMapping copy) {
33: super .copy(copy);
34: copy.setRefCompAlias(getRefCompAlias());
35: copy.setRefCompMapping(getRefCompMapping());
36: }
37:
38: public Mapping copy() {
39: ReferenceMapping copy = new ReferenceMapping();
40: copy(copy);
41: return copy;
42: }
43:
44: public boolean canBeCollectionWrapped() {
45: return true;
46: }
47:
48: public boolean isOverrideByName() {
49: return true;
50: }
51:
52: public void setOverrideByName(boolean overrideByName) {
53: throw new IllegalArgumentException(
54: "The reference mapping always overrides");
55: }
56:
57: public String getRefCompAlias() {
58: return refCompAlias;
59: }
60:
61: public void setRefCompAlias(String refCompAlias) {
62: this .refCompAlias = refCompAlias;
63: }
64:
65: public ClassMapping getRefCompMapping() {
66: return refCompMapping;
67: }
68:
69: public void setRefCompMapping(ClassMapping refCompMapping) {
70: this.refCompMapping = refCompMapping;
71: }
72: }
|