01: package org.apache.ojb.broker.accesslayer;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.apache.ojb.broker.PersistenceBroker;
22: import org.apache.ojb.broker.metadata.CollectionDescriptor;
23: import org.apache.ojb.broker.query.Query;
24: import org.apache.ojb.broker.query.QueryByCriteria;
25:
26: /**
27: * Default Implementation of QueryCustomizer.
28: *
29: * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
30: * @version $Id: QueryCustomizerDefaultImpl.java,v 1.5.2.1 2005/12/21 22:22:58 tomdz Exp $
31: */
32: public class QueryCustomizerDefaultImpl implements QueryCustomizer {
33:
34: private Map m_attributeList = null;
35:
36: /**
37: * Default Constructor
38: */
39: public QueryCustomizerDefaultImpl() {
40: super ();
41: }
42:
43: /**
44: * Default implementation returns unmodified original Query
45: *
46: * @see org.apache.ojb.broker.accesslayer.QueryCustomizer#customizeQuery
47: */
48: public Query customizeQuery(Object anObject,
49: PersistenceBroker aBroker, CollectionDescriptor aCod,
50: QueryByCriteria aQuery) {
51: return aQuery;
52: }
53:
54: /**
55: * @see org.apache.ojb.broker.metadata.AttributeContainer#addAttribute(String, String)
56: */
57: public void addAttribute(String attributeName, String attributeValue) {
58: if (attributeName == null) {
59: return;
60: }
61: if (m_attributeList == null) {
62: m_attributeList = new HashMap();
63: }
64: m_attributeList.put(attributeName, attributeValue);
65: }
66:
67: /* (non-Javadoc)
68: * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String, java.lang.String)
69: */
70: public String getAttribute(String attributeName, String defaultValue) {
71: String result = defaultValue;
72: if (m_attributeList != null) {
73: result = (String) m_attributeList.get(attributeName);
74: if (result == null) {
75: result = defaultValue;
76: }
77: }
78: return result;
79: }
80:
81: /* (non-Javadoc)
82: * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String)
83: */
84: public String getAttribute(String attributeName) {
85: return this.getAttribute(attributeName, null);
86: }
87:
88: }
|