📄 flowdictionary.java
字号:
/*
* Copyright (c) 2003, Alexander Greif
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Flow4J-Eclipse project nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.orthanc.flow4j.runtime;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* @author alex
*
* TODO
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class FlowDictionary extends HashMap {
/**
* Constructs an empty FlowDictionary with the default initial
* capacity and the default load factor.
*/
public FlowDictionary() {
super();
}
/**
* Constructs an empty FlowDictionary with the specified initial capacity and the default load factor.
* @param initialCapacity
*/
public FlowDictionary(int initialCapacity) {
super(initialCapacity);
}
/**
* Constructs an empty FlowDictionary with the specified initial capacity and load factor.
* @param initialCapacity
* @param loadFactor
*/
public FlowDictionary(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
}
/**
* Constructs a new FlowDictionary with the same mappings as the specified Map.
* @param m
*/
public FlowDictionary(Map m) {
super(m);
}
/**
* Returns true if the map contains the specified key. If
* extended is true then other containers than the underlying
* map can also be searched for the key.
* @param key key whose presence in this map is to be tested.
* @return true if this map contains a mapping for the specified key.
*/
public boolean extContainsKey(String key) {
return containsKey(key);
}
/**
* Returns the value to which this map maps the specified key.
* Returns null if the map contains no mapping for this key.
* @param key key whose associated value is to be returned.
* @param isExtended if true then other sources than the underlying map can be searched
* @return the value to which this map maps the specified key, or null if the map contains no mapping for this key.
* @throws ClassCastException if the key is of an inappropriate type for this map (optional).
* @throws NullPointerException key is null and this map does not not permit null keys (optional).
*/
public Object extGet(String key) throws ClassCastException, NullPointerException {
return get(key);
}
/**
* Returns the <code>Integer</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>Integer</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public Integer getInteger(String key) throws Flow4JRuntimeException {
if (! extContainsKey(key))
throw new Flow4JRuntimeException("Dictionary does not contain key \"" + key + "\"");
return (Integer)extGet(key);
}
/**
* Returns the <code>Integer</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>Integer</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public Integer I(String key) throws Flow4JRuntimeException {
return getInteger(key);
}
/**
* Returns the <code>int</code> value to which the specified key is mapped,
* or a Flow4JRuntimeException if no such key exists in the dictionary.
* @param key the key whose associated value is to be returned.
* @return the <code>int</code> value to which this map maps the specified key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public int getInt(String key) throws Flow4JRuntimeException {
return getInteger(key).intValue();
}
/**
* Returns the <code>int</code> value to which the specified key is mapped,
* or a Flow4JRuntimeException if no such key exists in the dictionary.
* @param key the key whose associated value is to be returned.
* @return the <code>int</code> value to which this map maps the specified key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public int i(String key) throws Flow4JRuntimeException {
return getInt(key);
}
/**
* Returns the <code>String</code> representation of the integer value that
* is stored in the dictionary under the given key.
* @param key the key whose associated value is to be returned.
* @return the <code>int</code> value to which this map maps the specified key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public String i2s(String key) throws Flow4JRuntimeException {
return I(key).toString();
}
/**
* Returns the <code>String</code> representation of the integer value that
* is stored in the dictionary under the given key.
* @param key the key whose associated value is to be returned.
* @return the <code>int</code> value to which this map maps the specified key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
* or the string could not be converted to a number.
*/
public int s2i(String key) throws Flow4JRuntimeException {
int result = 0;
try {
result = Integer.parseInt(str(key));
} catch (NumberFormatException e) {
throw new Flow4JRuntimeException(e);
} catch (Flow4JRuntimeException e) {
throw e;
}
return result;
}
/**
* Returns the <code>String</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>String</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public String getString(String key) throws Flow4JRuntimeException {
if (! extContainsKey(key))
throw new Flow4JRuntimeException("Dictionary does not contain key \"" + key + "\"");
return (String)extGet(key);
}
/**
* Returns the <code>String</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>String</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public String Str(String key) throws Flow4JRuntimeException {
return getString(key);
}
/**
* Returns the <code>String</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>String</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public String str(String key) throws Flow4JRuntimeException {
return getString(key);
}
/**
* Returns the <code>Float</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>Float</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public Float getFloat(String key) throws Flow4JRuntimeException {
if (! extContainsKey(key))
throw new Flow4JRuntimeException("Dictionary does not contain key \"" + key + "\"");
return (Float)extGet(key);
}
/**
* Returns the <code>Float</code> value to which the specified key is mapped,
* or null if the map contains no mapping for this key
* @param key the key whose associated value is to be returned.
* @return the <code>Float</code> value to which this map maps the specified key,
* or null if the map contains no mapping for this key
* @throws Flow4JRuntimeException if the dictionary does not contain such a key
*/
public Float F(String key) throws Flow4JRuntimeException {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -