List of usage examples for java.lang Character toString
public String toString()
From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java
public static String getFirstLetter(String name) { for (Character c : name.toCharArray()) { if (Character.isLetterOrDigit(c)) { return c.toString(); }//from w w w. j av a 2s. com } return "X"; }
From source file:com.moviejukebox.tools.StringTools.java
/** * Check the passed character against the replacement list. * * @param charToReplace// w w w . j a v a 2 s. c o m * @return */ public static String characterMapReplacement(Character charToReplace) { Character tempC = CHAR_REPLACEMENT_MAP.get(charToReplace); if (tempC == null) { return charToReplace.toString(); } return tempC.toString(); }
From source file:cn.vlabs.umt.ui.servlet.OauthTokenServlet.java
private static long tansferTime(String time) { Character end = time.charAt(time.length() - 1); if ("d".equalsIgnoreCase(end.toString())) { return 24l * 3600l * 1000l * Long.parseLong((time.substring(0, time.length() - 1))); } else if ("h".equalsIgnoreCase(end.toString())) { return 3600l * 1000l * Long.parseLong(time.substring(0, time.length() - 1)); } else {// w w w.j ava 2 s . co m return 24l * 3600l * 1000l * Long.parseLong(time.substring(0, time.length())); } }
From source file:nl.systemsgenetics.cellTypeSpecificAlleleSpecificExpression.ReadGenoAndAsFromIndividual.java
public static String get_allele_specific_overlap_at_snp(GeneticVariant this_variant, int sample_index, String chromosome, String position, SamReader bam_file) { int pos_int = Integer.parseInt(position); Alleles all_variants = this_variant.getVariantAlleles(); Character ref_allele_char = all_variants.getAllelesAsChars()[0]; String ref_allele = ref_allele_char.toString(); //System.out.println("ref_allele: " + ref_allele); Character alt_allele_char = all_variants.getAllelesAsChars()[1]; String alt_allele = alt_allele_char.toString(); //System.out.println("alt_allele: " + alt_allele); int ref_overlap = 0; int alt_overlap = 0; int no__overlap = 0; // now determine per individual the sample variants. // I'm assuming the ordering is the same as the individual names created // by the getSampleNames() method. // Otherwise the data will be nicely permuted, and I will have to convert some stuff. int i = 0;//from w w w .jav a2 s .c o m String temp_string; int position_of_snp = Integer.parseInt(position); SAMRecordIterator all_reads_in_region; all_reads_in_region = bam_file.queryOverlapping(chromosome, position_of_snp, position_of_snp); // Right now assuming the above iterator provides me with reads. // Otherwise, I don't know. String bases = ""; while (all_reads_in_region.hasNext()) { SAMRecord read_in_region = all_reads_in_region.next(); Character base_in_read = get_base_at_position(read_in_region, pos_int); //System.out.println("base_in_read: " + base_in_read); if (base_in_read == ref_allele.charAt(0)) { ref_overlap++; } else if (base_in_read == alt_allele.charAt(0)) { alt_overlap++; } else if (base_in_read == '!' || base_in_read == 'N') { continue; } else { no__overlap++; } } //This line below cost me a day to figure out the error. all_reads_in_region.close(); String string_for_output; string_for_output = Integer.toString(ref_overlap) + "\t" + Integer.toString(alt_overlap) + "\t" + Integer.toString(no__overlap); return (string_for_output); }
From source file:edu.umd.cs.findbugs.util.Strings.java
/** * Unescape XML entities and illegal characters in the given string. This * enhances the functionality of/*from w w w . jav a2 s .c om*/ * org.apache.commons.lang.StringEscapeUtils.unescapeXml by unescaping * low-valued unprintable characters, which are not permitted by the W3C XML * 1.0 specification. * * @param s * a string * @return the same string with XML entities/escape sequences unescaped * @see <a href="http://www.w3.org/TR/REC-xml/#charsets">Extensible Markup * Language (XML) 1.0 (Fifth Edition)</a> * @see <a * href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#unescapeXml(java.lang.String)">org.apache.commons.lang.StringEscapeUtils * javadoc</a> */ public static String unescapeXml(String s) { initializeEscapeMap(); /* * we can't escape the string if the pattern doesn't compile! (but that * should never happen since the pattern is static) */ if (!initializeUnescapePattern()) { return s; } if (s == null || s.length() == 0) { return s; } /* * skip this expensive check entirely if there are no substrings * resembling Unicode escape sequences in the string to be unescaped */ if (s.contains("\\u")) { StringBuffer sUnescaped = new StringBuffer(); Matcher m = unescapePattern.matcher(s); while (m.find() == true) { String slashes = m.group(1); String digits = m.group(3); int escapeCode; try { escapeCode = Integer.parseInt(digits, 16); } catch (NumberFormatException nfe) { /* * the static regular expression string should guarantee * that this exception is never thrown */ System.err.println("Impossible error: escape sequence '" + digits + "' is not a valid hex number! " + "Exception: " + nfe.toString()); return s; } if (slashes != null && slashes.length() % 2 == 0 && isInvalidXMLCharacter(escapeCode)) { Character escapedSequence = Character.valueOf((char) escapeCode); /* * slashes are apparently escaped when the string buffer is * converted to a string, so double them to make sure the * correct number appear in the final representation */ m.appendReplacement(sUnescaped, slashes + slashes + escapedSequence.toString()); } } m.appendTail(sUnescaped); s = sUnescaped.toString(); } return StringEscapeUtils.unescapeXml(s); }
From source file:edu.cornell.mannlib.vedit.util.Stemmer.java
public static String StemString(String inputStr, int maxLength) { String outputStr = ""; int previousCh = 0; char[] w = new char[maxLength]; char[] inputArray = inputStr.toCharArray(); Stemmer s = new Stemmer(); int inputArrayIndex = 0, stemmerInputBufferIndex = 0, ch = 0; for (inputArrayIndex = 0; inputArrayIndex < inputArray.length; inputArrayIndex++) { ch = inputArray[inputArrayIndex]; if (Character.isLetter((char) ch)) { stemmerInputBufferIndex = 0; // start collecting letters for a new word while (inputArrayIndex < inputArray.length) { // keep reading until hit character other than a letter ch = Character.toLowerCase((char) ch); w[stemmerInputBufferIndex] = (char) ch; if (stemmerInputBufferIndex < maxLength - 1) { stemmerInputBufferIndex++; }//w w w. j a v a2 s . c om if (inputArrayIndex < inputArray.length - 1) { previousCh = ch; ch = inputArray[++inputArrayIndex]; if (!Character.isLetter((char) ch)) { // parse the word in preparation for starting a new one for (int c = 0; c < stemmerInputBufferIndex; c++) { // copy to stemmer internal buffer s.add(w[c]); } s.stem(); { String u; u = s.toString(); outputStr += u; if (ch == '-') { // replace - with space outputStr += " "; } else if (ch == '.') { if (Character.isDigit((char) previousCh)) { outputStr += "."; } else { outputStr += " "; //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } stemmerInputBufferIndex = 0; // to avoid repeats after ) } break; } } else { break; } } } else if (Character.isWhitespace((char) ch)) { if (!Character.isWhitespace((char) previousCh)) { if (previousCh != '.') { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } } } else if (ch == '(') { // open paren; copy all characters until close paren while (ch != ')') { if (inputArrayIndex < inputArray.length) { ch = inputArray[inputArrayIndex++]; } else { log.trace(""); log.trace("1 short of EOS in paren at pos: " + inputArrayIndex + " of " + inputStr); break; } Character Ch = new Character((char) ch); //outputStr += Ch.toString(); //System.out.print( Ch.toString() ); } //log.trace(""); /* not needed -- just duplicates close paren if ( ch == ')') { Character Ch = new Character((char) ch); outputStr += Ch.toString(); log.trace( Ch.toString() ); } */ stemmerInputBufferIndex = 0; } else if (ch == ')') { // when is last character of input string Character Ch = new Character((char) ch); outputStr += Ch.toString(); log.trace(Ch.toString()); log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr); } else if (ch == '-') { // replace - with space outputStr += " "; } else if (ch == '.') { if (Character.isDigit((char) previousCh)) { outputStr += "."; } else { outputStr += " "; //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } previousCh = ch; if (ch < 0) break; } if (stemmerInputBufferIndex > 0) { for (int c = 0; c < stemmerInputBufferIndex; c++) { s.add(w[c]); } s.stem(); String u; u = s.toString(); outputStr += u; } return outputStr == null ? (outputStr.equals("") ? null : outputStr.trim()) : outputStr.trim(); }
From source file:com.boundary.plugin.sdk.PluginUtil.java
/** * Transform a camel case string into a upper case string with underscores * /*from ww w. ja va 2s .c o m*/ * @param s {@link String} to transform * @param d replacement character for white space * @return {@link String} */ public static String toUpperUnderscore(String s, Character d) { StringBuilder builder = new StringBuilder(); s = s.trim(); boolean first = true; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { builder.append(d); } else { if (Character.isUpperCase(s.charAt(i))) { if (first == false) { if (i + 1 < s.length() && Character.isLowerCase(s.charAt(i + 1))) { builder.append(d); } } } builder.append(Character.toUpperCase(s.charAt(i))); } first = false; } StringBuilder r = new StringBuilder(); r.append('\\').append(d).append('\\').append(d); return builder.toString().replaceAll(r.toString(), d.toString()); }
From source file:org.dbflute.solr.cbean.SolrQueryBuilder.java
/** * 2???lpad???????<br />/*from w w w .java 2 s . co m*/ * <pre> * ???? * RG_01000 * </pre> * @param value1 ? * @param value2 * @param lpadLength lpad?? * @param lpadChar lpad?? * @return */ public static String createDoubleQueryValue(String value1, String value2, int lpadLength, Character lpadChar) { if (value1 == null || value2 == null) { throw new IllegalArgumentException("value?null?????"); } Character c = lpadChar == null ? '0' : lpadChar; return value1 + VALUE_SEPARATOR + leftPad(value2, lpadLength, c.toString()); }
From source file:uk.ac.ebi.intact.editor.config.property.CharPropertyConverter.java
@Override public String convertToString(Character obj) { if (obj == null) return null; return obj.toString(); }
From source file:com.datastax.loader.parser.AbstractParser.java
public String prepareToParse(String retstring, String nullString, Character quote) { if (retstring.startsWith(quote.toString()) && retstring.endsWith(quote.toString())) //if ((quote == retstring.charAt(0)) //&& (quote == retstring.charAt(retstring.length() - 1))) retstring = retstring.substring(1, retstring.length() - 1); else/*from ww w.ja v a 2s.c o m*/ retstring = retstring.trim(); if (null != nullString) if (nullString.equalsIgnoreCase(retstring)) return null; return retstring; }