@Override public String toEditString() { StringWriter buf = new StringWriter(); buf.write(LABEL); buf.write("\t"); buf.write(Ssurgeon.EDGE_NAME_ARG);buf.write(" "); buf.write(edgeName); buf.write("\t"); buf.write(Ssurgeon.GOV_NODENAME_ARG);buf.write(" "); buf.write(govName); buf.write("\t"); buf.write(Ssurgeon.DEP_NODENAME_ARG);buf.write(" "); buf.write(depName); return buf.toString(); }
/** Copy the data from an {@link InputStream} to a string using the specified charset. * @param estimatedSize Used to allocate the output buffer to possibly avoid an array copy. * @param charset May be null to use the platform's default charset. */ public static String copyStreamToString (InputStream input, int estimatedSize, String charset) throws IOException { InputStreamReader reader = charset == null ? new InputStreamReader(input) : new InputStreamReader(input, charset); StringWriter writer = new StringWriter(Math.max(0, estimatedSize)); char[] buffer = new char[DEFAULT_BUFFER_SIZE]; int charsRead; while ((charsRead = reader.read(buffer)) != -1) { writer.write(buffer, 0, charsRead); } return writer.toString(); }
public static String read(Reader reader) { try { StringWriter writer = new StringWriter(); char[] buffer = new char[DEFAULT_BUFFER_SIZE]; int n = 0; while (-1 != (n = reader.read(buffer))) { writer.write(buffer, 0, n); } return writer.toString(); } catch (IOException ex) { throw new IllegalStateException("read error", ex); } }
@Override public String toEditString() { StringWriter buf = new StringWriter(); buf.write(LABEL); buf.write("\t"); buf.write(Ssurgeon.NODE_PROTO_ARG);buf.write(" "); buf.write("\""); buf.write(nodeString); buf.write("\"\t"); buf.write(Ssurgeon.NAME_ARG); buf.write("\t"); buf.write(nodeName); return buf.toString(); }
/** * Closes the currently open write and writes out the following text as a GString expression until it reaches an end %>. * * @param reader a reader for the template text * @param sw a StringWriter to write expression content * @throws IOException if something goes wrong */ private void groovyExpression(Reader reader, StringWriter sw) throws IOException { sw.write("${"); int c; while ((c = reader.read()) != -1) { if (c == '%') { c = reader.read(); if (c != '>') { sw.write('%'); } else { break; } } if (c != '\n' && c != '\r') { sw.write(c); } } sw.write("}"); }
/** Copy the data from an {@link InputStream} to a string using the specified charset. * @param estimatedSize Used to allocate the output buffer to possibly avoid an array copy. * @param charset May be null to use the platform's default charset. */ public static String copyStreamToString (InputStream input, int estimatedSize, String charset) throws IOException { InputStreamReader reader = charset == null ? new InputStreamReader(input) : new InputStreamReader(input, charset); StringWriter writer = new StringWriter(Math.max(0, estimatedSize)); char[] buffer = new char[DEFAULT_BUFFER_SIZE]; int charsRead; while ((charsRead = reader.read(buffer)) != -1) { writer.write(buffer, 0, charsRead); } return writer.toString(); }
@Override public String toEditString() { StringWriter buf = new StringWriter(); buf.write(LABEL); buf.write("\t"); buf.write(Ssurgeon.RELN_ARG);buf.write(" "); buf.write(relation.toString()); buf.write("\t"); buf.write(Ssurgeon.GOV_NODENAME_ARG);buf.write(" "); buf.write(govName); buf.write("\t"); buf.write(Ssurgeon.DEP_NODENAME_ARG);buf.write(" "); buf.write(depName); return buf.toString(); }
/** * Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>. * * @param reader a reader for the template text * @param sw a StringWriter to write expression content * @throws IOException if something goes wrong */ private void groovySection(Reader reader, StringWriter sw) throws IOException { sw.write("\"\"\");"); int c; while ((c = reader.read()) != -1) { if (c == '%') { c = reader.read(); if (c != '>') { sw.write('%'); } else { break; } } /* Don't eat EOL chars in sections - as they are valid instruction separators. * See http://jira.codehaus.org/browse/GROOVY-980 */ // if (c != '\n' && c != '\r') { sw.write(c); //} } sw.write(";\nout.print(\"\"\""); }
static String readFully(Reader reader) throws IOException { try { StringWriter writer = new StringWriter(); char[] buffer = new char[1024]; int count; while ((count = reader.read(buffer)) != -1) { writer.write(buffer, 0, count); } return writer.toString(); } finally { reader.close(); } }
/** * Returns the remainder of 'reader' as a string, closing it when done. */ public static String readFully(Reader reader) throws IOException { try { StringWriter writer = new StringWriter(); char[] buffer = new char[1024]; int count; while ((count = reader.read(buffer)) != -1) { writer.write(buffer, 0, count); } return writer.toString(); } finally { reader.close(); } } public static void skipAll(InputStream in) throws IOException {
private static String loadContents(InputStream stream, Charset charset) throws IOException { try (StringWriter writer = new StringWriter(); BufferedReader reader = new BufferedReader(new InputStreamReader(stream, charset))) { int c; while ((c = reader.read()) != -1) { writer.write(c); } return writer.toString(); } }
static String readFully(Reader reader) throws IOException { try { StringWriter writer = new StringWriter(); char[] buffer = new char[1024]; int count; while ((count = reader.read(buffer)) != -1) { writer.write(buffer, 0, count); } return writer.toString(); } finally { reader.close(); } }
@Override public String toEditString() { StringWriter buf = new StringWriter(); buf.write(LABEL); buf.write("\t"); buf.write(Ssurgeon.GOV_NODENAME_ARG);buf.write(" "); buf.write(govName); buf.write("\t"); buf.write(Ssurgeon.DEP_NODENAME_ARG);buf.write(" "); buf.write(depName); buf.write("\t"); buf.write(Ssurgeon.RELN_ARG);buf.write(" "); buf.write(relation.toString()); buf.write("\t"); buf.write(Ssurgeon.WEIGHT_ARG);buf.write(" "); buf.write(String.valueOf(weight)); return buf.toString(); }