List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:de.micromata.genome.gwiki.page.gspt.BodyContentImpl.java
@Override public void print(char arg0) throws IOException { write(Character.toString(arg0)); }
From source file:com.thinkbiganalytics.discovery.parsers.csv.CSVFileSchemaParser.java
private CSVFormat createCSVFormat(String sampleData) throws IOException { CSVFormat format;//from w w w. ja va2 s .c o m if (autoDetect) { CSVAutoDetect autoDetect = new CSVAutoDetect(); format = autoDetect.detectCSVFormat(sampleData, this.headerRow, this.separatorChar); this.separatorChar = Character.toString(format.getDelimiter()); this.quoteChar = Character.toString(format.getQuoteCharacter()); } else { format = CSVFormat.DEFAULT.withAllowMissingColumnNames(); if (StringUtils.isNotEmpty(separatorChar)) { format = format.withDelimiter(toChar(separatorChar).charAt(0)); } if (StringUtils.isNotEmpty(escapeChar)) { format = format.withEscape(toChar(escapeChar).charAt(0)); } if (StringUtils.isNotEmpty(quoteChar)) { format = format.withQuoteMode(QuoteMode.MINIMAL).withQuote(toChar(quoteChar).charAt(0)); } } return format; }
From source file:net.sf.jasperreports.functions.standard.TextFunctions.java
/** * Returns a single text character, given a character code. */// ww w .ja v a 2 s. c o m @Function("CHAR") @FunctionParameters({ @FunctionParameter("number") }) public static String CHAR(Integer number) { if (number == null || (number < 1 || number > 255)) { if (log.isDebugEnabled()) { log.debug("The number must be an integer number between 1 and 255."); } return null; } return Character.toString((char) number.intValue()); }
From source file:edu.ku.brc.util.GeoRefConverter.java
/** * */ public GeoRefConverter() { decimalSep = Character.toString(new DecimalFormatSymbols(Locale.getDefault()).getDecimalSeparator()); }
From source file:correospingtelnet.CorreosPingTelnet.java
private void mainAnterior() throws Exception { //JFreeChart chart; //chart = createPlot(); //ChartUtilities.saveChartAsPNG(new File("imagen.png"), chart, 1000, 600); // request/*from w ww . j a v a2 s. com*/ final IcmpPingRequest request = IcmpPingUtil.createIcmpPingRequest(); request.setHost("192.168.1.5"); final XYSeries google = new XYSeries("Ping a google"); // repeat a few times for (int count = 1; count <= 1; count++) { // delegate final IcmpPingResponse response = IcmpPingUtil.executePingRequest(request); // log final String formattedResponse = IcmpPingUtil.formatResponse(response); System.out.println(formattedResponse); //Aqu tomaremos el valor de los ms y los guardaremos en un arreglo. String[] splitStr = formattedResponse.split("\\s+"); int valor = 0; if (splitStr.length > 5) { //Quitamos los ms char[] cadenaEnChars = splitStr[4].toCharArray(); if (cadenaEnChars.length == 8) { valor = Integer.parseInt(Character.toString(cadenaEnChars[5])); } else { valor = Integer .parseInt(Character.toString(cadenaEnChars[5]) + Character.toString(cadenaEnChars[6])); } } else { //Aqu hacer telnet //Aqu enviar correo Telnet.doTelnet("64.62.142.154"); valor = 0; } google.add(count, valor); // rest Thread.sleep(1000); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(google); JFreeChart xylineChart = ChartFactory.createXYLineChart("Grfica de ping", "Ping #", "ms", dataset, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsPNG(new File("imagen.png"), xylineChart, 1000, 600); }
From source file:byps.BBufferJson.java
public void putChar(String name, char v) { putString(name, v != 0 ? Character.toString(v) : ""); }
From source file:com.zimbra.qa.unittest.TestDocument.java
/** * Tests moving of documents created with the {@code Note} flag set. *///from w w w . ja v a 2s . c o m public void testMoveNote() throws Exception { String USER2_NAME = "user2"; String filename = NAME_PREFIX + "-testMoveNote.txt"; Account acct = Provisioning.getInstance().get(Key.AccountBy.name, TestUtil.getAddress(USER_NAME)); Account acct2 = Provisioning.getInstance().get(Key.AccountBy.name, TestUtil.getAddress(USER2_NAME)); // Create a note. ZMailbox zmbx = TestUtil.getZMailbox(USER_NAME); String folderId = Integer.toString(Mailbox.ID_FOLDER_BRIEFCASE); ZDocument note = TestUtil.createDocument(zmbx, folderId, filename, "text/plain", "note".getBytes(), true); String flags = Character.toString(ZItem.Flag.note.getFlagChar()); // Confirm that note flag is set. assertEquals(flags, note.getFlags()); Mailbox remoteMbox = MailboxManager.getInstance().getMailboxByAccount(acct2); Mailbox mbox1 = MailboxManager.getInstance().getMailboxByAccount(acct); // Clean up test data for user2. TestUtil.deleteTestData(USER2_NAME, NAME_PREFIX); // reset the access if there are any present. remoteMbox.revokeAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct.getId()); mbox1.revokeAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct2.getId()); // Give write permissions on user2's Briefcase for user1 and user1's Briefcase for user2. remoteMbox.grantAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct.getId(), ACL.GRANTEE_USER, (short) (ACL.RIGHT_READ | ACL.RIGHT_WRITE | ACL.RIGHT_INSERT), null); mbox1.grantAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct2.getId(), ACL.GRANTEE_USER, (short) (ACL.RIGHT_READ | ACL.RIGHT_WRITE | ACL.RIGHT_INSERT), null); // move the note to user2 zmbx.moveItem(note.getId(), acct2.getId() + ":" + Mailbox.ID_FOLDER_BRIEFCASE, null); ZMailbox remoteZmbx = TestUtil.getZMailbox(USER2_NAME); String idStr = TestUtil.search(remoteZmbx, "in:briefcase " + filename, ZSearchParams.TYPE_DOCUMENT).get(0); Document doc = remoteMbox.getDocumentById(null, Integer.parseInt(idStr)); // make sure moved document has note flag. assertEquals(note.getFlags(), doc.getFlagString()); // move the note back to user1 remoteZmbx.moveItem(String.valueOf(doc.getId()), acct.getId() + ":" + Mailbox.ID_FOLDER_BRIEFCASE, null); // reset the access remoteMbox.revokeAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct.getId()); mbox1.revokeAccess(null, Mailbox.ID_FOLDER_BRIEFCASE, acct2.getId()); idStr = TestUtil.search(zmbx, "in:briefcase " + filename, ZSearchParams.TYPE_DOCUMENT).get(0); doc = mbox1.getDocumentById(null, Integer.parseInt(idStr)); // make sure moved document has note flag. assertEquals(note.getFlags(), doc.getFlagString()); }
From source file:com.netflix.dyno.connectionpool.impl.lb.TokenAwareSelection.java
/** * Identifying the proper pool for the operation. A couple of things that may affect the decision * (a) hashtags: In this case we will construct the key by decomposing from the hashtag * (b) type of key: string keys vs binary keys. * In binary keys hashtags do not really matter. */// w ww.ja v a 2 s. c om @Override public HostConnectionPool<CL> getPoolForOperation(BaseOperation<CL, ?> op, String hashtag) throws NoAvailableHostsException { String key = op.getStringKey(); HostConnectionPool<CL> hostPool; HostToken hToken; if (key != null) { // If a hashtag is provided by Dynomite then we use that to create the key to hash. if (hashtag == null || hashtag.isEmpty()) { hToken = this.getTokenForKey(key); } else { String hashValue = StringUtils.substringBetween(key, Character.toString(hashtag.charAt(0)), Character.toString(hashtag.charAt(1))); hToken = this.getTokenForKey(hashValue); } if (hToken == null) { throw new NoAvailableHostsException("Token not found for key " + key); } hostPool = tokenPools.get(hToken.getToken()); ; if (hostPool == null) { throw new NoAvailableHostsException("Could not find host connection pool for key: " + key + ", hash: " + tokenMapper.hash(key) + " Token:" + hToken.getToken()); } } else { // the key is binary byte[] binaryKey = op.getBinaryKey(); hToken = this.getTokenForKey(binaryKey); if (hToken == null) { throw new NoAvailableHostsException("Token not found for key " + binaryKey.toString()); } hostPool = tokenPools.get(hToken.getToken()); if (hostPool == null) { throw new NoAvailableHostsException( "Could not find host connection pool for key: " + binaryKey.toString() + ", hash: " + tokenMapper.hash(binaryKey) + " Token:" + getTokenForKey(binaryKey)); } } return hostPool; }
From source file:com.zfer.kit.StrKit.java
/** * to utf8 string.//from w w w. j av a2 s . com * js?decodeURI(msg)????. * * @param str want to change word * @return utf8 string of str */ public static String toUtf8String(String str) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < str.length(); i++) { char charAt = str.charAt(i); if (charAt <= 255) { sb.append(charAt); } else { byte[] bytes; try { bytes = Character.toString(charAt).getBytes("utf-8"); } catch (UnsupportedEncodingException e) { bytes = new byte[0]; } for (byte ab : bytes) { int abk = ab; if (abk < 0) { abk += 256; } sb.append("%").append(Integer.toHexString(abk).toUpperCase()); } } } return sb.toString(); }
From source file:org.apache.myfaces.shared_impl.renderkit.html.util.JavascriptUtils.java
public static String getValidJavascriptName(String s, boolean checkForReservedWord) { if (checkForReservedWord && RESERVED_WORDS.contains(s)) { return s + "_"; }/* w w w . j a va 2s. com*/ StringBuffer buf = null; for (int i = 0, len = s.length(); i < len; i++) { char c = s.charAt(i); if (Character.isLetterOrDigit(c)) { // allowed char if (buf != null) buf.append(c); } else { if (buf == null) { buf = new StringBuffer(s.length() + 10); buf.append(s.substring(0, i)); } buf.append('_'); if (c < 16) { // pad single hex digit values with '0' on the left buf.append('0'); } if (c < 128) { // first 128 chars match their byte representation in UTF-8 buf.append(Integer.toHexString(c).toUpperCase()); } else { byte[] bytes; try { bytes = Character.toString(c).getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } for (int j = 0; j < bytes.length; j++) { int intVal = bytes[j]; if (intVal < 0) { // intVal will be >= 128 intVal = 256 + intVal; } else if (intVal < 16) { // pad single hex digit values with '0' on the left buf.append('0'); } buf.append(Integer.toHexString(intVal).toUpperCase()); } } } } return buf == null ? s : buf.toString(); }