FileDocCategorySizeDatePackage
KeyValueMap.javaAPI DocAndroid 5.1 API2642Thu Mar 12 22:22:30 GMT 2015android.filterfw.core

KeyValueMap

public class KeyValueMap extends HashMap
hide

Fields Summary
Constructors Summary
Methods Summary
public static android.filterfw.core.KeyValueMapfromKeyValues(java.lang.Object keyValues)

        KeyValueMap result = new KeyValueMap();
        result.setKeyValues(keyValues);
        return result;
    
public floatgetFloat(java.lang.String key)

        Object result = get(key);
        return result != null ? (Float)result : null;
    
public intgetInt(java.lang.String key)

        Object result = get(key);
        return result != null ? (Integer)result : null;
    
public java.lang.StringgetString(java.lang.String key)

        Object result = get(key);
        return result != null ? (String)result : null;
    
public voidsetKeyValues(java.lang.Object keyValues)

        if (keyValues.length % 2 != 0) {
            throw new RuntimeException("Key-Value arguments passed into setKeyValues must be "
            + "an alternating list of keys and values!");
        }
        for (int i = 0; i < keyValues.length; i += 2) {
            if (!(keyValues[i] instanceof String)) {
                throw new RuntimeException("Key-value argument " + i + " must be a key of type "
                    + "String, but found an object of type " + keyValues[i].getClass() + "!");
            }
            String key = (String)keyValues[i];
            Object value = keyValues[i+1];
            put(key, value);
        }
    
public java.lang.StringtoString()

        StringWriter writer = new StringWriter();
        for (Map.Entry<String, Object> entry : entrySet()) {
            String valueString;
            Object value = entry.getValue();
            if (value instanceof String) {
                valueString = "\"" + value + "\"";
            } else {
                valueString = value.toString();
            }
            writer.write(entry.getKey() + " = " + valueString + ";\n");
        }
        return writer.toString();