List of usage examples for java.lang Character charValue
@HotSpotIntrinsicCandidate public char charValue()
From source file:z.tool.util.ToStringBuilder.java
public ToStringBuilder add(String key, Character value) { if (null != key && null != value) { getOrTryInitBuff().append(key).append(":").append(value.charValue()).append(SEP); }/* w ww .j a va2 s . c o m*/ return this; }
From source file:com.rgam.morsekeyboard.TryFragment.java
private void commitTyped() { if (!settings.getBoolean(Constants.GTAP_PREDICTIVE_MODE, false) && !textBuilder.toString().equals(" ")) { Character morseCharacter = Morse.characterFromCode(textBuilder.toString()); if (morseCharacter != null) { String morseString = String.valueOf(morseCharacter.charValue()); textBuilder = new StringBuilder(morseString); } else {//from w ww . j ava 2 s . com textBuilder.setLength(0); } } text.append(textBuilder); textBuilder.setLength(0); updateCandidate(); }
From source file:com.glaf.core.util.StringTools.java
public static String splitLine(String sourceString, int length) { if (sourceString == null) { return ""; }//from w w w .ja v a2s . c o m if (sourceString.length() <= length) { return sourceString; } char[] sourceChrs = sourceString.toCharArray(); char[] distinChrs = new char[length]; for (int i = 0; i < length; i++) { if (i >= sourceChrs.length) { return sourceString; } Character chr = Character.valueOf(sourceChrs[i]); if (chr.charValue() <= 202 && chr.charValue() >= 8) { distinChrs[i] = chr.charValue(); } else { distinChrs[i] = chr.charValue(); length--; } } return new String(distinChrs) + ""; }
From source file:com.glaf.core.util.StringTools.java
public static String formatLine(String sourceString, int length) { if (sourceString == null) { return ""; }//from ww w.java2 s .c o m if (sourceString.length() <= length) { StringBuffer buffer = new StringBuffer(sourceString.length() + 10); int k = length - sourceString.length(); for (int j = 0; j < k; j++) { buffer.append(sourceString).append(" "); } sourceString = buffer.toString(); return sourceString; } char[] sourceChrs = sourceString.toCharArray(); char[] distinChrs = new char[length]; for (int i = 0; i < length; i++) { if (i >= sourceChrs.length) { return sourceString; } Character chr = Character.valueOf(sourceChrs[i]); if (chr.charValue() <= 202 && chr.charValue() >= 8) { distinChrs[i] = chr.charValue(); } else { distinChrs[i] = chr.charValue(); length--; } } return new String(distinChrs) + ""; }
From source file:org.docx4j.fonts.fop.fonts.SingleByteFont.java
/** * Makes all unencoded characters available through additional encodings. This method * is used in cases where the fonts need to be encoded in the target format before * all text of the document is processed (for example in PostScript when resource optimization * is disabled)./*from ww w.j a v a2 s .c o m*/ */ public void encodeAllUnencodedCharacters() { if (this.unencodedCharacters != null) { Set sortedKeys = new java.util.TreeSet(this.unencodedCharacters.keySet()); Iterator iter = sortedKeys.iterator(); while (iter.hasNext()) { Character ch = (Character) iter.next(); char mapped = mapChar(ch.charValue()); assert mapped != Typeface.NOT_FOUND; } } }
From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java
private void refreshMnemonic(final Action actionImpl) { final Object o = actionImpl.getValue(Action.MNEMONIC_KEY); if (o != null) { if (o instanceof Character) { final Character c = (Character) o; setAccesskey(String.valueOf(c.charValue())); } else if (o instanceof Integer) { final Integer c = (Integer) o; setAccesskey(String.valueOf(c.intValue())); }/* ww w . ja v a 2 s . com*/ } else { setAccesskey("\0"); } }
From source file:org.apache.fop.fonts.SingleByteFont.java
/** * Makes all unencoded characters available through additional encodings. This method * is used in cases where the fonts need to be encoded in the target format before * all text of the document is processed (for example in PostScript when resource optimization * is disabled).// w w w .j a v a2 s . com */ public void encodeAllUnencodedCharacters() { if (this.unencodedCharacters != null) { Set<Character> sortedKeys = new TreeSet<Character>(this.unencodedCharacters.keySet()); for (Character ch : sortedKeys) { char mapped = mapChar(ch.charValue()); assert mapped != Typeface.NOT_FOUND; } } }
From source file:org.acmsl.commons.utils.ConversionUtils.java
/** * Converts given String to char./*from w ww. ja v a2 s . com*/ * @param value the value to convert. * @return the converted value. */ public char toChar(@Nullable final String value) { char result = (char) -1; @Nullable final Character t_Result = toCharIfNotNull(value); if (t_Result != null) { result = t_Result.charValue(); } if ((value == null) || (!value.equals(Character.toString(result)))) { result = (char) -1; } return result; }
From source file:Main.java
License:asdf
public static ArrayList<String> filter(String[] input, String filter, Integer maxlinelength) { init();/*from w w w .j ava 2 s. co m*/ //include both uppercase and lowercase letters in filter //example: asdF becomes asdfASDF filter = filter.toLowerCase() + filter.toUpperCase(); ArrayList<String> array = new ArrayList<String>(); String charstring; String filteredstring = ""; boolean lastwasspace = true; // ensure that text does not begin with a // space Integer counter = 0; for (String s : input) { //terminate with space - add a space between lines s += " "; for (Character c : s.toCharArray()) { charstring = c.toString(); //prevent doublespace; //break lines on spaces, when line meets or exceeds maxlinelength if (c == ' ') { if (lastwasspace) { // ignore double spaces } else { lastwasspace = true; if (filter.contains(charstring)) { filteredstring += " "; } //if filter doesn't contain " ", //we'll add one anyway every few words else { counter++; Log.e("", counter.toString()); if (counter == 4) { counter = 0; filteredstring += " "; Log.e("", "space"); } } // add and reset only if adding the next string will // exceed length limit if (filteredstring.length() >= maxlinelength) { array.add(filteredstring); filteredstring = ""; } } } else if (filter.contains(charstring)) { lastwasspace = false; filteredstring += charstring; if (Character.getNumericValue(c.charValue()) >= 0) chartotals[Character.getNumericValue(c.charValue())]++; } } } array.add(filteredstring); // for (int i = 0; i < chartotals.length; i++) // System.out.println(String.valueOf(i) + " " + chartotals[i]); //calculate total number of letters totalcharcount = 0; for (String s : array) totalcharcount += s.length(); return array; }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Creates a menubar./* w ww . j av a 2 s . c om*/ * * @param resources localised resources. * * @return the menu bar. */ private JMenuBar createMenuBar(final ResourceBundle resources) { // create the menus final JMenuBar menuBar = new JMenuBar(); String label; Character mnemonic; // first the file menu label = resources.getString("menu.file"); mnemonic = (Character) resources.getObject("menu.file.mnemonic"); final JMenu fileMenu = new JMenu(label, true); fileMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.file.exit"); mnemonic = (Character) resources.getObject("menu.file.exit.mnemonic"); final JMenuItem exitItem = new JMenuItem(label, mnemonic.charValue()); exitItem.setActionCommand(EXIT_COMMAND); exitItem.addActionListener(this); fileMenu.add(exitItem); // then the help menu label = resources.getString("menu.help"); mnemonic = (Character) resources.getObject("menu.help.mnemonic"); final JMenu helpMenu = new JMenu(label); helpMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.help.about"); mnemonic = (Character) resources.getObject("menu.help.about.mnemonic"); final JMenuItem aboutItem = new JMenuItem(label, mnemonic.charValue()); aboutItem.setActionCommand(ABOUT_COMMAND); aboutItem.addActionListener(this); helpMenu.add(aboutItem); // finally, glue together the menu and return it menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; }