001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  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 */
017package org.apache.activemq.filter;
018
019import org.apache.activemq.command.*;
020
021/**
022 * A base class for entry objects used to construct a destination based policy
023 * map.
024 * 
025 * 
026 * @org.apache.xbean.XBean
027 */
028public abstract class DestinationMapEntry<T> implements Comparable<T> {
029
030    protected ActiveMQDestination destination;
031
032    public int compareTo(Object that) {
033        if (that instanceof DestinationMapEntry) {
034            DestinationMapEntry<?> thatEntry = (DestinationMapEntry<?>)that;
035            return ActiveMQDestination.compare(destination, thatEntry.destination);
036        } else if (that == null) {
037            return 1;
038        } else {
039            return getClass().getName().compareTo(that.getClass().getName());
040        }
041    }
042
043    /**
044     * A helper method to set the destination from a configuration file
045     */
046    public void setQueue(String name) {
047        setDestination(new ActiveMQQueue(name));
048    }
049
050    /**
051     * A helper method to set the destination from a configuration file
052     */
053    public void setTopic(String name) {
054        setDestination(new ActiveMQTopic(name));
055    }
056
057    public void setTempTopic(boolean flag){
058        setDestination(new ActiveMQTempTopic(">"));
059    }
060    
061    public void setTempQueue(boolean flag){
062        setDestination(new ActiveMQTempQueue(">"));
063    }
064
065    public ActiveMQDestination getDestination() {
066        return destination;
067    }
068
069    public void setDestination(ActiveMQDestination destination) {
070        this.destination = destination;
071    }
072
073    public Comparable<T> getValue() {
074        return this;
075    }
076}