Package net.arnx.jsonic.io

Examples of net.arnx.jsonic.io.StringBuilderOutputSource


   
    OutputSource fs;
    if (ap instanceof Writer) {
      fs = new WriterOutputSource((Writer)ap);
    } else if (ap instanceof StringBuilder) {
      fs = new StringBuilderOutputSource((StringBuilder)ap);
    } else {
      fs = new AppendableOutputSource(ap);
    }
   
    context.enter('$');
View Full Code Here


        return null;
      }
    }
   
    public String toString() {
      StringBuilderOutputSource sb = new StringBuilderOutputSource(getCachedBuffer());
      for (int i = 0; i < path.length; i+=2) {
        Object key = path[i];
        if (key == null) {
          sb.append("[null]");
        } else if (key instanceof Number) {
          sb.append('[');
          sb.append(key.toString());
          sb.append(']');
        } else if (key instanceof Character) {
          sb.append(key.toString());
        } else {
          String str = key.toString();
          boolean escape = false;
          for (int j = 0; j < str.length(); j++) {
            if (j == 0) {
              escape = !Character.isJavaIdentifierStart(str.charAt(j));
            } else {
              escape = !Character.isJavaIdentifierPart(str.charAt(j));
            }
            if (escape) break;
          }
         
          if (escape) {
            sb.append('[');
            try {
              StringFormatter.serialize(this, str, sb);
            } catch (Exception e) {
              // no handle
            }
            sb.append(']');
          } else {
            sb.append('.');
            sb.append(str);
          }
        }
      }
      return sb.toString();
    }
View Full Code Here

 
  public Object convert(JSON json, Context context, Object value, Class<?> c, Type t) throws Exception {
    Context context2 = json.new Context(context);
    context2.skipHint = true;
    value = json.preformatInternal(context2, value);
    StringBuilderOutputSource fs = new StringBuilderOutputSource(new StringBuilder(200));
    try {
      json.formatInternal(context2, value, fs);
    } catch (IOException e) {
      // no handle
    }
    fs.flush();
   
    context.skipHint = true;
    return json.postparse(context, fs.toString(), c, t);
  }
View Full Code Here

TOP

Related Classes of net.arnx.jsonic.io.StringBuilderOutputSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.