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.engine.naming;
18:
19: /**
20: * A static path construction, which holds a string representation of the
21: * actual path.
22: * <p/>
23: * Benefits of using this implementation is its fast usage during marshalling/
24: * unmarshalling operations. Downside is its memory footprint.
25: *
26: * @author kimchy
27: * @see StaticPropertyNamingStrategy
28: */
29: public class StaticPropertyPath implements PropertyPath {
30:
31: private String path;
32:
33: public StaticPropertyPath(String path) {
34: this .path = path.intern();
35: }
36:
37: public StaticPropertyPath(PropertyPath root, String name) {
38: this .path = root.getPath() + '/' + name;
39: }
40:
41: public String getPath() {
42: return path;
43: }
44:
45: public PropertyPath hintStatic() {
46: return this ;
47: }
48:
49: public int hashCode() {
50: return path.hashCode();
51: }
52:
53: public boolean equals(Object object) {
54: if (this == object) {
55: return true;
56: }
57: if ((null == object) || (!(object instanceof PropertyPath))) {
58: return false;
59: }
60: return path.equals(((PropertyPath) object).getPath());
61: }
62: }
|