List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:byps.BBufferJson.java
public void putByte(char v) { putJsonValueAscii(null, Character.toString(v), STRING_WITHOUT_QUOTE); }
From source file:org.easyrec.utils.io.autoimport.AutoImportUtils.java
public static String retrieveTypeFromLine(String line) { // syntax: '# type: <TYPE_OF_FILE>' StringBuilder errorMsgBuffer = new StringBuilder("this line doesn't contain a valid type, line must be: '"); errorMsgBuffer.append(VALID_TYPE);/*w ww . j a v a2s .com*/ errorMsgBuffer.append("', but was: '"); errorMsgBuffer.append(line); errorMsgBuffer.append("'"); String errorMsg = errorMsgBuffer.toString(); // check '#' line = line.trim(); String csvComment = Character.toString(CSV_COMMENT_CHAR); if (!line.startsWith(csvComment)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(csvComment) + csvComment.length()); // check 'type' line = line.trim(); if (!line.startsWith(CSV_TYPE)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(CSV_TYPE) + CSV_TYPE.length()); // check ':' line = line.trim(); if (!line.startsWith(CSV_DELIMITER)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(CSV_DELIMITER) + CSV_DELIMITER.length()); // retrieve type of file, for e.g. 'itemassoc' or 'action' return line.trim(); }
From source file:cz.swi2.mendeluis.dataaccesslayer.repository.BaseRepository.java
/** * Vrati nazev tabulky v db pro danou entitu. * @return string nazev tabulky//from w w w .j ava 2s. c o m */ protected String getTableName() { String tableName = this.tEntityType.getSimpleName(); // Pokud m entita anotaci Table, na?teme definovan jmno Table tableAnotation = this.tEntityType.getAnnotation(Table.class); //Ovme existenci anotace a validitu jmna if (tableAnotation != null) { String anotName = tableAnotation.name(); if (anotName.trim().length() > 0) { tableName = anotName; } } // make first letter upper tableName = Character.toString(tableName.charAt(0)).toUpperCase() + tableName.substring(1); return tableName; }
From source file:com.itude.mobile.android.util.StringUtil.java
/** * Strip the given {@link String} with the given character * //from www . j a va2 s .c o m * @param inputString {@link String} to be stripped * @param stripCharacter strip character * @return Stripped {@link String} */ public static String stripCharacter(String inputString, char stripCharacter) { return inputString.replaceAll(Pattern.quote(Character.toString(stripCharacter)), ""); }
From source file:nl.vpro.jcr.criteria.query.criterion.SimpleExpression.java
@Override public String toXPathString(Criteria criteria) throws JCRQueryException { StringBuilder fragment = new StringBuilder(); fragment.append(" ("); if (value instanceof String) { fragment.append(propertyName).append(getOp()); // Generally, if you enclose values in single quotes, you just need to replace any literal single quote // character with '' (two consecutive single quote characters). String escValue = StringUtils.replace((String) value, "'", "''"); fragment.append("'").append(escValue).append("') "); } else if (value instanceof Number) { fragment.append(propertyName).append(getOp()); fragment.append(value).append(") "); } else if (value instanceof Character) { fragment.append(propertyName).append(getOp()); fragment.append("'").append(Character.toString((Character) value)).append("') "); } else if (value instanceof Boolean) { if ((Boolean) value) { fragment.append(propertyName).append(getOp()); fragment.append(value).append(") "); } else {/*from w w w .ja v a 2 s .c o m*/ // false should also match a missing boolean property fragment.append("("); fragment.append(propertyName).append(getOp()); fragment.append(value).append(") or not(").append(propertyName).append(" ))"); } } else if (value instanceof Calendar) { fragment.append(propertyName).append(getOp()); Calendar cal = (Calendar) value; fragment.append(XS_DATETIME_FUNCTION + "('").append(XPathTextUtils.toXsdDate(cal)).append("')) "); } else if (value != null) { fragment.append(propertyName).append(getOp()); // just use the toString() of the given object fragment.append("'").append(value).append("') "); } log.debug("xpathString is {} ", fragment); return fragment.toString(); }
From source file:com.stimulus.archiva.domain.FileSystem.java
public void setApplicationPath(String applicationPath) { if (applicationPath.endsWith(Character.toString(File.separatorChar))) this.applicationPath = applicationPath.substring(0, applicationPath.length() - 1); else/* w w w . ja v a 2s.c om*/ this.applicationPath = applicationPath; logger.debug("setApplicationPath {path='" + applicationPath + "'}"); }
From source file:byps.BBufferJson.java
public void putChar(char v) { putString(null, v != 0 ? Character.toString(v) : ""); }
From source file:com.salesmanager.core.module.impl.application.currencies.GenericCurrencyModule.java
public BigDecimal getAmount(String amount) throws Exception { // validations /**//from www . j av a2s . com * 1) remove decimal and thousand * * String.replaceAll(decimalPoint, ""); String.replaceAll(thousandPoint, * ""); * * Should be able to parse to Integer */ StringBuffer newAmount = new StringBuffer(); for (int i = 0; i < amount.length(); i++) { if (amount.charAt(i) != decimalPoint && amount.charAt(i) != thousandPoint) { newAmount.append(amount.charAt(i)); } } try { Integer.parseInt(newAmount.toString()); } catch (Exception e) { throw new ValidationException("Cannot parse " + amount); } if (!amount.contains(Character.toString(decimalPoint)) && !amount.contains(Character.toString(thousandPoint)) && !amount.contains(" ")) { if (CurrencyModuleUtil.matchPositiveInteger(amount)) { BigDecimalValidator validator = CurrencyValidator.getInstance(); BigDecimal bdamount = validator.validate(amount, Locale.US); if (bdamount == null) { throw new ValidationException("Cannot parse " + amount); } else { return bdamount; } } else { throw new ValidationException("Not a positive integer " + amount); } } else { StringBuffer pat = new StringBuffer(); if (!StringUtils.isBlank(Character.toString(thousandPoint))) { pat.append("\\d{1,3}(" + thousandPoint + "?\\d{3})*"); } pat.append("(\\" + decimalPoint + "\\d{1," + decimalCount + "})"); Pattern pattern = Pattern.compile(pat.toString()); Matcher matcher = pattern.matcher(amount); if (matcher.matches()) { Locale locale = Locale.US; if (this.decimalPoint == ',') { locale = Locale.GERMAN; } BigDecimalValidator validator = CurrencyValidator.getInstance(); BigDecimal bdamount = validator.validate(amount, locale); return bdamount; } else { throw new ValidationException("Cannot parse " + amount); } } }
From source file:com.predic8.membrane.core.util.TextUtil.java
public static Object capitalize(String english) { if (english.length() == 0) return ""; return Character.toString(Character.toUpperCase(english.charAt(0))) + english.substring(1); }
From source file:io.manasobi.utils.RandomUtils.java
/** * ?? ? ??? ? ?? .<br>/*from w ww.j ava2 s . c om*/ * ASCII CODE startChar ?? endChar? ??.<br><br> * * RandomUtils.getString(10, 'B', 'r') = FoOXjRmmMr * * @param count ? ? ? * @param startChar * @param endChar ?? * @return ?? ? ? */ public static String getString(int count, String startChar, String endChar) { int startInt = Integer.valueOf(CharUtils.toChar(startChar)); int endInt = Integer.valueOf(CharUtils.toChar(endChar)); int gap = endInt - startInt; StringBuilder buf = new StringBuilder(); for (int i = 0; i < count; i++) { int chInt; do { chInt = GENERATOR.nextInt(gap + 1) + startInt; } while (!Character.toString((char) chInt).matches("^[a-zA-Z]$")); buf.append((char) chInt); } return buf.toString(); }