List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:com.entertailion.android.shapeways.api.Request.java
public String toString() { StringBuffer stringBuffer = new StringBuffer(); for (String parameter : parameters) { if (stringBuffer.length() != 0) { stringBuffer.append(ShapewaysClient.AMPERSAND); }// www . ja v a 2 s.c om stringBuffer.append(parameter); } return stringBuffer.toString(); }
From source file:org.culturegraph.mf.stream.converter.JsonEncoder.java
@Override public void startRecord(final String id) { final StringBuffer buffer = writer.getBuffer(); buffer.delete(0, buffer.length()); startGroup(id);/*from w w w . ja v a2 s. c o m*/ }
From source file:com.linuxbox.enkive.imap.message.EnkiveImapTemplateMessage.java
@Override public long getFullContentOctets() { StringWriter stringWriter = new StringWriter(); try {/* w w w . ja v a 2 s . c om*/ messageBody.process(root, stringWriter); } catch (TemplateException e) { LOGGER.error("Error producing IMAP Inbox message from template", e); } catch (IOException e) { LOGGER.error("Error producing IMAP Inbox message from template", e); } StringBuffer message = stringWriter.getBuffer(); return headers.length() + message.length(); }
From source file:edu.scripps.fl.curves.plot.GCurvePlot.java
public void addCurve(Curve curve, FitFunction function) { double[] yValues = (double[]) ConvertUtils.convert(curve.getResponses(), double[].class); double curveMinY = NumberUtils.min(yValues); double curveMaxY = NumberUtils.max(yValues); this.minY = Math.min(minY, curveMinY); this.maxY = Math.min(maxY, curveMaxY); Data yData = DataUtil.scaleWithinRange(curveMinY, curveMaxY, yValues); double[] xValues = (double[]) ConvertUtils.convert(curve.getConcentrations(), double[].class); for (int ii = 0; ii < xValues.length; ii++) { double x = Math.log10(xValues[ii]); xValues[ii] = x;/*from w ww. j a va 2 s . c o m*/ } double curveMinX = NumberUtils.min(xValues); double curveMaxX = NumberUtils.max(xValues); this.minX = Math.min(minX, curveMinX); this.maxX = Math.min(maxX, curveMaxX); Data xData = DataUtil.scaleWithinRange(NumberUtils.min(xValues), NumberUtils.max(xValues), xValues); String hexColor = Integer .toHexString(((java.awt.Color) drawingSupplier.getNextPaint()).getRGB() & 0x00ffffff); StringBuffer sb = new StringBuffer(); sb.append(hexColor); while (sb.length() < 6) sb.insert(0, "0"); Color color = Color.newColor(sb.toString()); XYLine line1 = Plots.newXYLine(xData, yData, getBackgroundColor(), ""); // line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0)); line1.addShapeMarkers(Shape.CIRCLE, color, 5); XYLine fittedLine = sampleFunctionToLine(curve, function, curveMinX, curveMaxX, 100); // fittedLine.setLineStyle(LineStyle.newLineStyle(3, 1, 0)); fittedLine.setColor(color); lines.add(line1); lines.add(fittedLine); }
From source file:com.icesoft.faces.webapp.parser.JsfJspDigester.java
/** * This member gets the previous body text and returns it. It also clears * out that body text from the parent./*from w w w. j av a 2 s . com*/ * * @return The parent's body text. */ public String stealParentBodyText() { StringBuffer parentBodyText = (StringBuffer) bodyTexts.peek(); if (parentBodyText == null || parentBodyText.length() == 0) { return null; } String returnString = new String(parentBodyText.toString()); if (returnString.trim().length() == 0) { // Don't want to create whitespace only components; returnString = null; } // Get rid of body text that we just processed; parentBodyText.delete(0, parentBodyText.length()); return returnString; }
From source file:org.springmodules.validation.valang.functions.BeanPropertyFunction.java
private String concat(String[] path) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < path.length; i++) { sb.append(path[i]);/*w ww . ja va 2 s . c o m*/ sb.append("."); } sb.setLength(sb.length() - 1); return sb.toString(); }
From source file:com.exilant.eGov.src.reports.GeneralLedgerReport.java
public static StringBuffer numberToString(final String strNumberToConvert) { String strNumber = "", signBit = ""; if (strNumberToConvert.startsWith("-")) { strNumber = "" + strNumberToConvert.substring(1, strNumberToConvert.length()); signBit = "-"; } else//from w ww .jav a 2s .c om strNumber = "" + strNumberToConvert; final DecimalFormat dft = new DecimalFormat("##############0.00"); final String strtemp = "" + dft.format(Double.parseDouble(strNumber)); StringBuffer strbNumber = new StringBuffer(strtemp); final int intLen = strbNumber.length(); for (int i = intLen - 6; i > 0; i = i - 2) strbNumber.insert(i, ','); if (signBit.equals("-")) strbNumber = strbNumber.insert(0, "-"); return strbNumber; }
From source file:com.panet.imeta.core.row.ValueDataUtil.java
/** * Alternate faster version of string replace using a stringbuffer as input. * // ww w . j a va 2s. c om * @param str The string where we want to replace in * @param code The code to search for * @param repl The replacement string for code */ public static void replaceBuffer(StringBuffer str, String code, String repl) { int clength = code.length(); int i = str.length() - clength; while (i >= 0) { String look = str.substring(i, i + clength); if (look.equalsIgnoreCase(code)) // Look for a match! { str.replace(i, i + clength, repl); } i--; } }
From source file:de.suse.swamp.core.filter.TaskFilter.java
public String getSQL() { ArrayList columns = new ArrayList(); ArrayList tables = new ArrayList(); ArrayList conditions = new ArrayList(); columns.add("dbWorkflows.wfid"); tables.add("dbWorkflows"); tables.add("dbTasks"); conditions.add("dbTasks.workflowID = dbWorkflows.wfid"); if (actionNames != null) { if (descending == null) { conditions.add("dbTasks.state = " + WorkflowTask.ACTIVE); StringBuffer sqlActions = new StringBuffer(); for (Iterator it = actionNames.iterator(); it.hasNext();) { if (sqlActions.length() > 0) sqlActions.append(","); sqlActions.append("'").append(StringEscapeUtils.escapeSql((String) it.next())).append("'"); }/*from w w w . j a va 2 s. co m*/ conditions.add("dbTasks.actionName IN (" + sqlActions.toString() + ")"); } else { orderColumn = "dbTasks.actionName"; } } else if (isRunning != null) { if (descending == null) { if (isRunning == Boolean.TRUE) { conditions.add("dbTasks.state = " + WorkflowTask.ACTIVE); } } else { orderColumn = "dbWorkflows.wfid"; } } else { Logger.ERROR("Trying to use uninitialized Filter!"); } return buildSQLString(columns, tables, conditions); }
From source file:com.entertailion.android.shapeways.api.Request.java
/** * Sign the request based on OAuth 1.0// w ww. j a v a2 s . c o m * * @param url * @param consumerSecret * @param tokenSecret * @throws Exception */ public void sign(String url, String consumerSecret, String tokenSecret) throws Exception { Log.d(LOG_TAG, "sign: " + url); addParameter(ShapewaysClient.OAUTH_SIGNATURE_METHOD, ShapewaysClient.OAUTH_SIGNATURE_METHOD_HMAC_SHA1); addParameter(ShapewaysClient.OAUTH_VERSION, ShapewaysClient.OAUTH_VERSION_1_0); addParameter(ShapewaysClient.OAUTH_NONCE, RandomStringUtils.randomAlphanumeric(32)); addParameter(ShapewaysClient.OAUTH_TIMESTAMP, Long.toString(System.currentTimeMillis() / 1000)); StringBuffer stringBuffer = new StringBuffer(); for (String parameter : parameters) { if (stringBuffer.length() != 0) { stringBuffer.append(ShapewaysClient.AMPERSAND); } stringBuffer.append(parameter); } String baseString = String.format("%s&%s&%s", encode(httpMethod), encode(normalize(url)), encode(stringBuffer.toString())); Log.d(LOG_TAG, "base=" + baseString); addParameter(ShapewaysClient.OAUTH_SIGNATURE, generateHmac(encode(consumerSecret) + ShapewaysClient.AMPERSAND + encode(tokenSecret), baseString)); }