Examples of StringWriter


Examples of java.io.StringWriter

   * @param name
   * @return
   */
  private AnonId getAnonId(String name) {
   
    StringWriter result = new StringWriter();
    StringReader in = new StringReader(name);
    try {
      //Skip "A";
      in.read(new char[1]);
      boolean inX = false;
      StringWriter inXValueWriter = new StringWriter();
      for (int ch = in.read(); ch != -1; ch = in.read()) {
        if (inX) {
          if (ch == 'X') {
            inX = false;
            String inXValue = inXValueWriter.toString();
            inXValueWriter = new StringWriter();
            if (inXValue.equals("")) {
              result.write('X');
            } else {
              result.write(Integer.parseInt(inXValue, 16));
            }
          } else {
            inXValueWriter.write(ch);
          }
        } else {
          if (ch == 'X') {
            inX = true;
          } else {
View Full Code Here

Examples of java.io.StringWriter

        out.println(query);
       
        ResultSetMetaData rsmd = rs.getMetaData();
        int count = rsmd.getColumnCount();
        int[] sizes = new int[count];
        StringWriter types = new StringWriter();
        StringWriter columns = new StringWriter();
        for (int i = 1; i <= count; i++) {
            String columnName = rsmd.getColumnName(i);
            String typeName = rsmd.getColumnTypeName(i);
            if (maxColWidth == 0) {
                // Sets the width of the column to the wider of the column name and the column type name.
                sizes[i-1] = Math.max(columnName.length(), typeName.length());
            } else {
                // Sets the width of the column to the wider of the column name and the column display size (which cannot exceed maxColWidth).
                sizes[i-1] = Math.max(Math.max(columnName.length(), typeName.length()), // takes into account the type name width
                                      Math.min(rsmd.getColumnDisplaySize(i), maxColWidth));
            }
            types.write(resizeString(typeName, sizes[i-1]));
            columns.write(resizeString(columnName, sizes[i-1]));
            if (i != count) {
                types.write(SPACER);
                columns.write(SPACER);
            }
        }
        out.println(types.toString());
        out.println(columns.toString());
        int totalRows = 0;
        while (rs.next()) {
            for (int j = 1; j <= count; j++) {
                if (maxColWidth == 0) {
                    Object obj = rs.getObject(j);
View Full Code Here

Examples of java.io.StringWriter

    JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
    Marshaller marshell = jc.createMarshaller();
    marshell.setSchema(schema);
    marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
   
    StringWriter sw = new StringWriter();
    marshell.marshal(vdb, sw);
       
    //System.out.println(sw.toString());

    // UnMarshell
    Unmarshaller un = jc.createUnmarshaller();
    un.setSchema(schema);
    vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
   
    assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
    assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
    assertEquals(1, vdb.getVersion());
    assertEquals("vdb-value", vdb.getPropertyValue("vdb-property")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

Examples of mil.nga.giat.geowave.store.data.field.BasicWriter.StringWriter

        final ByteArrayId fieldId ) {
      if (fieldId.equals(GEOM)) {
        return new GeometryWriter();
      }
      else if (fieldId.equals(ID)) {
        return new StringWriter();
      }
      return null;
    }
View Full Code Here

Examples of org.apache.drill.exec.store.pojo.Writers.StringWriter

        }else if(type == boolean.class){
          writers[i] = new BitWriter(f);
        }else if(type == long.class){
          writers[i] = new LongWriter(f);
        }else if(type == String.class){
          writers[i] = new StringWriter(f);
        }else if (type == Timestamp.class) {
          writers[i] = new NTimeStampWriter(f);
        }else{
          throw new ExecutionSetupException(String.format("PojoRecord reader doesn't yet support conversions from type [%s].", type));
        }
View Full Code Here

Examples of org.lilystudio.util.StringWriter

  public void testBean() throws Exception {
    Context c = new Context();
    Bean bean = new Bean();
    c.putBean(bean);
    Template template = new Template(engine, "{$number}");
    Writer writer = new StringWriter();
    template.merge(c, writer);
    Assert.assertEquals("Bean导入", writer.toString(), "10");

    context.set("bean", bean);
    Assert.assertEquals("Bean导入",
        getResult("{$bean.number}{$bean.number}{$bean.aaa}{$bean.aaa}"),
        "1010nullnull");
View Full Code Here

Examples of org.nutz.lang.stream.StringWriter

   * @param sb
   *            StringBuilder 对象
   * @return 文本输出流对象
   */
  public static Writer opw(StringBuilder sb) {
    return new StringWriter(sb);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.