001 /*--------------------------------------------------------------------------+ 002 $Id: ArrayBackedStringMap.java 29399 2010-07-27 15:03:17Z juergens $ 003 | | 004 | Copyright 2005-2010 Technische Universitaet Muenchen | 005 | | 006 | Licensed under the Apache License, Version 2.0 (the "License"); | 007 | you may not use this file except in compliance with the License. | 008 | You may obtain a copy of the License at | 009 | | 010 | http://www.apache.org/licenses/LICENSE-2.0 | 011 | | 012 | Unless required by applicable law or agreed to in writing, software | 013 | distributed under the License is distributed on an "AS IS" BASIS, | 014 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 015 | See the License for the specific language governing permissions and | 016 | limitations under the License. | 017 +--------------------------------------------------------------------------*/ 018 package edu.tum.cs.commons.collections; 019 020 /** 021 * A specialization of the array backed map for string keys. This uses string 022 * interning and reference comparison. 023 * 024 * @author hummelb 025 * @author $Author: juergens $ 026 * @version $Rev: 29399 $ 027 * @levd.rating GREEN Hash: A6370F398F915DFAA7510CD39DE491C0 028 */ 029 public class ArrayBackedStringMap<V> extends ArrayBackedMap<String, V> { 030 031 /** Constructor. */ 032 public ArrayBackedStringMap() { 033 super(); 034 } 035 036 /** Constructor. */ 037 public ArrayBackedStringMap(int initialCapacity) { 038 super(initialCapacity); 039 } 040 041 /** {@inheritDoc} */ 042 @Override 043 protected String internKey(Object key) throws ClassCastException { 044 if (key == null) { 045 return null; 046 } 047 return ((String) key).intern(); 048 } 049 050 /** {@inheritDoc} */ 051 @Override 052 protected boolean areEqual(String key1, String key2) { 053 return key1 == key2; 054 } 055 }