List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:com.plm.model.RecordingQueue.java
public void setPackageAssetId(String assetId) { if (assetId.length() == 16 && StringUtils.isAlpha(Character.toString(assetId.charAt(0)))) { /*/*from w w w .j ava 2 s. com*/ * Added as workaround for auto approve functionality. * Should be removed once SQL procedure is fixed. */ this.assetId = RCSConstants.PACKAGE_ASSET_ID_PREFIX + assetId; } else { this.assetId = assetId; } }
From source file:com.prowidesoftware.swift.io.parser.SwiftParser.java
/** * Consume the next block of the message on the reader. * This methods seeks to a block start, then identifies the block * and calls the proper method to consume the block type * that is coming, not all blocks are parsed in the same manner. * @param unparsedReceiver may be <code>null</code>, the unparsedTextList that will receive the chunks that can not be identified sas part of the message * * @return the next block in the reader or <code>null</code> if none was found (i.e: end of input) * @throws IOException if an error occurred during read */// w w w . ja v a 2 s .c o m protected SwiftBlock consumeBlock(final UnparsedTextList unparsedReceiver) throws IOException { // search for block start final String unparsed = findBlockStart(); // si el string es no vacio agregarlo a unparsed texts // read the block contents final String s = readUntilBlockEnds(); if ("".equals(s)) { /* if we have an unparsed text add it to last block */ if (unparsed.length() > 0) { if (unparsedReceiver == null) { log.warning( "Unparsed text '" + unparsed + "' can not be reported since unparsedReceiver is null"); } else { unparsedReceiver.addText(unparsed); } } return null; } // analyze if it is an unparsed text // // NOTE: This can happen when we have got a block 1 and there is already a block 1 // if (s.startsWith("1:") && this.currentMessage != null && this.currentMessage.getBlock1() != null) { // unparsed text => initialize value to append final StringBuilder utBuffer = new StringBuilder(); utBuffer.append("{"); utBuffer.append(s); utBuffer.append("}"); boolean done = false; while (!done) { // try to read a block of data final char data[] = new char[128]; final int size = this.reader.read(data); if (size > 0) { // append the read buffer utBuffer.append(data); } else { // we are done done = true; } } final String unparsedText = utBuffer.toString(); // build an unparsed text list final UnparsedTextList list = processUnparsedText(unparsedText); if (list != null) { this.currentMessage.setUnparsedTexts(list); } // no more reading return null; } // identify and create the proper block final char blockId = identifyBlock(s); SwiftBlock b; if (blockId == ' ') { // block cannot be identified log.severe("unidentified block:" + s); throw new WifeException("The block " + s + " could not be identified"); } // create the block object switch (blockId) { case '1': // block 1 (single valued) b = new SwiftBlock1(s, this.configuration.isLenient()); break; case '2': // block 2 (single valued) if (isInput(s)) { b = new SwiftBlock2Input(s, this.configuration.isLenient()); } else { b = new SwiftBlock2Output(s, this.configuration.isLenient()); } break; case '3': // block 3 (tag list) b = tagListBlockConsume(new SwiftBlock3(), s); break; case '4': // block 4 if (this.configuration.isParseTextBlock()) { if (isTextBlock(s)) { b = block4Consume(new SwiftBlock4(), s); } else { b = tagListBlockConsume(new SwiftBlock4(), s); } } else { b = new SwiftBlock4(); } break; case '5': // block 5 (tag list) if (this.configuration.isParseTrailerBlock()) { b = tagListBlockConsume(new SwiftBlock5(), s); } else { b = new SwiftBlock5(); } break; default: // user defined block (tag list) if (this.configuration.isParseUserBlock()) { b = tagListBlockConsume(new SwiftBlockUser(Character.toString(blockId)), s); } else { b = new SwiftBlockUser(); } break; } if (unparsed.length() > 0) { if (unparsedReceiver == null) { log.warning("Unparsed text '" + unparsed + "' can not be reported since unparsedReceiver is null"); } else { unparsedReceiver.addText(unparsed); } } return b; }
From source file:es.uvigo.ei.sing.adops.datatypes.ExperimentOutput.java
public int[] loadScores() throws IOException { if (this.getRenamedScoreAsciiFile().exists()) { final List<String> lines = FileUtils.readLines(this.getRenamedScoreAsciiFile()); String score = ""; for (String line : lines) { if (line.matches("c[o-]n?\\s+([0-9]|-)+")) { score += line.split("\\s+")[1]; }/*from w ww.j a v a2 s. c om*/ } final int scores[] = new int[score.length()]; for (int i = 0; i < score.length(); i++) { try { scores[i] = Integer.valueOf(Character.toString(score.charAt(i))); } catch (NumberFormatException nfe) { scores[i] = -1; } } return scores; } else { return null; } }
From source file:no.lookout.incontrol.Module.java
protected Module(JSONObject module, HttpParams httpParams, String baseUrl, String userName, String password) throws JSONException { this.httpParams = httpParams; this.baseUrl = baseUrl; this.userName = userName; this.password = password; house = module.getString("house").charAt(0); unit = (byte) module.getInt("unit"); url = module.getString("url"); if (module.has("type")) { switch (module.getInt("type")) { case 1:// ww w . ja v a 2 s .c o m persistedType = Type.Appliance; break; case 2: persistedType = Type.Dimmer; break; case 3: persistedType = Type.Sensor; break; default: persistedType = Type.Unknown; break; } } persistedName = module.has("name") ? module.getString("name") : Character.toString(house) + unit; if (module.has("on")) { persistedState = module.getBoolean("on") ? State.On : State.Off; } if (module.has("brightness")) { persistedBrightness = (byte) module.getInt("brightness"); } type = persistedType; name = persistedName; state = persistedState; brightness = persistedBrightness; }
From source file:com.kyleszombathy.sms_scheduler.Home.java
private Bitmap createCircleImageFromFirstLetterOfName(String firstName) { // Get color//from w w w. j a v a2 s .c o m ColorGenerator generator = ColorGenerator.MATERIAL; int color = generator.getColor(firstName); //Always use same color for a specific person TextDrawable drawable = TextDrawable.builder(this).beginConfig().useFont(Typeface.DEFAULT_BOLD) .fontSize(circleImageViewTextSize).height(circleImageViewWidth).width(circleImageViewWidth) .endConfig().buildRound(Character.toString(firstName.charAt(0)).toUpperCase(), color); return Tools.drawableToBitmap(drawable); // Convert to bitmap }
From source file:org.diorite.cfg.messages.DioriteMessages.java
/** * Returns messages for given plugin, may return null if plugin don't use diorite message system. :( * * @param plugin plugin to get messages. * * @return messages for given plugin or null. *//*from ww w .j a va2 s. c o m*/ public static Messages getPluginMessages(final BasePlugin plugin) { return getMessages("plugins" + getNodeSeparator() + StringUtils.replaceEach(plugin.getName(), new String[] { Character.toString(getNodeSeparator()), ChildPlugin.CHILD_SEPARATOR }, new String[] { "_", getNodeSeparator() + "plugins" + getNodeSeparator() })); }
From source file:com.webcohesion.enunciate.modules.ruby_json_client.RubyJSONClientModule.java
protected String packageToModule(String pckg) { if (pckg == null) { return null; } else {/* ww w . j a v a 2s. c o m*/ StringBuilder ns = new StringBuilder(); for (StringTokenizer toks = new StringTokenizer(pckg, "."); toks.hasMoreTokens();) { String tok = toks.nextToken(); ns.append(Character.toString(tok.charAt(0)).toUpperCase()); if (tok.length() > 1) { ns.append(tok.substring(1)); } if (toks.hasMoreTokens()) { ns.append("::"); } } return ns.toString(); } }
From source file:org.dhatim.edisax.BufferedSegmentReader.java
/** * Move to the next EDI segment.//from w w w . j ava 2 s.c o m * <p/> * Simply reads and buffers the next EDI segment. * @param clearBuffer Clear the segment buffer before reading. * @return True if a "next" segment exists, otherwise false. * @throws IOException Error reading from EDI stream. */ public boolean moveToNextSegment(boolean clearBuffer) throws IOException { char[] segmentDelimiter = currentDelimiters.getSegmentDelimiter(); int delimiterLen = segmentDelimiter.length; String escape = currentDelimiters.getEscape(); int escapeLen = escape != null ? escape.length() : 0; boolean ignoreCRLF; int c = readChar(); // Ignoring of new lines can be set as part of the segment delimiter, or // as a feature on the parser (the later is the preferred method)... ignoreCRLF = (currentDelimiters.ignoreCRLF() || ignoreNewLines); if (clearBuffer) { segmentBuffer.setLength(0); } currentSegmentFields = null; // We reached the end of the stream the last time this method was // called - see the while loop below... if (c == -1) { return false; } // Ignore leading whitespace on a segment... c = forwardPastWhitespace(c); boolean escapingMode = false; // Read the next segment... while (c != -1) { char theChar = (char) c; if (ignoreCRLF && (theChar == '\n' || theChar == '\r')) { c = readChar(); continue; } segmentBuffer.append((char) c); int segLen = segmentBuffer.length(); if (segLen >= delimiterLen) { boolean reachedSegEnd = true; for (int i = 0; i < delimiterLen; i++) { char segChar = segmentBuffer.charAt(segLen - 1 - i); char delimChar = segmentDelimiter[delimiterLen - 1 - i]; if (escapingMode) { if (segChar == delimChar) { segmentBuffer = segmentBuffer.delete(segLen - 2, segLen - 1); } escapingMode = false; reachedSegEnd = false; break; } else if (escape != null && escape.equals(Character.toString(segChar))) { escapingMode = true; } if (segChar != delimChar) { // Not the end of a segment reachedSegEnd = false; break; } } // We've reached the end of a segment... if (reachedSegEnd) { // Trim off the delimiter and break out... segmentBuffer.setLength(segLen - delimiterLen); break; } } c = readChar(); } if (logger.isDebugEnabled()) { logger.debug(segmentBuffer.toString()); } currentSegmentNumber++; if (segmentListener != null) { return segmentListener.onSegment(this); } else { return true; } }
From source file:com.tesora.dve.sql.parser.InvokeParser.java
public static ParseResult parse(byte[] line, SchemaContext pc, Charset cs) throws ParserException { preparse(pc);/*from w ww.jav a2 s . com*/ ParserOptions options = ParserOptions.NONE.setDebugLog(true).setResolve().setFailEarly(); String lineStr = PECharsetUtils.getString(line, cs, true); if (lineStr != null) { lineStr = StringUtils.strip(lineStr, new String(Character.toString(Character.MIN_VALUE))); return parse(buildInputState(lineStr, pc), options, pc); } return parameterizeAndParse(pc, options, line, cs); }
From source file:by.zatta.pilight.model.Config.java
@SuppressLint("SimpleDateFormat") public static List<DeviceEntry> update(OriginEntry originEntry) { lastUpdateString = ""; int decimals = -1; int gui_decimals = -1; String name = ""; String value = ""; DecimalFormat digits = new DecimalFormat("#,##0.0");// format to 1 decimal place for (DeviceEntry device : mDevices) { if (device.getNameID().equals(originEntry.getNameID())) { // Log.v(TAG, "updating: " + device.getNameID()); for (SettingEntry sentry : device.getSettings()) { // Log.v(TAG, sentry.getKey()); if (sentry.getKey().equals("name")) { originEntry.setPopularName(sentry.getValue()); name = sentry.getValue(); }/*from w w w . j ava2 s .com*/ if (sentry.getKey().equals("device-decimals")) { decimals = Integer.valueOf(sentry.getValue()); // Log.v(TAG, sentry.getValue()); } if (sentry.getKey().equals("gui-decimals")) { gui_decimals = Integer.valueOf(sentry.getValue()); switch (gui_decimals) { case 1: digits = new DecimalFormat("#,##0.0");// format to 1 decimal place break; case 2: digits = new DecimalFormat("#,##0.00");// format to 1 decimal place break; case 3: digits = new DecimalFormat("#,##0.000");// format to 1 decimal place break; case 4: digits = new DecimalFormat("#,##0.0000");// format to 1 decimal place break; default: digits = new DecimalFormat("#,##0.0");// format to 1 decimal place break; } } } for (SettingEntry sentry : device.getSettings()) { for (SettingEntry orSentry : originEntry.getSettings()) { if (sentry.getKey().equals(orSentry.getKey())) { sentry.setValue(orSentry.getValue()); if (sentry.getKey().equals("temperature") && (decimals != -1)) { String temp = digits.format( Integer.valueOf(sentry.getValue()) / (Math.pow(10, decimals))) + " \u2103"; if (!value.contains("Temp:")) value = value + "Temp: " + temp + "\n"; } else if (sentry.getKey().equals("humidity") && (decimals != -1)) { String hum = digits.format( Integer.valueOf(sentry.getValue()) / (Math.pow(10, decimals))) + " %"; if (!value.contains("Humidity:")) value = value + "Humidity: " + hum + "\n"; } else if (sentry.getKey().equals("timestamp")) { if (!value.contains("Stamp: ")) value = value + "Stamp: " + new SimpleDateFormat("HH:mm:ss") .format(Long.valueOf(sentry.getValue()) * 1000) + "\n"; } else { char firstChar = orSentry.getKey().charAt(0); char replaceBy = Character.toUpperCase(firstChar); String what = orSentry.getKey().replaceFirst(Character.toString(firstChar), Character.toString(replaceBy)); if (!value.contains(what)) value = value + what + ": " + orSentry.getValue() + "\n"; } } } } } } lastUpdateString = name + "\n" + value; return mDevices; }