Exemple #1
0
 public CharBuf(byte[] bytes) {
   this.buffer = null;
   try {
     String str = new String(bytes, "UTF-8");
     __init__(FastStringUtils.toCharArray(str));
   } catch (UnsupportedEncodingException e) {
     Exceptions.handle(e);
   }
 }
Exemple #2
0
  public final CharBuf addDouble(Double key) {
    if (dcache == null) {
      dcache = new SimpleCache<Double, char[]>(20, CacheType.LRU);
    }
    char[] chars = dcache.get(key);

    if (chars == null) {
      String str = Double.toString(key);
      chars = FastStringUtils.toCharArray(str);
      dcache.put(key, chars);
    }

    add(chars);
    return this;
  }
Exemple #3
0
  public final CharBuf addInt(Integer key) {
    if (icache == null) {
      icache = new SimpleCache<Integer, char[]>(20, CacheType.LRU);
    }
    char[] chars = icache.get(key);

    if (chars == null) {
      String str = Integer.toString(key);
      chars = FastStringUtils.toCharArray(str);
      icache.put(key, chars);
    }

    addChars(chars);
    return this;
  }
Exemple #4
0
  public final CharBuf addLong(Long key) {
    if (lcache == null) {
      lcache = new SimpleCache<Long, char[]>(20, CacheType.LRU);
    }
    char[] chars = lcache.get(key);

    if (chars == null) {
      String str = Long.toString(key);
      chars = FastStringUtils.toCharArray(str);
      lcache.put(key, chars);
    }

    add(chars);

    return this;
  }
Exemple #5
0
  public CharBuf addBigInteger(BigInteger key) {
    if (bigICache == null) {
      bigICache = new SimpleCache<BigInteger, char[]>(20, CacheType.LRU);
    }
    char[] chars = bigICache.get(key);

    if (chars == null) {
      String str = key.toString();
      chars = FastStringUtils.toCharArray(str);
      bigICache.put(key, chars);
    }

    add(chars);

    return this;
  }
Exemple #6
0
  public final CharBuf addFloat(Float key) {
    if (fcache == null) {
      fcache = new SimpleCache<Float, char[]>(20, CacheType.LRU);
    }
    char[] chars = fcache.get(key);

    if (chars == null) {
      String str = Float.toString(key);
      chars = FastStringUtils.toCharArray(str);
      fcache.put(key, chars);
    }

    add(chars);

    return this;
  }
Exemple #7
0
  public static Date toDate(Object object) {

    if (object instanceof Date) {
      return (Date) object;
    } else if (object instanceof Value) {
      return ((Value) object).dateValue();
    } else if (object instanceof Calendar) {
      return ((Calendar) object).getTime();
    } else if (object instanceof Long) {
      return new Date((long) object);
    } else if (object instanceof String) {
      String val = (String) object;
      char[] chars = FastStringUtils.toCharArray(val);
      if (Dates.isISO8601QuickCheck(chars)) {
        return Dates.fromISO8601DateLoose(chars);
      } else {
        return toDateUS(val);
      }
    }
    return null;
  }
Exemple #8
0
 public final CharBuf add(String str) {
   add(FastStringUtils.toCharArray(str));
   return this;
 }
Exemple #9
0
 public final CharBuf addQuoted(String str) {
   final char[] chars = FastStringUtils.toCharArray(str);
   addQuoted(chars);
   return this;
 }
Exemple #10
0
 public final CharBuf addJsonFieldName(String str) {
   return addJsonFieldName(FastStringUtils.toCharArray(str));
 }
Exemple #11
0
 public final CharBuf addJsonEscapedString(String jsonString) {
   char[] charArray = FastStringUtils.toCharArray(jsonString);
   return addJsonEscapedString(charArray);
 }