List of usage examples for java.lang Character toChars
public static char[] toChars(int codePoint)
From source file:de.vandermeer.asciithemes.a7.A7_NumberingSchemes.java
/** * Numbering scheme using lower case alphanumeric ASCII characters `a-z`. * /*from w w w .j ava 2s . c om*/ * ---- * a item 1 * b item 2 * c item 3 * ... * z item 26 * ---- * * @return the line */ public static TA_Numbering alpha() { return new TA_Numbering() { @Override public String getNumber(int number) { Validate.validState(0 < number && number < 27, "numbering supported 0<number<27 - number was: " + number); return new String(Character.toChars(number + 96)); } @Override public int getMinNumber() { return 1; } @Override public int getMaxNumber() { return 26; } @Override public String getDescription() { return "numbering scheme using lower case alphanumeric ASCII characters 'a-z'"; } }; }
From source file:com.formkiq.core.service.generator.docx4j.Docx4jDocumentMergeFieldCheckbox.java
@SuppressWarnings("unused") @Override//from ww w .j a v a2 s . c o m public void updateDocument(final ArchiveDTO archive, final FormJSONField field) throws IOException { final int hex = 16; String val = !StringUtils.isEmpty(field.getValue()) ? this.checkbox.getCheckedState().getVal() : this.checkbox.getUncheckedState().getVal(); if (this.sdtRun != null) { ClassFinder traverser = new ClassFinder(Text.class); new TraversalUtil(this.sdtRun, traverser); if (!traverser.results.isEmpty()) { Text txt = (Text) traverser.results.get(0); String s = String.valueOf(Character.toChars(Integer.parseInt(val, hex))); txt.setValue(s); } } }
From source file:org.apache.olingo.server.core.deserializer.FixedFormatDeserializerTest.java
@Test public void primitiveValueLong() throws Exception { EdmProperty property = Mockito.mock(EdmProperty.class); Mockito.when(property.getType()).thenReturn(oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)); Mockito.when(property.isPrimitive()).thenReturn(true); Mockito.when(property.isUnicode()).thenReturn(true); Mockito.when(property.getMaxLength()).thenReturn(61); final String value = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\n" + "\uFDFC\n" + String.valueOf(Character.toChars(0x1F603)); assertEquals(value, deserializer.primitiveValue(IOUtils.toInputStream(value), property)); }
From source file:net.metanotion.json.JsonPath.java
private static Lexeme lexToken(final String cs, final int[] position) { final int c = skipWhitespace(cs, position); switch (c) {/*w w w . j av a 2 s.c om*/ case -1: return EOF; case '[': return L_BRACE; case ']': return R_BRACE; case '{': return L_CURLY; case '}': return R_CURLY; case '*': return STAR; case '.': return DOT; case '\'': return lexString(cs, position); default: if (Character.isDigit(c) || (c == (int) '-')) { // Lex integer final StringBuilder sb = new StringBuilder(new String(Character.toChars(c))); int digits = Character.isDigit(c) ? 1 : 0; while (true) { final int i = read(cs, position); if (Character.isDigit(i)) { digits++; sb.append(Character.toChars(i)); } else { position[0]--; if (digits == 0) { throw new IllegalArgumentException("Expected at least one digit [0-9]"); } return new Lexeme(Token.INT, Long.valueOf(sb.toString())); } } } else { // Lex identifier position[0]--; final StringBuilder sb = new StringBuilder(); while (true) { final int i = read(cs, position); if (i == -1) { return new Lexeme(Token.ID, sb.toString()); } if (Character.isLetter(i) || (i == (int) '_') || Character.isDigit(i)) { sb.append(Character.toChars(i)); } else { position[0]--; return new Lexeme(Token.ID, sb.toString()); } } } } }
From source file:org.lightjason.agentspeak.action.builtin.string.CRandom.java
@Nonnull @Override//from w w w. j a va 2s . com public final IFuzzyValue<Boolean> execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List<ITerm> p_argument, @Nonnull final List<ITerm> p_return) { final CharacterPredicate l_characters = p_char -> p_argument.get(0).<String>raw() .contains(new String(Character.toChars(p_char))); CCommon.flatten(p_argument).skip(1).map(i -> new RandomStringGenerator.Builder().filteredBy(l_characters) .build().generate(i.<Number>raw().intValue())).map(CRawTerm::from).forEach(p_return::add); return CFuzzyValue.from(true); }
From source file:de.vandermeer.asciilist.commons.ArabicLiteralUtils.java
/** * Returns an alphanumeric literal representation of the given number using UTF Dingbat Negative Sanserif Circled Digit characters. * @param number to convert// w w w .j a va 2s . c om * @return alphanumeric literal representation * @throws NotImplementedException if the number is out of bounds (currently smaller than 1 and larger than 10) */ public final static String toDingbatNegativeSanserifCircledDigit(int number) { if (number < 1 || number > 10) { throw new NotImplementedException( "Arabic literals - UTF Dingbat Negative Sanserif Circled - supported 0<number<11 - number was: " + number); } return new String(Character.toChars(number + 10121)); }
From source file:de.vandermeer.asciilist.commons.AlphaLiteralUtils.java
/** * Returns an alphanumeric literal representation of the given number using UTF Parenthesized Latin Small Letter (lower case) characters. * @param number to convert/*www. j a v a 2 s . c o m*/ * @return alphanumeric literal representation * @throws NotImplementedException if the number is out of bounds (currently smaller than 1 and larger than 26) */ public final static String toParenthesizedLatinSmallLetter(int number) { if (number < 1 || number > 26) { throw new NotImplementedException( "Alphanumeric literals supported 0<number<27 - number was: " + number); } return new String(Character.toChars(number + 9371)); }
From source file:com.denimgroup.threadfix.framework.impl.rails.RailsModelParser.java
@Override public void processToken(int type, int lineNumber, String stringValue) { String charValue = null;//from w w w . j ava 2 s. c om if (type > 0) charValue = String.valueOf(Character.toChars(type)); // System.err.println(); // System.err.println("line="+lineNumber); // System.err.println("sTyp="+type); // System.err.println("sVal="+stringValue); // System.err.println("cVal="+charValue); switch (currentModelState) { case CLASS: processClass(type, stringValue, charValue); break; case ATTR_ACCESSOR: processAttrAccessible(type, stringValue, charValue); break; } if (stringValue != null) { String s = stringValue.toLowerCase(); if (s.equals("class")) { currentModelState = ModelState.CLASS; } else if (s.equals("attr_accessible")) { currentModelState = ModelState.ATTR_ACCESSOR; } else if (s.equals("attr_accessor")) { currentModelState = ModelState.ATTR_ACCESSOR; } } }
From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java
/** * Numbering scheme using UTF Parenthesized Latin Small Letter (lower case) characters `-`. * /*from w w w . j a v a2 s . c o m*/ * ---- * item 1 * ? item 2 * item 3 * ... * item 26 * ---- * * @return the line */ public static TA_Numbering alphaParenthesizedLatinSmallLetter() { return new TA_Numbering() { @Override public String getNumber(int number) { Validate.validState(0 < number && number < 27, "numbering supported 0<number<27 - number was: " + number); return new String(Character.toChars(number + 9371)); } @Override public int getMinNumber() { return 1; } @Override public int getMaxNumber() { return 26; } @Override public String getDescription() { return "numbering scheme using UTF Parenthesized Latin Small Letter (lower case) characters '-'"; } }; }
From source file:Main.java
/** * This method descodes a string that was previously encoded for being XML * safe. It is the exact opposite of xmlEncode * * @param s the string to decode/*ww w. j ava 2s . com*/ * @return the decoded string * @exception IllegalArgumentException if the string cannot be decoded */ public static String xmlDecode(String s) throws IllegalArgumentException { if (s == null) return s; int idxS = s.indexOf('&'); if (idxS < 0) return s; StringBuilder sb = new StringBuilder(s.length()); int idxE, idx, size; char c, c_1; int prev = 0; while (idxS != -1) { idxE = s.indexOf(';', idxS); if (idxE < 0) throw new IllegalArgumentException("missing ';' in: " + s.substring(idxS)); sb.append(s.substring(prev, idxS)); idx = idxS + 1; size = idxE - idxS - 1; if (size < 2) throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); c = s.charAt(idx); c_1 = s.charAt(idx + 1); switch (c) { case 'l': if (size != 2) throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); if (c_1 == 't') sb.append('<'); else throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); break; case 'g': if (size != 2) throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); if (c_1 == 't') sb.append('>'); else throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); break; case 'q': if (size != 4) throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); if (c_1 != 'u' || s.charAt(idx + 2) != 'o' || s.charAt(idx + 3) != 't') throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); else sb.append('"'); break; case 'a': if (size == 3) { if (c_1 != 'm' || s.charAt(idx + 2) != 'p') throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); else sb.append('&'); } else if (size == 4) { if (c_1 != 'p' || s.charAt(idx + 2) != 'o' || s.charAt(idx + 3) != 's') throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); else sb.append('\''); } else throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); break; case '#': int codePoint; try { codePoint = (c_1 == 'x') ? Integer.parseInt(s.substring(idx + 2, idxE), 16) : Integer.parseInt(s.substring(idx + 1, idxE)); } catch (NumberFormatException ex) { throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); } if (codePoint < 0) throw new IllegalArgumentException( "invalid character codepoint: " + s.substring(idxS, idxE + 1)); if (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT) sb.append((char) codePoint); else sb.append(Character.toChars(codePoint)); break; default: throw new IllegalArgumentException("invalid escape tag: " + s.substring(idxS, idxE + 1)); } prev = idxE + 1; idxS = s.indexOf("&", prev); } if (prev < s.length()) sb.append(s.substring(prev)); return sb.toString(); }