Lines Matching refs:key

26  * store contains a list of string key-value pairs.
37 private static native String native_get(String key);
38 private static native String native_get(String key, String def);
39 private static native int native_get_int(String key, int def);
40 private static native long native_get_long(String key, long def);
41 private static native boolean native_get_boolean(String key, boolean def);
42 private static native void native_set(String key, String def);
46 * Get the value for the given key.
47 * @return an empty string if the key isn't found
48 * @throws IllegalArgumentException if the key exceeds 32 characters
50 public static String get(String key) {
51 if (key.length() > PROP_NAME_MAX) {
52 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
54 return native_get(key);
58 * Get the value for the given key.
59 * @return if the key isn't found, return def if it isn't null, or an empty string otherwise
60 * @throws IllegalArgumentException if the key exceeds 32 characters
62 public static String get(String key, String def) {
63 if (key.length() > PROP_NAME_MAX) {
64 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
66 return native_get(key, def);
70 * Get the value for the given key, and return as an integer.
71 * @param key the key to lookup
73 * @return the key parsed as an integer, or def if the key isn't found or
75 * @throws IllegalArgumentException if the key exceeds 32 characters
77 public static int getInt(String key, int def) {
78 if (key.length() > PROP_NAME_MAX) {
79 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
81 return native_get_int(key, def);
85 * Get the value for the given key, and return as a long.
86 * @param key the key to lookup
88 * @return the key parsed as a long, or def if the key isn't found or
90 * @throws IllegalArgumentException if the key exceeds 32 characters
92 public static long getLong(String key, long def) {
93 if (key.length() > PROP_NAME_MAX) {
94 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
96 return native_get_long(key, def);
100 * Get the value for the given key, returned as a boolean.
104 * If the key does not exist, or has any other value, then the default
106 * @param key the key to lookup
108 * @return the key parsed as a boolean, or def if the key isn't found or is
110 * @throws IllegalArgumentException if the key exceeds 32 characters
112 public static boolean getBoolean(String key, boolean def) {
113 if (key.length() > PROP_NAME_MAX) {
114 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
116 return native_get_boolean(key, def);
120 * Set the value for the given key.
121 * @throws IllegalArgumentException if the key exceeds 32 characters
124 public static void set(String key, String val) {
125 if (key.length() > PROP_NAME_MAX) {
126 throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
132 native_set(key, val);