List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:com.wojtechnology.sunami.SongManager.java
public List<FireMixtape> getByTitle() { List<FireMixtape> displayList = new ArrayList<>(mSongList); if (mSongList.size() <= 0) { return displayList; }/*from w ww .ja va 2 s. c om*/ Collections.sort(displayList, new Comparator<FireMixtape>() { @Override public int compare(FireMixtape lhs, FireMixtape rhs) { return compareTitles(lhs, rhs); } }); Map<Character, Integer> letters = new HashMap<>(); int i = 0; while (firstLetter(displayList.get(i).title) < 'A' || firstLetter(displayList.get(i).title) > 'Z') { i++; if (i >= displayList.size()) return displayList; } int sum = i; int j = i; for (char headerTitle = 'A'; headerTitle <= 'Z' && i < displayList.size(); i++) { if (firstLetter(displayList.get(i).title) != headerTitle) { letters.put(headerTitle, i - j); headerTitle++; j = i; i--; } } for (char headerTitle = 'A'; headerTitle <= 'Z' && letters.containsKey(headerTitle); headerTitle++) { if (letters.get(headerTitle) != 0) { FireMixtape mixtape = HeaderHelper.makeHeader(context, Character.toString(headerTitle)); displayList.add(sum, mixtape); sum++; } sum += letters.get(headerTitle); } FireMixtape final_header = HeaderHelper.makeFinal(context, getFinalLabel()); displayList.add(final_header); return displayList; }
From source file:au.org.ala.delta.translation.delta.DeltaWriter.java
public String rangeToString(List<Integer> values, char separator, char rangeSeparator) { return rangeToString(values, separator, Character.toString(rangeSeparator)); }
From source file:edu.pitt.tcga.httpclient.util.CSVReader.java
/** * Constructs CSVReader with supplied separator and quote char. * //from www . j a va 2 s .co m * @param reader * the reader to an underlying CSV source. * @param separator * the delimiter to use for separating entries * @param quotechar * the character to use for quoted elements * @param line * the line number to skip for start reading */ public CSVReader(Reader reader, char separator, char quotechar, int line) { this.br = new BufferedReader(reader); this.separator = separator; sepStr = Character.toString(separator); this.quotechar = quotechar; this.skipLines = line; }
From source file:de.uni.bremen.monty.moco.ast.expression.literal.StringLiteral.java
/** replaces escape sequences of string literals by the LLVM IR equivalents * * @param value//from www.j a v a 2s . com * the string which should be escaped * @return an escaped string */ public static String replaceEscapeSequences(String value) { // replace escape sequences value = value.replace("\\t", "\\09"); // horizontal tab value = value.replace("\\b", "\\08"); // backspace value = value.replace("\\n", "\\0A"); // line feed value = value.replace("\\r", "\\0D"); // carriage return value = value.replace("\\f", "\\0C"); // formfeed value = value.replace("\\'", "\\27"); // single quote value = value.replace("\\\"", "\\22"); // double quote value = value.replace("\\\\", "\\5C"); // backslash // replace unicode escape sequences by utf-8 codes StringBuffer output = new StringBuffer(); Pattern regex = Pattern.compile("(\\\\u....)|\\P{ASCII}"); Matcher matcher = regex.matcher(value); byte[] utf8; while (matcher.find()) { String replacement = ""; if (matcher.group().startsWith("\\u")) { // convert hexadecimal unicode number to utf-8 encoded bytes utf8 = Character.toString((char) Integer.parseInt(matcher.group().substring(2), 16)) .getBytes(StandardCharsets.UTF_8); } else { // convert a unicode character to utf-8 encoded bytes utf8 = matcher.group().getBytes(StandardCharsets.UTF_8); } // convert utf-8 bytes to hex strings (for LLVM IR) for (byte c : utf8) { replacement += String.format("\\\\%02x", c); } matcher.appendReplacement(output, replacement); } matcher.appendTail(output); return output.toString(); }
From source file:org.apache.hadoop.hbase.TestScanner2.java
/** * Test getting scanners with regexes for column names. * @throws IOException /*from w ww . j a v a 2 s . c o m*/ */ public void testRegexForColumnName() throws IOException { // Setup HClient, ensure that it is running correctly HBaseAdmin admin = new HBaseAdmin(conf); // Setup colkeys to be inserted Text tableName = new Text(getName()); createTable(admin, tableName); HTable table = new HTable(this.conf, tableName); // Add a row to columns without qualifiers and then two with. Make one // numbers only so easy to find w/ a regex. long id = table.startUpdate(new Text(getName())); final String firstColkeyFamily = Character.toString(FIRST_COLKEY) + ":"; table.put(id, new Text(firstColkeyFamily + getName()), GOOD_BYTES); table.put(id, new Text(firstColkeyFamily + "22222"), GOOD_BYTES); table.put(id, new Text(firstColkeyFamily), GOOD_BYTES); table.commit(id); // Now do a scan using a regex for a column name. checkRegexingScanner(table, firstColkeyFamily + "\\d+"); // Do a new scan that only matches on column family. checkRegexingScanner(table, firstColkeyFamily + "$"); }
From source file:io.fabric8.forge.rest.dto.UICommands.java
public static PropertyDTO createInputDTO(UIContext context, InputComponent<?, ?> input) { String name = input.getName(); String description = input.getDescription(); String label = input.getLabel(); String requiredMessage = input.getRequiredMessage(); char shortNameChar = input.getShortName(); String shortName = Character.toString(shortNameChar); Object inputValue = InputComponents.getValueFor(input); /*//from w ww.j a va 2s. c om if (input instanceof ManyValued) { ManyValued manyValued = (ManyValued) input; inputValue = manyValued.getValue(); } */ Object value = convertValueToSafeJson(input.getValueConverter(), inputValue); Class<?> valueType = input.getValueType(); String javaType = null; if (valueType != null) { javaType = valueType.getCanonicalName(); } String type = JsonSchemaTypes.getJsonSchemaTypeName(valueType); boolean enabled = input.isEnabled(); boolean required = input.isRequired(); List<Object> enumValues = new ArrayList<>(); List<Object> typeaheadData = new ArrayList<>(); if (input instanceof SelectComponent) { SelectComponent selectComponent = (SelectComponent) input; Iterable valueChoices = selectComponent.getValueChoices(); Converter converter = selectComponent.getItemLabelConverter(); boolean isJson = isJsonDTO(javaType); for (Object valueChoice : valueChoices) { Object jsonValue; if (isJson) { jsonValue = Proxies.unwrap(valueChoice); } else { jsonValue = convertValueToSafeJson(converter, valueChoice); } enumValues.add(jsonValue); } } if (input instanceof HasCompleter) { HasCompleter hasCompleter = (HasCompleter) input; UICompleter completer = hasCompleter.getCompleter(); if (completer != null) { String textValue = inputValue != null ? inputValue.toString() : ""; Iterable valueChoices = completer.getCompletionProposals(context, input, textValue); // TODO is there a way to find a converter? Converter converter = null; for (Object valueChoice : valueChoices) { Object jsonValue = convertValueToSafeJson(converter, valueChoice); typeaheadData.add(jsonValue); } } } if (enumValues.isEmpty()) { enumValues = null; } if (typeaheadData.isEmpty()) { typeaheadData = null; } return new PropertyDTO(name, description, label, requiredMessage, value, javaType, type, enabled, required, enumValues, typeaheadData); }
From source file:org.exoplatform.wiki.rendering.internal.parser.confluence.ConfluenceLinkReferenceParser.java
private String divideAfterLast(StringBuffer buffer, char divider) { if (buffer.length() == 0) { return null; }/* w w w . j a v a2 s . c o m*/ return divideAfter(buffer, buffer.lastIndexOf(Character.toString(divider))); }
From source file:io.github.jeddict.jcode.util.JavaUtil.java
/** * a derived methodName from variableName Eg nickname -> getNickname / * setNickname//from w w w. jav a 2 s. co m */ public static String getMethodName(String type, String fieldName) { String methodName; if (fieldName.charAt(0) == '_') { char ch = Character.toUpperCase(fieldName.charAt(1)); methodName = Character.toString(ch) + fieldName.substring(2); } else { char ch = Character.toUpperCase(fieldName.charAt(0)); methodName = Character.toString(ch) + fieldName.substring(1); } if (type != null) { methodName = type + methodName; } return methodName; }
From source file:org.easyrec.utils.io.autoimport.AutoImportUtils.java
public static String retrieveCommandFromLine(String line) { // syntax: '# command: insert/remove' String csvComment = Character.toString(CSV_COMMENT_CHAR); StringBuilder errorMsgBuffer = new StringBuilder( "this line doesn't contain a valid command, line must be: '"); errorMsgBuffer.append(VALID_COMMAND); errorMsgBuffer.append("', but was: '"); errorMsgBuffer.append(line);//w ww. j a v a 2s. co m errorMsgBuffer.append("'"); String errorMsg = errorMsgBuffer.toString(); // check '#' line = line.trim(); if (!line.startsWith(csvComment)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(csvComment) + csvComment.length()); // check 'command' line = line.trim(); if (!line.startsWith(CSV_COMMAND)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(CSV_COMMAND) + CSV_COMMAND.length()); // check ':' line = line.trim(); if (!line.startsWith(CSV_DELIMITER)) { throw new IllegalArgumentException(errorMsg); } line = line.substring(line.indexOf(CSV_DELIMITER) + CSV_DELIMITER.length()); // check command 'insert' or 'delete' line = line.trim(); if (line.startsWith(COMMAND_INSERT)) { return COMMAND_INSERT; } if (line.startsWith(COMMAND_REMOVE)) { return COMMAND_REMOVE; } throw new IllegalArgumentException(errorMsg); }
From source file:ninja.javafx.smartcsv.fx.preferences.PreferencesController.java
public void setCsvPreference(CsvPreference csvPreference) { quoteChar.setText(Character.toString(csvPreference.getQuoteChar())); delimiterChar.setText(Character.toString((char) csvPreference.getDelimiterChar())); surroundingSpacesNeedQuotes.setSelected(csvPreference.isSurroundingSpacesNeedQuotes()); ignoreEmptyLines.setSelected(csvPreference.isIgnoreEmptyLines()); quoteMode.getSelectionModel().select(getQuoteModeName(csvPreference.getQuoteMode())); endOfLineSymbols = csvPreference.getEndOfLineSymbols(); }