Example #1
0
 public static byte[] bytesFrom(String string) {
   try {
     return Not.nil(string, "string").getBytes(ENC);
   } catch (UnsupportedEncodingException e) {
     throw new Error("Unsupported encoding", e);
   }
 }
Example #2
0
 public static String stringFrom(byte[] bytes, int offset, int length) {
   try {
     return new String(Not.nil(bytes, "bytes"), offset, length, ENC);
   } catch (UnsupportedEncodingException e) {
     throw new Error("Unsupported encoding", e);
   }
 }
Example #3
0
 public static byte[] suffix(int offset, byte[] bytes) {
   if (offset < Not.nil(bytes, "bytes").length) {
     byte[] suffix = new byte[bytes.length - offset];
     System.arraycopy(bytes, offset, suffix, 0, suffix.length);
     return suffix;
   }
   return NONE;
 }
Example #4
0
 public void setAsynchYou(SystemEvents asynch) {
   Not.nil(asynch, "asynch reference");
   if (this.asynch != null) {
     throw new IllegalStateException(this + " already received asynch pointer to itself");
   }
   this.asynch = asynch;
   this.asynch.spool(bundles);
 }
Example #5
0
 public static byte[] append(byte[] bytes, byte... suffix) {
   return add(Not.nil(bytes, "bytes"), Not.nil(suffix, "suffix"));
 }
Example #6
0
 public static byte[] prepend(byte[] bytes, byte... prefix) {
   return add(Not.nil(prefix, "prefix"), Not.nil(bytes, "bytes"));
 }
Example #7
0
 public static String stringFrom(byte[] bytes, int offset) {
   return stringFrom(Not.nil(bytes, "bytes"), offset, bytes.length - offset);
 }
Example #8
0
 public static String stringFrom(byte[] bytes) {
   return stringFrom(Not.nil(bytes, "bytes"), 0, bytes.length);
 }