List of usage examples for java.lang StringBuffer setLength
@Override public synchronized void setLength(int newLength)
From source file:com.digitalgeneralists.assurance.ApplicationDelegate.java
public void saveScanDefinition(ScanDefinition scanDefinition) { StringBuffer message = new StringBuffer(256); logger.info(message.append("Saving scan defintion: ").append(scanDefinition)); message.setLength(0); message = null;//ww w .j ava 2 s . com SaveScanDefinitionWorker thread = new SaveScanDefinitionWorker(scanDefinition, this.notificationProvider); thread.execute(); thread = null; }
From source file:org.geoserver.security.impl.ServiceAccessRule.java
/** * Returns the list of roles as a comma separated string for this rule * /*from w ww .ja v a 2 s.co m*/ * @return */ public String getValue() { if (roles.isEmpty()) { return ServiceAccessRule.ANY; } else { StringBuffer sb = new StringBuffer(); for (String role : roles) { sb.append(role); sb.append(","); } sb.setLength(sb.length() - 1); return sb.toString(); } }
From source file:com.digitalgeneralists.assurance.ApplicationDelegate.java
public void deleteScanDefinition(ScanDefinition scanDefinition) { StringBuffer message = new StringBuffer(256); logger.info(message.append("Deleting scan defintion: ").append(scanDefinition)); message.setLength(0); message = null;/*from www.j a va 2 s. c om*/ DeleteScanDefinitionWorker thread = new DeleteScanDefinitionWorker(scanDefinition, this.notificationProvider); thread.execute(); thread = null; }
From source file:com.pureinfo.srm.contract.model.impl.ZjuContractSidGeneratorImpl.java
/** * @param _sCode//ww w . j a v a2 s . c o m * @return */ public String getCodePrefix(String _sCode) { String sDateString = DATE_FORMATTER.format(new Date()); StringBuffer sbuff = new StringBuffer(); try { sbuff.append(sDateString); sbuff.append('-'); sbuff.append(_sCode); sbuff.append('-'); return sbuff.toString(); } finally { sbuff.setLength(0); } }
From source file:CSVSimple.java
/** parse: break the input String into fields * @return java.util.Iterator containing each field * from the original as a String, in order. *///from w ww. jav a2 s . c o m public List parse(String line) { StringBuffer sb = new StringBuffer(); list.clear(); // recycle to initial state int i = 0; if (line.length() == 0) { list.add(line); return list; } do { sb.setLength(0); if (i < line.length() && line.charAt(i) == '"') i = advQuoted(line, sb, ++i); // skip quote else i = advPlain(line, sb, i); list.add(sb.toString()); i++; } while (i < line.length()); return list; }
From source file:Main.java
/** * This method is used to send a XML request file to web server to process the request and return * xml response containing event id./*from ww w.j av a2 s . c o m*/ */ public static String postXMLWithTimeout(String postUrl, String xml, int readTimeout) throws Exception { System.out.println("XMLUtils.postXMLWithTimeout: Connecting to Web Server ......."); InputStream in = null; BufferedReader bufferedReader = null; OutputStream out = null; PrintWriter printWriter = null; StringBuffer responseMessageBuffer = new StringBuffer(""); try { URL url = new URL(postUrl); URLConnection con = url.openConnection(); // Prepare for both input and output con.setDoInput(true); con.setDoOutput(true); // Turn off caching con.setUseCaches(false); con.setRequestProperty("Content-Type", "text/xml"); con.setReadTimeout(readTimeout); out = con.getOutputStream(); // Write the arguments as post data printWriter = new PrintWriter(out); printWriter.println(xml); printWriter.flush(); //Process response and return back to caller function in = con.getInputStream(); bufferedReader = new BufferedReader(new InputStreamReader(in)); String tempStr = null; int tempClearResponseMessageBufferCounter = 0; while ((tempStr = bufferedReader.readLine()) != null) { tempClearResponseMessageBufferCounter++; //clear the buffer for the first time if (tempClearResponseMessageBufferCounter == 1) responseMessageBuffer.setLength(0); responseMessageBuffer.append(tempStr); } } catch (Exception ex) { throw ex; } finally { System.out.println("Calling finally in POSTXML"); try { if (in != null) in.close(); } catch (Exception eex) { System.out.println("COULD NOT Close Input Stream in try"); } try { if (out != null) out.close(); } catch (Exception eex) { System.out.println("COULD NOT Close Output Stream in try"); } } System.out.println("XMLUtils.postXMLWithTimeout: end ......."); return responseMessageBuffer.toString(); }
From source file:com.digitalgeneralists.assurance.ApplicationDelegate.java
public void performScan(ScanDefinition scanDefinition, boolean merge) { StringBuffer message = new StringBuffer(256); logger.info(message.append("Starting scan with scan defintion: ").append(scanDefinition)); message.setLength(0); message = null;/*from ww w .j a va 2s. c o m*/ PerformScanWorker thread = new PerformScanWorker(scanDefinition, merge, this.notificationProvider); thread.execute(); thread = null; }
From source file:hu.qgears.xtextdoc.util.EscapeString.java
/** * <p>/*from w w w. ja v a 2 s . c om*/ * Unescapes any Java literals found in the <code>String</code> to a * <code>Writer</code>. * </p> * * <p> * For example, it will turn a sequence of <code>'\'</code> and <code>'n'</code> into * a newline character, unless the <code>'\'</code> is preceded by another <code>'\'</code>. * </p> * * <p> * A <code>null</code> string input has no effect. * </p> * * @param out * the <code>Writer</code> used to output unescaped characters * @param str * the <code>String</code> to unescape, may be null * @throws IllegalArgumentException * if the Writer is <code>null</code> * @throws IOException * if error occurs on underlying Writer */ public static void unescapeJava(Writer out, String str) throws IOException { if (out == null) { throw new IllegalArgumentException("The Writer must not be null"); } if (str == null) { return; } int sz = str.length(); StringBuffer unicode = new StringBuffer(4); boolean hadSlash = false; boolean inUnicode = false; for (int i = 0; i < sz; i++) { char ch = str.charAt(i); if (inUnicode) { // if in unicode, then we're reading unicode // values in somehow unicode.append(ch); if (unicode.length() == 4) { // unicode now contains the four hex digits // which represents our unicode character try { int value = Integer.parseInt(unicode.toString(), 16); out.write((char) value); unicode.setLength(0); inUnicode = false; hadSlash = false; } catch (NumberFormatException nfe) { throw new RuntimeException("Unable to parse unicode value: " + unicode, nfe); } } continue; } if (hadSlash) { // handle an escaped value hadSlash = false; switch (ch) { case '\\': out.write('\\'); break; case '\'': out.write('\''); break; case '\"': out.write('"'); break; case 'r': out.write('\r'); break; case 'f': out.write('\f'); break; case 't': out.write('\t'); break; case 'n': out.write('\n'); break; case 'b': out.write('\b'); break; case 'u': { // uh-oh, we're in unicode country.... inUnicode = true; break; } default: out.write(ch); break; } continue; } else if (ch == '\\') { hadSlash = true; continue; } out.write(ch); } if (hadSlash) { // then we're in the weird case of a \ at the end of the // string, let's output it anyway. out.write('\\'); } }
From source file:org.geoserver.wps.security.WpsAccessRule.java
/** * Returns the list of roles as a comma separated string for this rule * *//*from ww w . j a v a2s.c o m*/ public String getValue() { if (roles.isEmpty()) { return WpsAccessRule.ANY; } else { StringBuffer sb = new StringBuffer(); for (String role : roles) { sb.append(role); sb.append(","); } sb.setLength(sb.length() - 1); return sb.toString(); } }
From source file:org.apache.ode.jacob.ChannelListener.java
/** * Get a description of the object for debugging purposes. * * @return human-readable description./* w ww . j a v a 2 s . co m*/ */ public String toString() { StringBuffer buf = new StringBuffer(getClassName()); buf.append('{'); for (Method m : getImplementedMethods()) { buf.append(m.getName()); buf.append("()"); buf.append("&"); } buf.setLength(buf.length() - 1); buf.append('}'); return buf.toString(); }