src/core/net/sf/basedb/util/extensions/SingleExtensionFilter.java

Code
Comments
Other
Rev Date Author Line
4320 29 May 08 nicklas 1 /**
4479 05 Sep 08 jari 2   $Id$
4320 29 May 08 nicklas 3
4320 29 May 08 nicklas 4   Copyright (C) Authors contributing to this file.
4320 29 May 08 nicklas 5
4320 29 May 08 nicklas 6   This file is part of BASE - BioArray Software Environment.
4320 29 May 08 nicklas 7   Available at http://base.thep.lu.se/
4320 29 May 08 nicklas 8
4320 29 May 08 nicklas 9   BASE is free software; you can redistribute it and/or
4320 29 May 08 nicklas 10   modify it under the terms of the GNU General Public License
4479 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
4320 29 May 08 nicklas 12   of the License, or (at your option) any later version.
4320 29 May 08 nicklas 13
4320 29 May 08 nicklas 14   BASE is distributed in the hope that it will be useful,
4320 29 May 08 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4320 29 May 08 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4320 29 May 08 nicklas 17   GNU General Public License for more details.
4320 29 May 08 nicklas 18
4320 29 May 08 nicklas 19   You should have received a copy of the GNU General Public License
4515 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4320 29 May 08 nicklas 21 */
4320 29 May 08 nicklas 22 package net.sf.basedb.util.extensions;
4320 29 May 08 nicklas 23
4320 29 May 08 nicklas 24 import java.util.List;
4320 29 May 08 nicklas 25
4320 29 May 08 nicklas 26 /**
4320 29 May 08 nicklas 27   A filter implementation that enables a single extension and
4320 29 May 08 nicklas 28   disables all other.
4320 29 May 08 nicklas 29   
4320 29 May 08 nicklas 30   @author nicklas
4320 29 May 08 nicklas 31   @version 2.8
4320 29 May 08 nicklas 32   @base.modified $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
4320 29 May 08 nicklas 33 */
4320 29 May 08 nicklas 34 public class SingleExtensionFilter 
4320 29 May 08 nicklas 35   implements ExtensionsFilter 
4320 29 May 08 nicklas 36 {
4320 29 May 08 nicklas 37
4320 29 May 08 nicklas 38   private final String id;
4320 29 May 08 nicklas 39   
4320 29 May 08 nicklas 40   /**
4320 29 May 08 nicklas 41     Create a filter that enables the given extension 
4320 29 May 08 nicklas 42     and disables all other.
4320 29 May 08 nicklas 43   */
6875 20 Apr 15 nicklas 44   public SingleExtensionFilter(Extension<?> extension)
4320 29 May 08 nicklas 45   {
4320 29 May 08 nicklas 46     this.id = extension.getId();
4320 29 May 08 nicklas 47   }
4320 29 May 08 nicklas 48   
4320 29 May 08 nicklas 49   /**
4320 29 May 08 nicklas 50     Create a filter that enables the extension with the 
4320 29 May 08 nicklas 51     given ID and disables all others.
4320 29 May 08 nicklas 52   */
4320 29 May 08 nicklas 53   public SingleExtensionFilter(String id)
4320 29 May 08 nicklas 54   {
4320 29 May 08 nicklas 55     this.id = id;
4320 29 May 08 nicklas 56   }
4320 29 May 08 nicklas 57   
4320 29 May 08 nicklas 58   /*
4320 29 May 08 nicklas 59     From the ExtensionsFilter interface
4320 29 May 08 nicklas 60     -----------------------------------
4320 29 May 08 nicklas 61   */
4320 29 May 08 nicklas 62   @Override
4320 29 May 08 nicklas 63   public boolean isEnabled(ExtensionPoint<?> extensionPoint) 
4320 29 May 08 nicklas 64   {
4320 29 May 08 nicklas 65     return true;
4320 29 May 08 nicklas 66   }
4320 29 May 08 nicklas 67
4320 29 May 08 nicklas 68   @Override
4320 29 May 08 nicklas 69   public boolean isEnabled(Extension<?> extension) 
4320 29 May 08 nicklas 70   {
4320 29 May 08 nicklas 71     return extension.getId().equals(id);
4320 29 May 08 nicklas 72   }
4320 29 May 08 nicklas 73
4320 29 May 08 nicklas 74   /**
4320 29 May 08 nicklas 75     Do nothing since the list should contain only a single extension.
4320 29 May 08 nicklas 76   */
4320 29 May 08 nicklas 77   @Override
4320 29 May 08 nicklas 78   public void sort(List<? extends InvokationContext<?>> extensions) 
4320 29 May 08 nicklas 79   {}
4320 29 May 08 nicklas 80   // --------------------------------------------------
4320 29 May 08 nicklas 81 }