KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > accesslayer > QueryCustomizerDefaultImpl


1 package org.apache.ojb.broker.accesslayer;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
19 import java.util.Map JavaDoc;
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
35     private Map JavaDoc m_attributeList = null;
36
37     /**
38      * Default Constructor
39      */

40     public QueryCustomizerDefaultImpl()
41     {
42         super();
43     }
44
45     /**
46      * Default implementation returns unmodified original Query
47      *
48      * @see org.apache.ojb.broker.accesslayer.QueryCustomizer#customizeQuery
49      */

50     public Query customizeQuery(Object JavaDoc anObject, PersistenceBroker aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
51     {
52         return aQuery;
53     }
54
55
56     /**
57      * @see org.apache.ojb.broker.metadata.AttributeContainer#addAttribute(String, String)
58      */

59    public void addAttribute(String JavaDoc attributeName, String JavaDoc attributeValue)
60    {
61         if (attributeName==null)
62         {
63             return;
64         }
65         if (m_attributeList==null)
66         {
67             m_attributeList=new HashMap JavaDoc();
68         }
69        m_attributeList.put(attributeName,attributeValue);
70     }
71
72     /* (non-Javadoc)
73      * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String, java.lang.String)
74      */

75     public String JavaDoc getAttribute(String JavaDoc attributeName, String JavaDoc defaultValue)
76     {
77         String JavaDoc result = defaultValue;
78         if (m_attributeList!=null)
79         {
80             result = (String JavaDoc)m_attributeList.get(attributeName);
81             if (result==null)
82             {
83                 result = defaultValue;
84             }
85         }
86         return result;
87     }
88
89     /* (non-Javadoc)
90      * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String)
91      */

92     public String JavaDoc getAttribute(String JavaDoc attributeName)
93     {
94         return this.getAttribute(attributeName,null);
95     }
96
97 }
98
Popular Tags