Package java.io

Examples of java.io.StringWriter


        }
      }
   
    private void performMethodParsingViaJDTAST(final String classname, final Set<TMLScriptMethod> methods, final int envFlags) {
        ASTParser parser = ASTParser.newParser(AST.JLS3);
        StringWriter writer = new StringWriter();
        InputStreamReader reader = new InputStreamReader(retrieveJavaSource(classname));
        try {
            WGUtils.inToOut(reader, writer, 1024);
        }
        catch (IOException e) {
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {
            private Map<String, String> _imports = new HashMap<String, String>();

            @Override
View Full Code Here


            return constructors;
    }

    private void performConstructorParsingViaJDTAST(final String classname, final Set<TMLScriptMethod> constructors) {
        ASTParser parser = ASTParser.newParser(AST.JLS3);
        StringWriter writer = new StringWriter();
        InputStreamReader reader = new InputStreamReader(retrieveJavaSource(classname));
        try {
            WGUtils.inToOut(reader, writer, 1024);
        }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {
           
            private Map<String, String> _imports = new HashMap<String, String>();
View Full Code Here

    this.message = message;
    this.actor = actor;
    this.detail = detail;
    if(th != null){
      detail.put("message", th.getMessage());
      StringWriter stringWriter = new StringWriter();
      PrintWriter pw = new PrintWriter(stringWriter );
      th.printStackTrace(pw);
      if(th.getCause() != null){
        th.getCause().printStackTrace(pw);
        if(th.getCause() != null){
          th.getCause().printStackTrace(pw);
        }
      }
      pw.close();
      detail.put("printStackTrace", stringWriter.toString());
    }
  }
View Full Code Here

    node.setSex('e');
    node.setText("dfs\t");
    int[] rig = new int[]{1,2,3};
    node.setRig(rig);
    System.out.println(Json.toJson(node));
    StringWriter writer = new StringWriter();
    Json.toJson(node, writer);
    System.out.println(writer.toString());

  }
View Full Code Here

        case BOOLEAN:
            return "boolean: " + this.bool;
        case INT:
            return "int: " + this.intValue;
        case EXCEPTION: {
            StringWriter w = new StringWriter();
            exception.printStackTrace(new PrintWriter(w));
            return "exception: " + exception.getSQLState() + ": " + exception.getMessage() + "\r\n" + w.toString();
        }
        case RESULT_SET:
            String result = "ResultSet { // size=" + rows.size() + "\r\n  ";
            for (Column column : header) {
                result += column.toString() + "; ";
View Full Code Here

    return sources;
  }

  @Override
  public String toString() {
    StringWriter resultWriter = new StringWriter();
    resultWriter.write("ModelMetaStore\n");
    metaModel.write(resultWriter);
    return resultWriter.toString();
  }
View Full Code Here

            maxColWidth = DEFAULT_MAX_COL_WIDTH;
        }
        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++) {
                Object obj = rs.getObject(j);
                if (obj instanceof SQLXML) {
View Full Code Here

    downloadAttempt.addProperty(AGGREGATOR.aggregatedSource, logEntryModel
        .createResource(aggregatedSource.getURIRef()));
    downloadAttempt.addProperty(AGGREGATOR.aggregator, logEntryModel
        .createResource(identity.getURIRef()));
    Graph logEntryGraph = JenaUtil.getGraphFromModel(logEntryModel, true);
    final StringWriter aggregationWarningWriter = new StringWriter();
    final StringWriter aggregationErrorWriter = new StringWriter();
    try {
      Model model = ModelFactory.createDefaultModel();
      // model.read(url.toString());
      JenaReader jenaReader = new JenaReader();
      jenaReader.setErrorHandler(new RDFErrorHandler() {

        public void error(Exception e) {
          aggregationErrorWriter.write(e.getMessage());
        }

        public void fatalError(Exception e) {
          aggregationErrorWriter.write("FATAL: ");
          aggregationErrorWriter.write(e.getMessage());
          log.info("Fatal Error aggregating "+aggregatedSource, e);
          throw new AllreadyLoggedRuntimeException(e);
        }

        public void warning(Exception e) {
          aggregationWarningWriter.write(e.getMessage());
        }

      });
      jenaReader.read(model, url.toString());
      String errorMessage = aggregationErrorWriter.toString();
      if (errorMessage.equals("")) {
        Graph graph = JenaUtil.getGraphFromModel(model, true);
        store.updateGraph(aggregatedSource, new FCAGraphImpl(graph));
      } else {
        if (!errorMessage.equals("")) {
View Full Code Here

   * @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

        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

TOP

Related Classes of java.io.StringWriter

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.