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 ComponentMapping extends AbstractRefAliasMapping implements
26: OverrideByNameMapping, HasRefAliasMapping {
27:
28: private boolean overrideByName = true;
29:
30: // the depth of cyclic component mappings allowed
31: // set by configuration
32: private int maxDepth = 5;
33:
34: public Mapping copy() {
35: ComponentMapping copy = new ComponentMapping();
36: copy(copy);
37: return copy;
38: }
39:
40: protected void copy(ComponentMapping componentMapping) {
41: super .copy(componentMapping);
42: componentMapping.setOverrideByName(isOverrideByName());
43: componentMapping.setMaxDepth(getMaxDepth());
44: }
45:
46: public boolean canBeCollectionWrapped() {
47: return true;
48: }
49:
50: public boolean isOverrideByName() {
51: return overrideByName;
52: }
53:
54: public void setOverrideByName(boolean overrideByName) {
55: this .overrideByName = overrideByName;
56: }
57:
58: public int getMaxDepth() {
59: return maxDepth;
60: }
61:
62: public void setMaxDepth(int maxDepth) {
63: this.maxDepth = maxDepth;
64: }
65: }
|