001    package org.apache.ojb.broker.accesslayer;
002    
003    /* Copyright 2003-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    import java.util.HashMap;
019    import java.util.Map;
020    
021    import org.apache.ojb.broker.PersistenceBroker;
022    import org.apache.ojb.broker.metadata.CollectionDescriptor;
023    import org.apache.ojb.broker.query.Query;
024    import org.apache.ojb.broker.query.QueryByCriteria;
025    
026    /**
027     * Default Implementation of QueryCustomizer.
028     *
029     * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
030     * @version $Id: QueryCustomizerDefaultImpl.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
031     */
032    public class QueryCustomizerDefaultImpl implements QueryCustomizer
033    {
034    
035        private Map m_attributeList = null;
036    
037            /**
038             * Default Constructor
039             */
040            public QueryCustomizerDefaultImpl()
041            {
042                    super();
043            }
044    
045        /**
046         * Default implementation returns unmodified original Query
047         *
048         * @see org.apache.ojb.broker.accesslayer.QueryCustomizer#customizeQuery
049         */
050        public Query customizeQuery(Object anObject, PersistenceBroker aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
051        {
052            return aQuery;
053        }
054    
055    
056        /**
057         * @see org.apache.ojb.broker.metadata.AttributeContainer#addAttribute(String, String)
058         */
059       public void addAttribute(String attributeName, String attributeValue)
060       {
061            if (attributeName==null)
062            {
063                return;
064            }
065            if (m_attributeList==null)
066            {
067                m_attributeList=new HashMap();
068            }
069           m_attributeList.put(attributeName,attributeValue);
070        }
071    
072            /* (non-Javadoc)
073             * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String, java.lang.String)
074             */
075            public String getAttribute(String attributeName, String defaultValue)
076            {
077            String result = defaultValue;
078            if (m_attributeList!=null)
079            {
080                result = (String)m_attributeList.get(attributeName);
081                if (result==null)
082                {
083                    result = defaultValue;
084                }
085            }
086            return result;
087            }
088    
089            /* (non-Javadoc)
090             * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String)
091             */
092            public String getAttribute(String attributeName)
093            {
094            return this.getAttribute(attributeName,null);
095            }
096    
097    }