List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:io.ecarf.core.utils.UsageParser.java
public void parse() throws FileNotFoundException, IOException { for (String file : files) { try (BufferedReader reader = new BufferedReader(new FileReader(file), Constants.GZIP_BUF_SIZE);) { Iterable<CSVRecord> records = CSVFormat.DEFAULT.withHeader().withSkipHeaderRecord().parse(reader); for (CSVRecord record : records) { String[] values = record.values(); String measurement = StringUtils.remove(values[1], MEASURE_PREFIX); this.measurementIds.add(measurement); if (!measurement.contains(CONTAINER_ENGINE_VM)) { if (measurement.contains(VM)) { this.numberOfVms++; this.vms.add(values[4]); }/*w w w .jav a 2 s . c om*/ Usage usage = this.usages.get(measurement); if (usage == null) { usage = new Usage(); this.usages.put(measurement, usage); } long value = Long.parseLong(values[2]); usage.raw += value; if (measurement.contains(VM)) { long adjusted = value; // minimum billable is 10 minutes for VMs if (adjusted < MIN_BILL) { adjusted = MIN_BILL; } // round up value to the nearest minute adjusted = (long) (MINUTE * Math.ceil(adjusted / 60.0)); usage.value += adjusted; // hourly based billing adjusted = value; if (adjusted < HOUR) { adjusted = HOUR; } else { adjusted = (long) (HOUR * Math.ceil(adjusted / 3600.0)); } usage.adjusted += adjusted; } } else { // container engine vms System.out.println(StringUtils.join(values, ',')); } } } } for (String measureId : this.measurementIds) { System.out.println(measureId); } System.out.println("Total number of VMs: " + this.numberOfVms); System.out.println(this.vms); System.out.println(this.vms.size()); for (Entry<String, Usage> entry : this.usages.entrySet()) { Usage usage = entry.getValue(); System.out.println(entry.getKey() + ',' + usage.raw + ',' + usage.value + ',' + usage.adjusted); } }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.AgentNameCleanupParserDlg.java
/** * @param str//from w w w . j a v a2 s .co m * @return */ private boolean doIncludeStr(final String str) { if (StringUtils.isNotEmpty(str)) { String lower = StringUtils.remove(str.toLowerCase(), '.'); if (lower.startsWith("ltd") || lower.startsWith("exp") || lower.equals("party") || lower.equals("etal") || lower.equals("et al") || lower.equals("et") || lower.equals("mrs") || lower.equals("mr") || StringUtils.isNumeric(lower)) { return false; } return true; } return true; }
From source file:de.alpharogroup.xsl.transform.XsltTransformerUtilsTest.java
@Test(enabled = true) public void testTransformSourceSourceOutputStream() throws TransformerException, IOException { final File resDestDir = PathFinder.getSrcTestResourcesDir(); final String[] dirsAndFilename = { "de", "alpharogroup", "xsl", "transform", "birthdates.xml" }; final File xmlFile = PathFinder.getRelativePath(resDestDir, dirsAndFilename); final File xsltFile = PathFinder.getRelativePathTo(resDestDir, "\\.", "de.alpharogroup.xsl.transform", "functions.xsl"); final InputStream is = StreamUtils.getInputStream(xsltFile); final Source xsltSource = new StreamSource(is); final InputStream xmlIs = StreamUtils.getInputStream(xmlFile); final File outputFile = PathFinder.getRelativePathTo(resDestDir, "\\.", "de.alpharogroup.xsl.transform", "data_02_output.xml"); final OutputStream output = StreamUtils.getOutputStream(outputFile, true); final Source xmlSource = new StreamSource(xmlIs); XsltTransformerUtils.transform(xmlSource, xsltSource, output); String actual = ReadFileUtils.readFromFile(outputFile); actual = StringUtils.remove(actual, '\r'); actual = StringUtils.remove(actual, '\n'); expected = StringUtils.remove(expected, '\r'); expected = StringUtils.remove(expected, '\n'); AssertJUnit.assertTrue("", expected.equals(actual)); }
From source file:de.alpharogroup.xsl.transform.XsltTransformerExtensionsTest.java
@Test(enabled = true) public void testTransformSourceSourceOutputStream() throws TransformerException, IOException { final File resDestDir = PathFinder.getSrcTestResourcesDir(); final String[] dirsAndFilename = { "de", "alpharogroup", "xsl", "transform", "birthdates.xml" }; final File xmlFile = PathFinder.getRelativePath(resDestDir, dirsAndFilename); final File xsltFile = PathFinder.getRelativePathTo(resDestDir, "\\.", "de.alpharogroup.xsl.transform", "functions.xsl"); final InputStream is = StreamExtensions.getInputStream(xsltFile); final Source xsltSource = new StreamSource(is); final InputStream xmlIs = StreamExtensions.getInputStream(xmlFile); final File outputFile = PathFinder.getRelativePathTo(resDestDir, "\\.", "de.alpharogroup.xsl.transform", "data_02_output.xml"); final OutputStream output = StreamExtensions.getOutputStream(outputFile, true); final Source xmlSource = new StreamSource(xmlIs); XsltTransformerExtensions.transform(xmlSource, xsltSource, output); String actual = ReadFileExtensions.readFromFile(outputFile); actual = StringUtils.remove(actual, '\r'); actual = StringUtils.remove(actual, '\n'); expected = StringUtils.remove(expected, '\r'); expected = StringUtils.remove(expected, '\n'); AssertJUnit.assertTrue("", expected.equals(actual)); }
From source file:com.theserverlabs.maven.utplsq.ResultSplitter.java
/** * Separates Assert Test description from attached results and setTestName * in dc.//from w w w. j a v a2 s.c om * * @param dc the unscrambled results object * @param testStr typically the 2nd colon string from UTR_OUTCOME table * @return the results that were appended to testStr or null */ private static String extractAndSetTestName(DescContainer dc, String testStr) { int resultPos = testStr.indexOf(RESULT_BLOCK_1); String testName, resultsStr = null; if (resultPos > 0) { testName = testStr.substring(0, resultPos); } else // Unable to identify a results section, maybe its the EQ form? { int expectedPos = testStr.indexOf(RESULT_BLOCK_2); if (expectedPos > 0) { testName = testStr.substring(0, expectedPos); resultsStr = StringUtils.remove(testStr.substring(expectedPos + 1).trim(), '"'); } else { testName = testStr; } } dc.setTestName(testName.trim()); return resultsStr; }
From source file:de.hybris.platform.storefront.controllers.pages.checkout.steps.AbstractCheckoutStepController.java
@ModelAttribute("checkoutSteps") public List<CheckoutSteps> addCheckoutStepsToModel() { final CheckoutGroup checkoutGroup = getCheckoutFlowGroupMap() .get(getCheckoutFacade().getCheckoutFlowGroupForCheckout()); final Map<String, CheckoutStep> progressBarMap = checkoutGroup.getCheckoutProgressBar(); final List<CheckoutSteps> checkoutSteps = new ArrayList<CheckoutSteps>(progressBarMap.size()); for (final Map.Entry<String, CheckoutStep> entry : progressBarMap.entrySet()) { final CheckoutStep checkoutStep = entry.getValue(); checkoutSteps.add(new CheckoutSteps(checkoutStep.getProgressBarId(), StringUtils.remove(checkoutStep.currentStep(), "redirect:"), Integer.valueOf(entry.getKey()))); }/*w w w . j a va 2 s. c o m*/ return checkoutSteps; }
From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.application.SQLToMyBatisConvert.java
/** * make some sql// w ww .ja v a 2 s.c o m * @param sql * @return */ private static String makeSomeSQL(String sql) { StringBuffer sbSQL = new StringBuffer(); StringBuffer strLine; StringBuffer strConst; sql = StringUtils.remove(sql, ";"); String[] splists = StringUtils.split(sql, PublicTadpoleDefine.LINE_SEPARATOR); int idx = 1; for (String part : splists) { if (!"".equals(StringUtils.trimToEmpty(part))) { sbSQL.append("\t"); part = SQLTextUtil.delLineChar(part); strLine = new StringBuffer(); strConst = new StringBuffer(); boolean isOpen = false; for (int p = 0; p < part.length(); p++) { if (!isOpen & '\'' == part.charAt(p)) { strLine.append("#{"); strConst.append("/* '"); isOpen = true; } else if (isOpen & '\'' == part.charAt(p)) { strLine.append("param_" + idx++ + "}"); strConst.append("' */"); isOpen = false; } else if (!isOpen) { strLine.append(part.charAt(p)); } else if (isOpen) { strConst.append(part.charAt(p)); } } sbSQL.append(strLine.toString() + strConst.toString()); sbSQL.append(PublicTadpoleDefine.LINE_SEPARATOR); } //if Empty } //for return sbSQL.toString(); }
From source file:edu.cornell.kfs.fp.businessobject.USBankRecordFieldUtils.java
/** * Extracts a KualiDecimal representing dollars and cents from a substring less any ending whitespace * for a given beginning and ending position. * //from w ww.ja v a 2s .c om * @param line Superstring * @param begin Beginning index * @param end Ending index * @param lineCount The current line number * @return The KualiDecimal parsed from the trimmed substring * @throws ParseException When unable to parse the KualiDecimal */ public static KualiDecimal extractDecimalWithCents(String line, int begin, int end, int lineCount) throws ParseException { KualiDecimal theDecimal; KualiDecimal theCents; try { String sanitized = line.substring(begin, end - 2); sanitized = StringUtils.remove(sanitized, '-'); sanitized = StringUtils.remove(sanitized, '+'); theDecimal = new KualiDecimal(sanitized); theCents = new KualiDecimal(line.substring(end - 2, end)); theCents = theCents.multiply(new KualiDecimal("0.01")); theDecimal = theDecimal.add(theCents); } catch (StringIndexOutOfBoundsException | IllegalArgumentException e) { // May encounter a StringIndexOutOfBoundsException if the string bounds do not match or // an IllegalArgumentException if the Decimal or Cents do not parse correctly throw new ParseException( "Unable to parse " + line.substring(begin, end) + " into a decimal value on line " + lineCount, lineCount); } return theDecimal; }
From source file:hydrograph.ui.perspective.dialog.PreStartActivity.java
private static boolean checkJDKVersion(String jdkVersion, boolean showPopupAndExit) { jdkVersion = StringUtils.removeStart(jdkVersion, "jdk"); jdkVersion = StringUtils.remove(jdkVersion, "."); jdkVersion = StringUtils.remove(jdkVersion, "_"); long version = Long.parseLong(jdkVersion); if (version >= REQUIRED_JDK_VERSION) { return true; }//from w w w .j a v a 2 s .c o m if (showPopupAndExit) { showInvalidJavaHomeDialogAndExit(); } return false; }
From source file:com.dream.messaging.engine.fixformat.FixformatDataHandler.java
@Override public Object createMessageData(Object objData, Node node) throws DataConvertException { // if the objData is the byte[],return directly if (objData instanceof byte[]) { return objData; }/*from w w w . j a v a 2 s . c o m*/ String formatedString = this.createStringMessage(objData, node); if (formatedString == null) { return null; } String format = QueryNode.getAttribute(node, ElementAttr.Attr_Format); ElementFormat elementFormat = null; if (format != null) { try { elementFormat = new ElementFormat(format); } catch (ElementFormatParseException e) { throw new DataConvertException( "ElementFormatParseException occurs when institiated the object ElementFormat", e); } } // must define the length in fixformat int length = Integer.parseInt(QueryNode.getAttribute(node, ElementAttr.Attr_Length)); if (objData instanceof Number) {// || isNumber(clsname) // must define the format if this is a Number // remove point first if ((elementFormat != null) && elementFormat.isHasPoint()) { formatedString = StringUtils.remove(formatedString, "."); } // move the sign to the end of the number if (formatedString.startsWith("-") || formatedString.startsWith("+")) { String sign = formatedString.substring(0, 1); formatedString = formatedString.substring(1) + sign; } return this.fillUpAsByteArray(formatedString, length, true); } else { return this.fillUpAsByteArray(formatedString, length, false); } }