01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
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: package org.apache.slide.search.basic;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.apache.slide.common.SlideException;
22: import org.apache.slide.common.SlideToken;
23: import org.apache.slide.content.Content;
24: import org.apache.slide.content.NodeProperty;
25: import org.apache.slide.search.PropertyProvider;
26: import org.apache.slide.search.QueryScope;
27: import org.apache.slide.search.SearchToken;
28: import org.apache.slide.structure.ObjectNode;
29:
30: /**
31: * @author Max Pfingsthorn (mpfingsthorn@hippo.nl)
32: *
33: */
34: public class AugmentableComparableResource extends
35: ComparableResourceImpl {
36:
37: public AugmentableComparableResource(ObjectNode objectNode,
38: SearchToken searchToken, QueryScope scope,
39: PropertyProvider propertyProvider) throws SlideException {
40: super (objectNode, searchToken, scope, propertyProvider);
41: }
42:
43: public AugmentableComparableResource(ObjectNode objectNode,
44: SlideToken slideToken, Content contentHelper,
45: QueryScope scope, PropertyProvider propertyProvider)
46: throws SlideException {
47: super (objectNode, slideToken, contentHelper, scope,
48: propertyProvider);
49: }
50:
51: protected Map extraProperties = new HashMap();
52:
53: public void setExtraProperty(String namespace, String name,
54: Object value) {
55: NodeProperty newprop = new NodeProperty(name, value, namespace);
56: extraProperties.put(mangledName(namespace, name), newprop);
57: }
58:
59: public NodeProperty getProperty(String name, String namespace)
60: throws SlideException {
61:
62: String mangled = mangledName(namespace, name);
63: NodeProperty ret = null;
64:
65: if (extraProperties.containsKey(mangled)) {
66: ret = (NodeProperty) extraProperties.get(mangled);
67: } else {
68: ret = super .getProperty(name, namespace);
69: }
70:
71: return ret;
72: }
73:
74: protected String mangledName(String namespace, String name) {
75: return namespace + "#" + name;
76: }
77: }
|