Beispiel #1
0
 /**
  * Set the value for the given key.
  *
  * @throws IllegalArgumentException if the key exceeds 32 characters
  * @throws IllegalArgumentException if the value exceeds 92 characters
  */
 public static void set(String key, String val) {
   if (key.length() > PROP_NAME_MAX) {
     throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
   }
   if (val != null && val.length() > PROP_VALUE_MAX) {
     throw new IllegalArgumentException("val.length > " + PROP_VALUE_MAX);
   }
   native_set(key, val);
 }
 /**
  * Set the value for the given key.
  *
  * @throws IllegalArgumentException if the key exceeds 32 characters
  */
 public static void setLongString(String key, String val) {
   if (key.length() + 1 > PROP_NAME_MAX) {
     throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
   }
   int chunks = 0;
   if (val != null && val.length() > 0) {
     chunks = 1 + val.length() / (PROP_VALUE_MAX + 1);
   }
   native_set(key + '0', Integer.toString(chunks));
   if (chunks > 0) {
     for (int i = 1, start = 0; i <= chunks; i++) {
       int end = start + PROP_VALUE_MAX;
       if (end > val.length()) {
         end = val.length();
       }
       native_set(key + Integer.toString(i), val.substring(start, end));
       start = end;
     }
   }
 }