Skip to content

Instantly share code, notes, and snippets.

@azenla
Created June 11, 2013 12:59
Show Gist options
  • Save azenla/5756602 to your computer and use it in GitHub Desktop.
Save azenla/5756602 to your computer and use it in GitHub Desktop.
The DirectMyFile Core Bundle Class
package com.directmyfile;
import java.util.HashMap;
import java.util.Set;
public class Bundle {
protected HashMap<String, Object> objects;
public Bundle() {
this.objects = new HashMap<String, Object>();
}
public Bundle(Bundle source) {
this.objects = new HashMap<String, Object>();
for (String key : source.keySet()) {
objects.put(key, source.objects.get(key));
}
}
public void put(String key, Object value) {
objects.put(key, value);
}
public Object get(String key) {
return objects.get(key);
}
public void putString(String key, String value) {
put(key, value);
}
public String getString(String key) {
return (String) get(key);
}
public void putInteger(String key, int value) {
put(key, value);
}
public Integer getInteger(String key) {
return (Integer) get(key);
}
public Double getDouble(String key) {
return (Double) objects.get(key);
}
public void putDouble(String key, Double value) {
put(key, value);
}
public void putFloat(String key, Float value) {
put(key, value);
}
public void putArray(String key, Object[] value) {
put(key, value);
}
public void putStringArray(String key, String[] value) {
put(key, value);
}
public Object[] getArray(String key) {
return (Object[]) get(key);
}
public String[] getStringArray(String key) {
return (String[]) get(key);
}
public Float getFloat(String key) {
return (Float) get(key);
}
public void putByte(String key, Byte value) {
put(key, value);
}
public Byte getByte(String key) {
return (Byte) get(key);
}
public void putByteArray(String key, Byte[] value) {
put(key, value);
}
public void putCharacter(String key, Character value) {
put(key, value);
}
public Character getCharacter(String key) {
return (Character) get(key);
}
public Byte[] getByteArray(String key) {
return (Byte[]) get(key);
}
public boolean containsKey(String key) {
return objects.containsKey(key);
}
public Set<String> keySet() {
return objects.keySet();
}
public void remove(String key) {
objects.remove(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment