Esempio n. 1
0
 /** Store a String and return the stored address. */
 public final long store(final String s) {
   final int strlen = s.length();
   if (strlen < CHUNKED_THRESHOLD) {
     s.getChars(0, strlen, tmpBuf, 0);
     return storeCharChunk(tmpBuf, 0, strlen);
   }
   final byte[] b = StringUtils.getBytes(s);
   return storeStringChunk(b);
 }
Esempio n. 2
0
 public static byte[] decodeMacAddress(final String mac) {
   final StringTokenizer tokens = new StringTokenizer(mac, "-");
   if (tokens.countTokens() != MAC_ADDRESS_TOKENS) {
     throw new IllegalArgumentException("Unexpected mac address representation: " + mac);
   }
   final StringBuilder buf = new StringBuilder(MAC_ADDRESS_TOKENS * 2);
   for (int i = 0; i < MAC_ADDRESS_TOKENS; i++) {
     buf.append(tokens.nextToken());
   }
   char[] c = buf.toString().toCharArray();
   return StringUtils.decodeHex(c);
 }
Esempio n. 3
0
 public ByteArray(@CheckForNull String data) {
   if (data == null) {
     throw new IllegalArgumentException();
   }
   this.bytea = StringUtils.getBytes(data);
 }