List of usage examples for java.lang Character toChars
public static char[] toChars(int codePoint)
From source file:spark.help.CustomNTriplesParser.java
private int parseLiteral(int c, StringBuilder sb, StringBuilder lang, StringBuilder datatype) throws IOException, RDFParseException { if (c != '"') { reportError("Supplied char should be a '\"', is: " + c, NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); }// ww w. j a va2 s . co m // Read up to the next '"' character c = readCodePoint(); while (c != '"') { if (c == -1) { throwEOFException(); } sb.append(Character.toChars(c)); if (c == '\\') { // This escapes the next character, which might be a double quote c = readCodePoint(); if (c == -1) { throwEOFException(); } sb.append(Character.toChars(c)); } c = readCodePoint(); } // c == '"', read next char c = readCodePoint(); if (c == '@') { // Read language c = readCodePoint(); if (!NTriplesUtil.isLetter(c)) { reportError("Expected a letter, found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } while (c != -1 && c != '.' && c != '^' && c != ' ' && c != '\t') { this.languageTag.append(Character.toChars(c)); c = readCodePoint(); } } else if (c == '^') { // Read datatype c = readCodePoint(); // c should be another '^' if (c == -1) { throwEOFException(); } else if (c != '^') { reportError("Expected '^', found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } c = readCodePoint(); // c should be a '<' if (c == -1) { throwEOFException(); } else if (c != '<') { reportError("Expected '<', found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } c = parseUriRef(c, datatype); } return c; }
From source file:com.gelakinetic.mtgfam.helpers.CardDbAdapter.java
public Cursor fetchCardByName(String name, String[] fields) throws FamiliarDbException { // replace lowercase ae with Ae name = name.replace(Character.toChars(0xE6)[0], Character.toChars(0xC6)[0]); String sql = "SELECT "; boolean first = true; for (String field : fields) { if (first) { first = false;//from www . j a v a 2 s .c o m } else { sql += ", "; } sql += DATABASE_TABLE_CARDS + "." + field; } sql += " FROM " + DATABASE_TABLE_CARDS + " JOIN " + DATABASE_TABLE_SETS + " ON " + DATABASE_TABLE_SETS + "." + KEY_CODE + " = " + DATABASE_TABLE_CARDS + "." + KEY_SET + " WHERE " + DATABASE_TABLE_CARDS + "." + KEY_NAME + " = " + DatabaseUtils.sqlEscapeString(name) + " ORDER BY " + DATABASE_TABLE_SETS + "." + KEY_DATE + " DESC"; Cursor mCursor = null; try { mCursor = mDb.rawQuery(sql, null); } catch (SQLiteException e) { throw new FamiliarDbException(e); } catch (IllegalStateException e) { throw new FamiliarDbException(e); } if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
From source file:txyd.util.StringUtils.java
/** * ?????/*from ww w . j a va2 s . co m*/ * charjavachar16????16??????? * <p> * ??U+0000U+10FFFFU+0000U+FFFFU+10000U+10FFFF * <p> * ????1216??UTF-16 * ??????????U+D800U+DFFF * ??????? * * @param sentence */ public static void printlnChar(String sentence) { // String sentence = "\u03C0\uD835\uDD6B";//? // String sentence = ""; int lengthU = sentence.length(); int lengthP = sentence.codePointCount(0, lengthU); // System.out.println(lengthU); // ?? // System.out.println(lengthP); // ??? if (lengthU != lengthP) {// for (int i = 0; i < lengthU; i++) { int codePoint = sentence.codePointAt(i); if (Character.isSupplementaryCodePoint(codePoint)) { System.out.println(String.valueOf(Character.toChars(codePoint))); i++; } else { System.out.println(sentence.charAt(i)); } } } }
From source file:com.gelakinetic.mtgfam.helpers.CardDbAdapter.java
public Cursor fetchLatestCardByName(String name, String[] fields) throws FamiliarDbException { // replace lowercase ae with Ae name = name.replace(Character.toChars(0xE6)[0], Character.toChars(0xC6)[0]); String sql = "SELECT "; boolean first = true; for (String field : fields) { if (first) { first = false;//w w w . j a v a 2 s . co m } else { sql += ", "; } sql += DATABASE_TABLE_CARDS + "." + field; } sql += " FROM " + DATABASE_TABLE_CARDS + " JOIN " + DATABASE_TABLE_SETS + " ON " + DATABASE_TABLE_SETS + "." + KEY_CODE + " = " + DATABASE_TABLE_CARDS + "." + KEY_SET + " WHERE " + DATABASE_TABLE_CARDS + "." + KEY_NAME + " = " + DatabaseUtils.sqlEscapeString(name) + " ORDER BY " + DATABASE_TABLE_SETS + "." + KEY_DATE + " DESC LIMIT 1"; Cursor mCursor = null; try { mCursor = mDb.rawQuery(sql, null); } catch (SQLiteException e) { throw new FamiliarDbException(e); } catch (IllegalStateException e) { throw new FamiliarDbException(e); } if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
From source file:com.gelakinetic.mtgfam.helpers.CardDbAdapter.java
public Cursor fetchCardByNameAndSet(String name, String setCode) throws FamiliarDbException { // replace lowercase ae with Ae name = name.replace(Character.toChars(0xE6)[0], Character.toChars(0xC6)[0]); String sql = "SELECT " + DATABASE_TABLE_CARDS + "." + KEY_ID + ", " + DATABASE_TABLE_CARDS + "." + KEY_NAME + ", " + DATABASE_TABLE_CARDS + "." + KEY_SET + ", " + DATABASE_TABLE_CARDS + "." + KEY_NUMBER + ", " + DATABASE_TABLE_CARDS + "." + KEY_TYPE + ", " + DATABASE_TABLE_CARDS + "." + KEY_MANACOST + ", " + DATABASE_TABLE_CARDS + "." + KEY_ABILITY + ", " + DATABASE_TABLE_CARDS + "." + KEY_POWER + ", " + DATABASE_TABLE_CARDS + "." + KEY_TOUGHNESS + ", " + DATABASE_TABLE_CARDS + "." + KEY_LOYALTY + ", " + DATABASE_TABLE_CARDS + "." + KEY_RARITY + " FROM " + DATABASE_TABLE_CARDS + " JOIN " + DATABASE_TABLE_SETS + " ON " + DATABASE_TABLE_SETS + "." + KEY_CODE + " = " + DATABASE_TABLE_CARDS + "." + KEY_SET + " WHERE " + DATABASE_TABLE_CARDS + "." + KEY_NAME + " = " + DatabaseUtils.sqlEscapeString(name) + " AND " + DATABASE_TABLE_CARDS + "." + KEY_SET + " = '" + setCode + "' ORDER BY " + DATABASE_TABLE_SETS + "." + KEY_DATE + " DESC"; Cursor mCursor = null;//from w w w. ja v a 2s. c o m try { mCursor = mDb.rawQuery(sql, null); } catch (SQLiteException e) { throw new FamiliarDbException(e); } catch (IllegalStateException e) { throw new FamiliarDbException(e); } if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
From source file:org.eclipse.rdf4j.rio.turtle.TurtleParser.java
/** * Parses an RDF value. This method parses uriref, qname, node ID, quoted * literal, integer, double and boolean. *//*from w w w . ja v a 2 s . c om*/ protected Value parseValue() throws IOException, RDFParseException, RDFHandlerException { int c = peekCodePoint(); if (c == '<') { // uriref, e.g. <foo://bar> return parseURI(); } else if (c == ':' || TurtleUtil.isPrefixStartChar(c)) { // qname or boolean return parseQNameOrBoolean(); } else if (c == '_') { // node ID, e.g. _:n1 return parseNodeID(); } else if (c == '"' || c == '\'') { // quoted literal, e.g. "foo" or """foo""" or 'foo' or '''foo''' return parseQuotedLiteral(); } else if (ASCIIUtil.isNumber(c) || c == '.' || c == '+' || c == '-') { // integer or double, e.g. 123 or 1.2e3 return parseNumber(); } else if (c == -1) { throwEOFException(); return null; } else { reportFatalError("Expected an RDF value here, found '" + new String(Character.toChars(c)) + "'"); return null; } }
From source file:org.openrdf.rio.turtle.TurtleParser.java
/** * Parses a quoted string, optionally followed by a language tag or datatype. *//*from www. j av a2 s.c o m*/ protected Literal parseQuotedLiteral() throws IOException, RDFParseException, RDFHandlerException { String label = parseQuotedString(); // Check for presence of a language tag or datatype int c = peekCodePoint(); if (c == '@') { readCodePoint(); // Read language StringBuilder lang = new StringBuilder(8); c = readCodePoint(); if (c == -1) { throwEOFException(); } boolean verifyLanguageTag = getParserConfig().get(BasicParserSettings.VERIFY_LANGUAGE_TAGS); if (verifyLanguageTag && !TurtleUtil.isLanguageStartChar(c)) { reportError("Expected a letter, found '" + new String(Character.toChars(c)) + "'", BasicParserSettings.VERIFY_LANGUAGE_TAGS); } lang.append(Character.toChars(c)); c = readCodePoint(); while (!TurtleUtil.isWhitespace(c)) { // SES-1887 : Flexibility introduced for SES-1985 and SES-1821 needs // to be counterbalanced against legitimate situations where Turtle // language tags do not need whitespace following the language tag if (c == '.' || c == ';' || c == ',' || c == ')' || c == ']' || c == -1) { break; } if (verifyLanguageTag && !TurtleUtil.isLanguageChar(c)) { reportError("Illegal language tag char: '" + new String(Character.toChars(c)) + "'", BasicParserSettings.VERIFY_LANGUAGE_TAGS); } lang.append(Character.toChars(c)); c = readCodePoint(); } unread(c); return createLiteral(label, lang.toString(), null, getLineNumber(), -1); } else if (c == '^') { readCodePoint(); // next character should be another '^' verifyCharacterOrFail(readCodePoint(), "^"); skipWSC(); // Read datatype Value datatype = parseValue(); if (datatype instanceof IRI) { return createLiteral(label, null, (IRI) datatype, getLineNumber(), -1); } else { reportFatalError("Illegal datatype value: " + datatype); return null; } } else { return createLiteral(label, null, null, getLineNumber(), -1); } }
From source file:com.gelakinetic.mtgfam.helpers.CardDbAdapter.java
public long fetchIdByName(String name) throws FamiliarDbException { // replace lowercase ae with Ae name = name.replace(Character.toChars(0xE6)[0], Character.toChars(0xC6)[0]); String sql = "SELECT " + DATABASE_TABLE_CARDS + "." + KEY_ID + ", " + DATABASE_TABLE_CARDS + "." + KEY_SET + ", " + DATABASE_TABLE_SETS + "." + KEY_DATE + " FROM (" + DATABASE_TABLE_CARDS + " JOIN " + DATABASE_TABLE_SETS + " ON " + DATABASE_TABLE_CARDS + "." + KEY_SET + "=" + DATABASE_TABLE_SETS + "." + KEY_CODE + ")" + " WHERE " + DATABASE_TABLE_CARDS + "." + KEY_NAME + " = " + DatabaseUtils.sqlEscapeString(name) + " ORDER BY " + DATABASE_TABLE_SETS + "." + KEY_DATE + " DESC"; Cursor mCursor = null;//from w w w .j av a2 s . c o m try { mCursor = mDb.rawQuery(sql, null); } catch (SQLiteException e) { throw new FamiliarDbException(e); } catch (IllegalStateException e) { throw new FamiliarDbException(e); } if (mCursor != null) { mCursor.moveToFirst(); long id = mCursor.getLong(mCursor.getColumnIndex(CardDbAdapter.KEY_ID)); mCursor.close(); return id; } return -1; }
From source file:org.eclipse.rdf4j.rio.turtle.TurtleParser.java
/** * Parses a quoted string, optionally followed by a language tag or * datatype.//from www .j a v a 2 s . co m */ protected Literal parseQuotedLiteral() throws IOException, RDFParseException, RDFHandlerException { String label = parseQuotedString(); // Check for presence of a language tag or datatype int c = peekCodePoint(); if (c == '@') { readCodePoint(); // Read language StringBuilder lang = getBuilder(); c = readCodePoint(); if (c == -1) { throwEOFException(); } boolean verifyLanguageTag = getParserConfig().get(BasicParserSettings.VERIFY_LANGUAGE_TAGS); if (verifyLanguageTag && !TurtleUtil.isLanguageStartChar(c)) { reportError("Expected a letter, found '" + new String(Character.toChars(c)) + "'", BasicParserSettings.VERIFY_LANGUAGE_TAGS); } appendCodepoint(lang, c); c = readCodePoint(); while (!TurtleUtil.isWhitespace(c)) { // SES-1887 : Flexibility introduced for SES-1985 and SES-1821 // needs // to be counterbalanced against legitimate situations where // Turtle // language tags do not need whitespace following the language // tag if (c == '.' || c == ';' || c == ',' || c == ')' || c == ']' || c == -1) { break; } if (verifyLanguageTag && !TurtleUtil.isLanguageChar(c)) { reportError("Illegal language tag char: '" + new String(Character.toChars(c)) + "'", BasicParserSettings.VERIFY_LANGUAGE_TAGS); } appendCodepoint(lang, c); c = readCodePoint(); } unread(c); return createLiteral(label, lang.toString(), null, getLineNumber(), -1); } else if (c == '^') { readCodePoint(); // next character should be another '^' verifyCharacterOrFail(readCodePoint(), "^"); skipWSC(); // Read datatype Value datatype = parseValue(); if (datatype instanceof IRI) { return createLiteral(label, null, (IRI) datatype, getLineNumber(), -1); } else { reportFatalError("Illegal datatype value: " + datatype); return null; } } else { return createLiteral(label, null, null, getLineNumber(), -1); } }
From source file:com.sonymobile.android.media.internal.VUParser.java
private boolean parseMtdt(BoxHeader header) { boolean parseOK = true; // if mCurrentBoxSequence contains trak, then add metadata to current // track//from ww w . jav a2s .c o m // else metadata is for file // we're currently not interested in anything on track level try { int numberOfUnits = mDataSource.readShort(); mHmmpTitles = new ArrayList<String>(1); ArrayDeque<String> titleLanguages = new ArrayDeque<String>(1); ArrayDeque<String> iconLanguages = new ArrayDeque<String>(1); for (int i = 0; i < numberOfUnits; i++) { short dataUnitSize = mDataSource.readShort(); int dataTypeID = mDataSource.readInt(); short language = mDataSource.readShort(); char l1 = Character.toChars(((language >> 10) & 0x1F) + 96)[0]; char l2 = Character.toChars(((language >> 5) & 0x1F) + 96)[0]; char l3 = Character.toChars(((language) & 0x1F) + 96)[0]; String languageString = "" + l1 + l2 + l3; short encodingType = mDataSource.readShort(); if (encodingType == 0x01) { byte[] metadata = new byte[dataUnitSize - 10]; mDataSource.read(metadata); String metadataString = new String(metadata, "UTF-16BE").trim(); if ((dataTypeID & 0xFFFF) == 0x01) { mHmmpTitles.add(metadataString); titleLanguages.add(languageString); } } else if (encodingType == 0x101) { if (dataTypeID == 0xA04) { if (mIconList == null) { mIconList = new ArrayList<IconInfo>(); } mDataSource.skipBytes(4); // selectionFlags mDataSource.skipBytes(4); // reserved int artworkCount = mDataSource.readInt(); for (int j = 0; j < artworkCount; j++) { IconInfo iconInfo = new IconInfo(); iconInfo.mtsmId = mDataSource.readInt(); iconInfo.mdstIndex = mDataSource.readInt(); iconInfo.languageIndex = iconLanguages.size(); mDataSource.skipBytes(4); mIconList.add(iconInfo); } iconLanguages.add(languageString); } } } addMetaDataValue(KEY_HMMP_TITLE_LANGUAGES, titleLanguages.toArray()); addMetaDataValue(KEY_HMMP_ICON_LANGUAGES, iconLanguages.toArray()); } catch (EOFException e) { if (LOGS_ENABLED) Log.e(TAG, "Exception while reading from 'MTDT' box", e); return false; } catch (IOException e) { if (LOGS_ENABLED) Log.e(TAG, "Exception while reading from 'MTDT' box", e); return false; } return parseOK; }