List of usage examples for java.lang String concat
public String concat(String str)
From source file:com.github.cereda.arara.rulechecker.RuleUtils.java
/** * Prints the report for every rule report. * @param rules The list of rule report. *///from w ww. ja v a 2 s .c o m public static void printReport(List<RuleReport> rules) { // print header System.out.println(StringUtils.center(" Task coverage report ", 60, "-").concat("\n")); // let's sort our list of reports according to // each rule coverage Collections.sort(rules, new Comparator<RuleReport>() { @Override public int compare(RuleReport t1, RuleReport t2) { // get values of each rule float a1 = t1.getCoverage(); float a2 = t2.getCoverage(); // they are equal, do nothing if (a1 == a2) { return 0; } else { // we want to sort in reverse order, // so return a negative value here if (a1 > a2) { return -1; } else { // return a positive value, since // the first statement was false return 1; } } } }); // for each report, print // the corresponding entry for (RuleReport rule : rules) { // build the beginning of the line String line = String.format("- %s ", rule.getReference().getName()); // build the coverage information String coverage = String.format(" %2.2f%%", rule.getCoverage()); // generate the line by concatenating // the beginning and coverage line = line.concat(StringUtils.repeat(".", 60 - line.length() - coverage.length())).concat(coverage); // print the line System.out.println(line); } }
From source file:edu.wpi.khufnagle.webimagemanager.WebImageManager.java
private static String calculateElapsedTime(final long estimatedTime) { String output = ""; final double numSecondsPrecise = estimatedTime / 1000000000.0; int numSeconds = (int) (numSecondsPrecise + 0.5); int numMinutes = 0; numMinutes = numSeconds / 60;//from ww w . ja v a2 s . com numSeconds = numSeconds % 60; if (numMinutes > 0) { if (numMinutes == 1) { output = output.concat("1 minute"); } else { output = output.concat(numMinutes + " minutes"); } } // At "even" minute markers (exactly 2 minutes), don't record seconds // value if (numMinutes == 0 || numMinutes > 0 && numSeconds != 0) { if (numSeconds == 1) { output = output.concat(" 1 second"); } else { output = output.concat(" " + numSeconds + " seconds"); } } return output; }
From source file:com.kakao.hbase.stat.print.Color.java
/** * Extracted from org.apache.commons.lang.StringUtils *//*from w w w .j a v a 2s. c o m*/ static String leftPad(String str, int size, String padStr, Formatter.Type formatType) { if (str == null) { return null; } if (isEmpty(padStr)) { padStr = " "; } int padLen = padStr.length(); int strLen = lengthWithoutColor(str, formatType); int pads = size - strLen; if (pads <= 0) { return str; // returns original String when possible } if (padLen == 1 && pads <= PAD_LIMIT) { return leftPad(str, size, padStr.charAt(0), formatType); } if (pads == padLen) { return padStr.concat(str); } else if (pads < padLen) { return padStr.substring(0, pads).concat(str); } else { char[] padding = new char[pads]; char[] padChars = padStr.toCharArray(); for (int i = 0; i < pads; i++) { padding[i] = padChars[i % padLen]; } return new String(padding).concat(str); } }
From source file:com.opensymphony.xwork2.util.TextParseUtil.java
/** * Converted object from variable translation. * * @param open//w ww. ja v a 2 s .c o m * @param expression * @param stack * @param asType * @param evaluator * @return Converted object from variable translation. */ public static Object translateVariables(char[] openChars, String expression, ValueStack stack, Class asType, ParsedValueEvaluator evaluator, int maxLoopCount) { // deal with the "pure" expressions first! //expression = expression.trim(); Object result = expression; for (char open : openChars) { int loopCount = 1; int pos = 0; //this creates an implicit StringBuffer and shouldn't be used in the inner loop final String lookupChars = open + "{"; while (true) { int start = expression.indexOf(lookupChars, pos); if (start == -1) { pos = 0; loopCount++; start = expression.indexOf(lookupChars); } if (loopCount > maxLoopCount) { // translateVariables prevent infinite loop / expression recursive evaluation break; } int length = expression.length(); int x = start + 2; int end; char c; int count = 1; while (start != -1 && x < length && count != 0) { c = expression.charAt(x++); if (c == '{') { count++; } else if (c == '}') { count--; } } end = x - 1; if ((start != -1) && (end != -1) && (count == 0)) { String var = expression.substring(start + 2, end); Object o = stack.findValue(var, asType); if (evaluator != null) { o = evaluator.evaluate(o); } String left = expression.substring(0, start); String right = expression.substring(end + 1); String middle = null; if (o != null) { middle = o.toString(); if (StringUtils.isEmpty(left)) { result = o; } else { result = left.concat(middle); } if (StringUtils.isNotEmpty(right)) { result = result.toString().concat(right); } expression = left.concat(middle).concat(right); } else { // the variable doesn't exist, so don't display anything expression = left.concat(right); result = expression; } pos = (left != null && left.length() > 0 ? left.length() - 1 : 0) + (middle != null && middle.length() > 0 ? middle.length() - 1 : 0) + 1; pos = Math.max(pos, 1); } else { break; } } } XWorkConverter conv = ((Container) stack.getContext().get(ActionContext.CONTAINER)) .getInstance(XWorkConverter.class); return conv.convertValue(stack.getContext(), result, asType); }
From source file:com.liferay.cucumber.util.StringUtil.java
public static String quote(String s, String quote) { if (s == null) { return null; }//from w w w. j a v a2 s . com return quote.concat(s).concat(quote); }
From source file:es.juntadeandalucia.panelGestion.negocio.utiles.Utils.java
/** * TODO//w w w. j av a 2 s . c o m * * @param serviceUrl * @return */ public static String getWorkspaceFromServiceUrl(String serviceUrl) { String workspace = null; GeoserverVO geoserver = getGeoserverVOByURL(serviceUrl); String geoserverUrl = geoserver.getGeoserverUrl(); if (serviceUrl.startsWith(geoserverUrl)) { String geoserverSlashUrl = geoserverUrl.concat("/"); String workspaceAndParameters = serviceUrl.replace(geoserverSlashUrl, ""); int idxSlash = workspaceAndParameters.indexOf("/"); workspace = workspaceAndParameters.substring(0, idxSlash); } return workspace; }
From source file:com.eurotong.orderhelperandroid.Common.java
public static String GetDeviceUniqueID() { //http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id/2853253#2853253 String android_id = Secure.getString(MyApplication.getAppContext().getContentResolver(), Secure.ANDROID_ID); long id = -1; long idMod = 0; String idString = "UNKNOWN"; if (android_id != null) { id = abs(android_id.hashCode()); //could get negative value idString = Long.toString(id); idString = idString.concat("0000000000").substring(0, 10); id = Long.parseLong(idString); idMod = id % Define.MOD;/*w ww.java 2 s . c o m*/ String idModString = Long.toString(idMod); idModString = "00".concat(idModString); idModString = idModString.substring(idModString.length() - 2, idModString.length()); idString = Long.toString(id) + idModString; //id=id / 10000; } return idString; }
From source file:net.sf.jabref.logic.util.io.FileUtil.java
private static File shortenFileName(File fileName, String directory) { if ((fileName == null) || !fileName.isAbsolute() || (directory == null)) { return fileName; }// w w w. j av a 2 s . co m String dir = directory; String longName; if (OS.WINDOWS) { // case-insensitive matching on Windows longName = fileName.toString().toLowerCase(); dir = dir.toLowerCase(); } else { longName = fileName.toString(); } if (!dir.endsWith(FILE_SEPARATOR)) { dir = dir.concat(FILE_SEPARATOR); } if (longName.startsWith(dir)) { // result is based on original name, not on lower-cased name String newName = fileName.toString().substring(dir.length()); return new File(newName); } else { return fileName; } }
From source file:eu.optimis.tf.ip.service.utils.PropertiesUtils.java
public static String getConfigFilePath(String configFile) { String optimisHome = System.getenv("OPTIMIS_HOME"); //log.info(optimisHome); if (optimisHome == null) { if (System.getProperty("file.separator").equalsIgnoreCase("/")) { optimisHome = "/opt/optimis"; log.debug("TRUST: OPTIMIS_HOME: " + optimisHome + " (DEFAULT)"); } else {/*w w w . j a v a2s.co m*/ optimisHome = "d:\\opt\\optimis"; log.debug("TRUST: OPTIMIS_HOME: " + optimisHome + " (DEFAULT)"); } } else { log.debug("TRUST: OPTIMIS_HOME: " + optimisHome); } File fileObject = new File(optimisHome.concat(configFile)); if (!fileObject.exists()) { try { createDefaultConfigFile(fileObject); } catch (Exception ex) { log.error("TRUST: Error reading " + optimisHome.concat(configFile) + " configuration file: " + ex.getMessage()); ex.printStackTrace(); } } return optimisHome.concat(configFile); }
From source file:com.albert.util.StringUtilCommon.java
public static String maskSin(String sin) { if (isEmpty(sin) || isEmpty(sin.trim()) || sin.equals("0")) { return null; } else {//from w w w. j a va2 s . c o m String last3Digit = sin.substring(6); String mask = "******"; String maskedSin = mask.concat(last3Digit); return maskedSin; } }