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 */ 017 package org.apache.commons.collections.bidimap; 018 019 import java.util.Comparator; 020 import java.util.SortedMap; 021 022 import org.apache.commons.collections.SortedBidiMap; 023 024 /** 025 * Provides a base decorator that enables additional functionality to be added 026 * to a SortedBidiMap via decoration. 027 * <p> 028 * Methods are forwarded directly to the decorated map. 029 * <p> 030 * This implementation does not perform any special processing with the map views. 031 * Instead it simply returns the inverse from the wrapped map. This may be 032 * undesirable, for example if you are trying to write a validating implementation 033 * it would provide a loophole around the validation. 034 * But, you might want that loophole, so this class is kept simple. 035 * 036 * @since Commons Collections 3.0 037 * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $ 038 * 039 * @author Stephen Colebourne 040 */ 041 public abstract class AbstractSortedBidiMapDecorator 042 extends AbstractOrderedBidiMapDecorator implements SortedBidiMap { 043 044 /** 045 * Constructor that wraps (not copies). 046 * 047 * @param map the map to decorate, must not be null 048 * @throws IllegalArgumentException if the collection is null 049 */ 050 public AbstractSortedBidiMapDecorator(SortedBidiMap map) { 051 super(map); 052 } 053 054 /** 055 * Gets the map being decorated. 056 * 057 * @return the decorated map 058 */ 059 protected SortedBidiMap getSortedBidiMap() { 060 return (SortedBidiMap) map; 061 } 062 063 //----------------------------------------------------------------------- 064 public SortedBidiMap inverseSortedBidiMap() { 065 return getSortedBidiMap().inverseSortedBidiMap(); 066 } 067 068 public Comparator comparator() { 069 return getSortedBidiMap().comparator(); 070 } 071 072 public SortedMap subMap(Object fromKey, Object toKey) { 073 return getSortedBidiMap().subMap(fromKey, toKey); 074 } 075 076 public SortedMap headMap(Object toKey) { 077 return getSortedBidiMap().headMap(toKey); 078 } 079 080 public SortedMap tailMap(Object fromKey) { 081 return getSortedBidiMap().tailMap(fromKey); 082 } 083 084 }