List of usage examples for java.lang Character toChars
public static char[] toChars(int codePoint)
From source file:ac.elements.parser.ExtendedFunctions.java
/** * /* w w w. j a v a 2 s . co m*/ * This method ensures that the output String has only valid XML unicode * characters as specified by the * * XML 1.0 standard. For reference, please see the * * standard. This method will return an empty String if the input is null or * empty. * * * @author Donoiu Cristian, GPL * * @param The * String whose non-valid characters we want to remove. * * @return The in String, stripped of non-valid characters. * @author * http://cse-mjmcl.cse.bris.ac.uk/blog/2007/02/14/1171465494443.html */ public static String stripNonValidXML(String s) { // Used to hold the output. StringBuilder out = new StringBuilder(); // Used to reference the current character. int codePoint; // This is actualy one unicode character, // represented by two code units!!!. // String ss = "\ud801\udc00"; // System.out.println(ss.codePointCount(0, ss.length()));// See: 1 int i = 0; while (i < s.length()) { // System.out.println("i=" + i); // This is the unicode code of the character. codePoint = s.codePointAt(i); // Consider testing larger ranges first to improve speed. if ((codePoint == 0x9) || (codePoint == 0xA) || (codePoint == 0xD) || ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) { out.append(Character.toChars(codePoint)); } // Increment with the number of code units(java chars) needed to // represent a Unicode char. i += Character.charCount(codePoint); } return out.toString(); }
From source file:eu.sisob.uma.extractors.adhoc.websearchers_cv.WebSearchersCVExtractor.java
/** * * @param nextLine// ww w .j av a 2 s .c om * @param idStaffIdentifier * @param idName * @param idFirstName * @param idLastName * @param idInitials * @param idSubject * @param idInstitutionName * @param idWebAddress * @param expression * @param params * @return */ @Override protected String get_result(String[] nextLine, int idStaffIdentifier, int idName, int idFirstName, int idLastName, int idInitials, int idSubject, int idInstitutionName, int idWebAddress, String expression, Object[] params) { String domain = clean_site(nextLine[idWebAddress]); String subject = nextLine[idSubject]; String expression_subject = expression + " " + subject + " " + files + " " + cv_keywords_in_query; expression_subject = expression_subject.replaceAll("\t", " "); expression_subject = expression_subject.replaceAll(" ", " "); String url = "https://duckduckgo.com/html/?q=" + expression_subject; Logger.getRootLogger().info("Go with " + url); boolean again = false; Document doc = null; do { doc = getDocumentFromPage(url, 10, 2000, 5000); if (doc != null && doc.text().contains("If this error persists, please let us know")) { try { Thread.sleep(30000); } catch (InterruptedException ex) { } again = true; } else { again = false; } } while (again); //if(doc.select("div[class*=links_main] > a[href*=" + domain + "]").size() > 0){ String final_result = ""; if (doc != null && doc.select("div[class*=links_main] > a").size() > 0) { /* Write resercher founded */ Elements elements = doc.select("div[class*=links_main] > a"); /* We will take the first html page and the first pdf */ List<String[]> results = new ArrayList<String[]>(); final int EXT_I = 0; final int SCORE_INT_I = 1; final int SCORE_LETTER_I = 2; final int RESULT_I = 3; final int WORST_SCORE = 67; //int max_results = elements.size(); //int i_result = 0; for (Element e : elements) { if ((e.text().startsWith("[") && !e.text().startsWith("[PDF]")) || e.absUrl("href").contains("duckduckgo.com/y.js") || e.absUrl("href").contains("wikipedia.") || e.absUrl("href").contains("microsoft.com") || e.absUrl("href").contains("google.com") || e.absUrl("href").contains("linkedin") || e.absUrl("href").contains("www.biography.com") || e.absUrl("href").contains("biomedexperts.com") || e.absUrl("href").contains("www.experts.scival.com") || e.absUrl("href").contains("ratemyprofessors.com") || e.absUrl("href").contains("flickr.com") || e.absUrl("href").endsWith(".txt") || e.absUrl("href").endsWith(".csv") || e.absUrl("href").endsWith(".xml") || e.absUrl("href").endsWith(".doc") || e.absUrl("href").endsWith(".docx") || e.absUrl("href").endsWith(".xls") || e.absUrl("href").endsWith(".xlxs") || e.absUrl("href").contains("www.amazon")) { continue; } boolean add = false; int score_int = WORST_SCORE; String score = ""; String ext = ""; if (e.text().startsWith("[PDF]") || e.text().startsWith("[DOCX]") || e.text().startsWith("[DOC]") || e.text().startsWith("[RTF]")) { String clean_name_1 = e.text().replaceAll("[^\\w\\s]", "").toLowerCase(); int i = e.absUrl("href").lastIndexOf("/"); int f = e.absUrl("href").lastIndexOf("."); String clean_name_2 = ""; if (i != -1 && f != -1) clean_name_2 = e.absUrl("href").substring(i, f).toLowerCase(); boolean b = false; for (String k : cv_keywords_in_name_list) { if (clean_name_1.contains(k) || clean_name_2.contains(k)) { b = true; break; } } if (b) { score_int--; } if (clean_name_1.contains(nextLine[idLastName]) || clean_name_2.contains(nextLine[idLastName])) { score_int--; } score = Character.toChars(score_int)[0] + ""; add = true; ext = "PDF"; } //if(!results.containsKey("HTML") && !e.text().startsWith("[")){ //} if (add) { String result = ""; result += "\"" + nextLine[idStaffIdentifier] + "\";"; result += "\"" + nextLine[idLastName] + "\";"; result += "\"" + nextLine[idInitials] + "\";"; if (idFirstName != -1) result += "\"" + nextLine[idFirstName] + "\";"; if (idName != -1) result += "\"" + nextLine[idName] + "\";"; result += "\"" + e.absUrl("href") + "\";"; result += "\"" + ext + "\";"; result += "\"" + "CV" + "\";"; result += "\"" + score + "\""; result += "\r\n"; results.add(new String[] { ext, score_int + "", score, result }); Logger.getRootLogger().info("Select " + e.absUrl("href") + " - " + score + " - " + e.text()); } } final_result = ""; int best_score = WORST_SCORE; for (String[] result : results) { if (result[EXT_I].equals("PDF")) { int act_score = Integer.parseInt(result[SCORE_INT_I]); if (act_score < best_score) { best_score = act_score; final_result = result[RESULT_I]; } } } } return final_result; }
From source file:spark.help.CustomNTriplesParser.java
protected int parseNodeID(int c, StringBuilder sb) throws IOException, RDFParseException { if (c != '_') { reportError("Supplied char should be a '_', is: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); }/* ww w. ja v a 2s. co m*/ c = readCodePoint(); if (c == -1) { throwEOFException(); } else if (c != ':') { reportError("Expected ':', found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } c = readCodePoint(); if (c == -1) { throwEOFException(); } else if (!NTriplesUtil.isLetterOrNumber(c)) { reportError("Expected a letter or number, found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); } sb.append(Character.toChars(c)); // Read all following letter and numbers, they are part of the name c = readCodePoint(); while (c != -1 && NTriplesUtil.isLetterOrNumber(c)) { sb.append(Character.toChars(c)); c = readCodePoint(); } return c; }
From source file:com.github.veqryn.collect.TestPatriciaTrieWithApacheCommonsCollections.java
public void testPrefixMapSizes2() { final char u8000 = Character.toChars(32768)[0]; // U+8000 (1000000000000000) final char char_b = 'b'; // 1100010 final PatriciaTrie<String> trie = new PatriciaTrie<String>(); final String prefixString = "" + char_b; final String longerString = prefixString + u8000; assertEquals(1, prefixString.length()); assertEquals(2, longerString.length()); assertTrue(longerString.startsWith(prefixString)); trie.put(prefixString, "prefixString"); trie.put(longerString, "longerString"); assertEquals(2, trie.prefixedByMap(prefixString, true).size()); assertTrue(trie.prefixedByMap(prefixString, true).containsKey(longerString)); }
From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java
/** * Numbering scheme using UTF Parenthesized Digit/Number characters `-`. * /*from w ww. j a va 2 s . c om*/ * ---- * item 1 * item 2 * item 3 * ... * item 20 * ---- * * @return the line */ public static TA_Numbering numberParenthesized() { return new TA_Numbering() { @Override public String getNumber(int number) { Validate.validState(0 < number && number < 21, "numbering supported 0<number<21 - number was: " + number); return new String(Character.toChars(number + 9331)); } @Override public int getMinNumber() { return 1; } @Override public int getMaxNumber() { return 20; } @Override public String getDescription() { return "numbering scheme using UTF Parenthesized Digit/Number characters '-'"; } }; }
From source file:org.eclipse.rdf4j.rio.ntriples.NTriplesParser.java
private int parseLiteral(int c, StringBuilder value, 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.jav a2 s. c om // Read up to the next '"' character c = readCodePoint(); while (c != '"') { if (c == -1) { throwEOFException(); } value.append(Character.toChars(c)); if (c == '\\') { // This escapes the next character, which might be a double quote c = readCodePoint(); if (c == -1) { throwEOFException(); } value.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') { lang.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:org.gathe.verge.uno.ODT2PDFConverter.java
public void run() { System.setProperty("javax.net.ssl.trustStore", "/opt/myKeystore"); System.setProperty("javax.net.ssl.trustStorePassword", "keys$%"); FileInputStream is = null;/*from w w w . jav a2s .co m*/ try { XComponentContext xComponentContext = Bootstrap.bootstrap(); // XComponentContext xComponentContext = BootstrapSocketConnector.bootstrap(oooExeFolder); XMultiComponentFactory xMCF = xComponentContext.getServiceManager(); HashMap<String, ArrayList<HashMap<String, String>>> data = new HashMap<>(); HashMap<String, String> fields = new HashMap<>(); String json = this.getParameters(); //"{\"lastname\":\"\",\"firstname\":\"\",\"middlename\":\"\",\"table-ege\":[{\"subject\":\"Physics\",\"Score\":\"100\"},{\"subject\":\"Chemistry\",\"Score\":\"95\"}]}"; JSONParser parser = new JSONParser(); System.out.println(json); JSONObject jsonObj = (JSONObject) parser.parse(json); for (Object jsonKey : jsonObj.keySet()) { if (("" + jsonKey).startsWith("table-")) { ArrayList<HashMap<String, String>> tableContent = new ArrayList<>(); String tableName = ("" + jsonKey).substring(6); JSONArray arr = (JSONArray) jsonObj.get(jsonKey); HashMap<String, String> row; for (int c = 0; c < arr.size(); c++) { row = new HashMap<>(); JSONObject jobj = (JSONObject) arr.get(c); for (Object rowKey : jobj.keySet()) { String rowKeyStr = "" + rowKey; String rowValue = "" + jobj.get(rowKey); row.put(rowKeyStr.toUpperCase(), rowValue); } tableContent.add(row); } data.put(tableName.toUpperCase(), tableContent); } else { String jsonValue = "" + jsonObj.get(jsonKey); fields.put(("" + jsonKey).toUpperCase(), jsonValue); System.out.println(jsonKey + ":" + jsonValue); } } //load file Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xComponentContext); XComponentLoader xCompLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); String url = this.getTemplateName();//"file:///devel/LOConnector/declaration_bachelor.odt"; PropertyValue[] loadProperties = new PropertyValue[1]; // loadProperties[0] = new PropertyValue(); // loadProperties[0].Name = "Hidden"; // loadProperties[0].Value = new Boolean(false); loadProperties[0] = new PropertyValue(); loadProperties[0].Name = "ReadOnly"; loadProperties[0].Value = new Boolean(false); Object document = xCompLoader.loadComponentFromURL(url, "_blank", 0, loadProperties); XTextDocument xTextDocument = UnoRuntime.queryInterface(XTextDocument.class, document); XTextFieldsSupplier fieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document); // XNameAccess xNameAccess = fieldsSupplier.getTextFieldMasters(); for (String element : fields.keySet()) { if (element.startsWith("#")) continue; System.out.println(element); String value = fields.get(element); System.out.println(value); if (value != null) { String name = "com.sun.star.text.FieldMaster.User." + element.toUpperCase(); if (xNameAccess.hasByName(name)) { Object fieldObj = xNameAccess.getByName(name); XPropertySet field = UnoRuntime.queryInterface(XPropertySet.class, fieldObj); String oldValue = field.getPropertyValue("Content").toString(); System.out.println(oldValue); if (oldValue.startsWith("#")) { if (value.equalsIgnoreCase("true")) { value = "1"; } if (value.equalsIgnoreCase("false")) { value = "0"; } String[] values = oldValue.substring(1).split("/"); boolean flag = false; for (String value2 : values) { String[] entry = value2.split("="); if (entry.length == 1) { String[] entry2 = new String[2]; entry2[0] = entry[0]; entry2[1] = ""; entry = entry2; } System.out.println("Comparing " + entry[0] + " : " + entry[1] + " with " + value); if (Integer.parseInt(entry[0]) == Integer.parseInt(value)) { flag = true; value = entry[1]; break; } } if (!flag) value = "<??>"; } field.setPropertyValue("Content", value); } } } XTextTablesSupplier tablesSupplier = UnoRuntime.queryInterface(XTextTablesSupplier.class, document); //fill the tables XNameAccess allTables = tablesSupplier.getTextTables(); for (String tableName : data.keySet()) { if (!allTables.hasByName(tableName)) { continue; } Object retrievedTableObj = allTables.getByName(tableName); ArrayList<HashMap<String, String>> dataSubset = data.get(tableName); if (dataSubset.size() == 0) { //remove empty table XTextDocument textDocument = UnoRuntime.queryInterface(XTextDocument.class, document); XText text = textDocument.getText(); XTextContent tableContentText = UnoRuntime.queryInterface(XTextContent.class, retrievedTableObj); text.removeTextContent(tableContentText); continue; } XTextTable retrievedTable = UnoRuntime.queryInterface(XTextTable.class, retrievedTableObj); XCellRange retrievedTableCells = UnoRuntime.queryInterface(XCellRange.class, retrievedTableObj); int rowsCount = retrievedTable.getRows().getCount(); int colsCount = retrievedTable.getColumns().getCount(); ArrayList<String> rowNumbers = new ArrayList<String>(); ArrayList<HashMap<String, String>> fieldsLocations = new ArrayList<HashMap<String, String>>(); ArrayList<String> rowLength = new ArrayList<String>(); //get row numbers with referenced fields int maxRow = 0; int maxLen = 0; for (int row = 0; row < rowsCount; row++) { boolean found = false; HashMap<String, String> fieldsAtRow = new HashMap<String, String>(); int col = 0; for (col = 0; col < colsCount; col++) { System.out.println("Reading cell " + col + ":" + row); try { XCell cell = retrievedTableCells.getCellByPosition(col, row); XText cellText = UnoRuntime.queryInterface(XText.class, cell); String val = cellText.getString(); if (val.startsWith("#")) { fieldsAtRow.put("" + col, val.substring(1)); found = true; } } catch (Exception e) { break; } } if (found) { rowNumbers.add("" + row); fieldsLocations.add(fieldsAtRow); rowLength.add("" + col); if (row > maxRow) maxRow = row; if (col > maxLen) maxLen = col; } } maxRow++; XController xController = xTextDocument.getCurrentController(); XTransferableSupplier xTransferableSupplier = UnoRuntime.queryInterface(XTransferableSupplier.class, xController); //Fill the table below the bottom line int tableRow = maxRow; for (HashMap<String, String> dataRow : dataSubset) { // if (tableRow != 0) { System.out.println("Adding row " + maxRow); retrievedTable.getRows().insertByIndex(maxRow, 1); maxRow++; } for (HashMap<String, String> dataRow : dataSubset) { //merging cells System.out.println("Datarow: " + dataRow); int rowId = 0; if (dataRow.containsKey("%")) rowId = Integer.parseInt("" + dataRow.get("%")); int rowLen = Integer.parseInt(rowLength.get(rowId)); if (dataRow.containsKey("$")) { System.out.println("MERGING CELLS"); int left = maxLen; int positionX = 0; int positionY = tableRow; String[] dataRowSize = dataRow.get("$").split(","); int newLen = 0; for (String dataRowSizeElement : dataRowSize) { System.out.println("PROCESSING: " + dataRowSizeElement); int horSpan; if (dataRowSizeElement.equals("*")) horSpan = left; else horSpan = Integer.parseInt(dataRowSizeElement); String startAddress = String.valueOf(Character.toChars(positionX + 65)) + (positionY + 1); XTextTableCursor textTableCursor = retrievedTable.createCursorByCellName(startAddress); if (horSpan > 1) textTableCursor.goRight((short) (horSpan - 1), true); textTableCursor.mergeRange(); left -= horSpan; newLen++; if (left <= 0) break; } rowLen = newLen; } System.out.println("Extracting range for 0:" + rowNumbers.get(rowId) + ":" + (rowLen - 1) + ":" + rowNumbers.get(rowId)); XCellRange templateRow = retrievedTableCells.getCellRangeByPosition(0, Integer.parseInt(rowNumbers.get(rowId)), rowLen - 1, Integer.parseInt(rowNumbers.get(rowId))); XSelectionSupplier xSelectionSupplier = UnoRuntime.queryInterface(XSelectionSupplier.class, xController); xSelectionSupplier.select(templateRow); XTransferable transferable = xTransferableSupplier.getTransferable(); System.out.println("Getting cellRange 0:" + tableRow + ":" + (rowLen - 1) + ":" + tableRow); XCellRange newRow = retrievedTableCells.getCellRangeByPosition(0, tableRow, rowLen - 1, tableRow); xSelectionSupplier.select(newRow); xTransferableSupplier.insertTransferable(transferable); // } for (int tableCol = 0; tableCol < rowLen; tableCol++) { HashMap<String, String> rowMetadata = fieldsLocations.get(rowId); if (rowMetadata.containsKey("" + tableCol)) { String fieldId = rowMetadata.get("" + tableCol); String dataItem = dataRow.get(fieldId); System.out.println("Retrieving cell:" + tableCol + ":" + tableRow); XCell cell = retrievedTableCells.getCellByPosition(tableCol, tableRow); System.out.println( "Setting to cell " + tableCol + ":" + tableRow + " value: " + dataItem); XText cellText = UnoRuntime.queryInterface(XText.class, cell); cellText.setString(dataItem); } } // if (tableRow != 0) { tableRow++; // } } for (int i = rowNumbers.size() - 1; i >= 0; i--) { retrievedTable.getRows().removeByIndex(Integer.parseInt(rowNumbers.get(i)), 1); } } //show/hide frames XTextFramesSupplier framesSupplier = UnoRuntime.queryInterface(XTextFramesSupplier.class, document); XNameAccess frames = framesSupplier.getTextFrames(); XTextDocument textDocument = UnoRuntime.queryInterface(XTextDocument.class, document); XText text = textDocument.getText(); for (String fieldName : fields.keySet()) { if (!fieldName.startsWith("#")) { continue; } String fieldName2 = fieldName.substring(1); String value = fields.get(fieldName); if (frames.hasByName(fieldName2)) { System.out.println("Checking frame " + fieldName2); if (value.trim().equalsIgnoreCase("0")) { System.out.println("Hiding"); Object frameContent = frames.getByName(fieldName2); XTextContent frameContentText = UnoRuntime.queryInterface(XTextContent.class, frameContent); text.removeTextContent(frameContentText); } } } //update graphic objects XTextGraphicObjectsSupplier goSupplier = UnoRuntime.queryInterface(XTextGraphicObjectsSupplier.class, document); XNameAccess graphicsObjects = goSupplier.getGraphicObjects(); for (String objName : fields.keySet()) { if (!objName.startsWith("@")) continue; String value = fields.get(objName); //encoded binary image byte[] imageData = DatatypeConverter.parseBase64Binary(value); File temp = File.createTempFile("image", ".jpg", new File("/tmp")); FileOutputStream fos = null; fos = new FileOutputStream(temp); fos.write(imageData); fos.flush(); fos.close(); String newURL = temp.getCanonicalPath(); String goName = objName.substring(1); if (graphicsObjects.hasByName(goName)) { XPropertySet graphicObject = UnoRuntime.queryInterface(XPropertySet.class, graphicsObjects.getByName(goName)); graphicObject.setPropertyValue("GraphicURL", "file://" + newURL); } } //transform file //save file String sSaveURL = "file:///tmp/" + this.getSessionID() + ".pdf"; XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document); PropertyValue[] propertyValue = new PropertyValue[2]; propertyValue[0] = new PropertyValue(); propertyValue[0].Name = "Overwrite"; propertyValue[0].Value = new Boolean(true); propertyValue[1] = new PropertyValue(); propertyValue[1].Name = "FilterName"; propertyValue[1].Value = "writer_pdf_Export"; xStorable.storeToURL(sSaveURL, propertyValue); XComponent component = (XComponent) UnoRuntime.queryInterface(XComponent.class, document); component.dispose(); byte[] key = this.getSessionID().getBytes("utf-8"); File file = new File("/tmp/" + this.getSessionID() + ".pdf"); is = new FileInputStream(file); long length = file.length(); byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } System.out.println("Here"); jedis.set(key, bytes); jedis.expire(key, 30 * 60); //30 minutes to expire is.close(); file.delete(); // String url2 = this.getCallbackURL(); // if (url2.trim().length()!=0) { // url2 = url2.replace("~SESSION~", this.getSessionID()); // URL urlx; // try { // urlx = new URL(url2); // urlx.openStream(); // } catch (IOException ex) { // Logger.getLogger(ODT2PDFConverter.class.getName()).log(Level.SEVERE, null, ex); // } // } // XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, document); // if (xCloseable!=null) { // xCloseable.close(false); // } } catch (IOException | Exception | ParseException | BootstrapException ex) { Logger.getLogger(ODT2PDFConverter.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (is != null) { is.close(); } } catch (IOException ex) { Logger.getLogger(ODT2PDFConverter.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:org.exoplatform.cms.common.CommonUtils.java
private static void getValueTokens() { if (tokens.size() <= 0) { String token;// w w w.j a v a2s. co m // Tokens by HTML(Decimal) code. for (int t = Character.MIN_CODE_POINT; t < Character.MAX_CODE_POINT; t++) { if (t < CHAR_CODES[0] && t > CHAR_CODES[1] || t < CHAR_CODES[2] && t > CHAR_CODES[3] || t < CHAR_CODES[4] && t > CHAR_CODES[5] || t < CHAR_CODES[6] && t > CHAR_CODES[7]) { token = new StringBuilder(AMP_NUMBER).append(t).append(SEMICOLON).toString(); tokens.add(token); charcodes.put(token, String.valueOf(Character.toChars(t)[0])); } } // Tokens by Entity code. tokens.add(LESS_THAN); charcodes.put(LESS_THAN, ">"); tokens.add(GREATER_THAN); charcodes.put(GREATER_THAN, "<"); tokens.add(QUOT); charcodes.put(QUOT, "\""); tokens.add(AMP_SPACE); charcodes.put(AMP_SPACE, SPACE); tokens.add(AMP_HEX); charcodes.put(AMP_HEX, "&"); tokens.add(AMP); charcodes.put(AMP, "&"); } }
From source file:com.bigdata.rdf.sail.webapp.AbstractTestNanoSparqlClient.java
/** * Generate and return a very large literal. *//* w ww. j a v a2 s. co m*/ protected Literal getVeryLargeLiteral() { final int len = 1024000; final StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { sb.append(Character.toChars('A' + (i % 26))); } return new LiteralImpl(sb.toString()); }
From source file:de.vandermeer.asciithemes.u8.U8_NumberingSchemes.java
/** * Numbering scheme case UTF Fullwidth characters `-`. * /* ww w.j av a2s.c o m*/ * ---- * item 1 * item 2 * item 3 * ... * item 9 * ---- * * @return the line */ public static TA_Numbering numberFullwidth() { return new TA_Numbering() { @Override public String getNumber(int number) { Validate.validState(0 < number && number < 10, "numbering supported 0<number<10 - number was: " + number); return new String(Character.toChars(number + 65296)); } @Override public int getMinNumber() { return 1; } @Override public int getMaxNumber() { return 9; } @Override public String getDescription() { return "numbering scheme using UTF Fullwidth characters '-'"; } }; }