List of usage examples for java.lang Character toString
public String toString()
From source file:com.aw.swing.mvp.ui.common.LabelResolver.java
public static JLabel getLabelFromDlg(String fieldName) { JLabel label = null;//from w w w. ja v a2 s .c o m fieldName = fieldName.substring(fieldName.indexOf(".") + 1, fieldName.length()); Character init = fieldName.charAt(0); String labelName = init.toString().toUpperCase() + fieldName.substring(1, fieldName.length()); try { label = AWWindowsManager.instance().getCurrentPst().getIpView().getJLabelForComponent(labelName); } catch (IllegalStateException ex) { label = null; } return label; }
From source file:MainClass.java
static String capitalize(String s) throws NullPointerException, AlreadyCapitalizedException { if (s == null) { throw new NullPointerException("Your passed a null argument"); }// w w w . jav a 2s. c om Character firstChar = s.charAt(0); if (Character.isUpperCase(firstChar)) { throw new AlreadyCapitalizedException(); } String theRest = s.substring(1); return firstChar.toString().toUpperCase() + theRest; }
From source file:Main.java
License:asdf
public static ArrayList<String> filter(String[] input, String filter, Integer maxlinelength) { init();/*from w w w . j a v a 2 s. c o 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:com.github.xbn.text.CharUtil.java
public static final String getVisible(Character chr) { if (chr == null) { return "null"; }/* ww w . jav a 2 s .c o m*/ return StringEscapeUtils.escapeJava(chr.toString()); }
From source file:net.lmxm.ute.resources.ResourcesUtils.java
/** * Gets the resource value of the provided value type. * * @param resourceType the resource type to load * @param resourceValueType the resource value type to load * @return the resource value/*from ww w .j av a2 s. co m*/ */ public static String getResource(final ResourceType resourceType, ResourceValueType resourceValueType) { if (resourceValueType == ResourceValueType.ACCELERATOR) { final Character accelerator = getResourceAccelerator(resourceType); return accelerator == null ? null : accelerator.toString(); } else if (resourceValueType == ResourceValueType.MESSAGE) { return getResourceMessage(resourceType); } else if (resourceValueType == ResourceValueType.TEXT) { return getResourceText(resourceType); } else if (resourceValueType == ResourceValueType.TITLE) { return getResourceTitle(resourceType); } else if (resourceValueType == ResourceValueType.TOOLTIP_TEXT) { return getResourceToolTipText(resourceType); } else { throw new IllegalArgumentException("Unsupported resource value type: " + resourceValueType); } }
From source file:de.vandermeer.asciilist.commons.RomanNumberLiterals.java
/** * Converts a string of Roman literals into an array of enumerates for further character conversion. * @param roman string with Roman literals * @return enumerate array for further character conversion */// ww w. ja v a2 s. c o m public final static RomanNumberLiterals[] ROMAN_2_ENUM(String roman) { RomanNumberLiterals[] ret = new RomanNumberLiterals[0]; try { RomanNumberLiterals rnl = RomanNumberLiterals.valueOf(roman); if (rnl != null) { return ArrayUtils.add(ret, rnl); } } catch (Exception ignore) { //this exception happens when no direct mapping is available //ignore and continue to find a manual mapping } for (Character c : roman.toCharArray()) { RomanNumberLiterals rnl = RomanNumberLiterals.valueOf(c.toString()); ret = ArrayUtils.add(ret, rnl); } return ret; }
From source file:com.adobe.acs.commons.rewriter.impl.StaticReferenceRewriteTransformerFactory.java
private static String getShardValue(final String filePath, final int shardCount, final ShardNameProvider sharder) { int result = 1; if (shardCount > 1) { final int fileHash = ((filePath.hashCode() & Integer.MAX_VALUE) % shardCount) + 1; String hostNumberString = Integer.toString(fileHash); if (hostNumberString.length() >= 2) { // get the 2nd digit as the 1st digit will not contain "0" Character c = hostNumberString.charAt(1); hostNumberString = c.toString(); // If there are more than 10 hosts, convert it back to base10 // so we do not have alpha hostNumberString = Integer.toString(Integer.parseInt(hostNumberString, shardCount)); result = Integer.parseInt(hostNumberString) + 1; } else {/* w w w. j a va2 s . c o m*/ result = fileHash; } } return sharder.lookup(result); }
From source file:de.vandermeer.asciithemes.TA_CheckedItem.java
/** * Creates a new checked item./*from w ww. j a va2 s .c o m*/ * @param checked checked label character * @param unchecked unckecked label character * @param description item description * @return new checked item */ public static TA_CheckedItem create(final Character checked, final Character unchecked, final String description) { Validate.notNull(checked); Validate.notNull(unchecked); Validate.notBlank(description); return new TA_CheckedItem() { @Override public String getUncheckedLabel() { return unchecked.toString(); } @Override public String getCheckedLabel() { return checked.toString(); } @Override public String getDescription() { return description; } }; }
From source file:edu.uci.ics.asterix.result.ResultUtils.java
public static String escapeHTML(String s) { for (Character c : HTML_ENTITIES.keySet()) { if (s.indexOf(c) >= 0) { s = s.replace(c.toString(), HTML_ENTITIES.get(c)); }/*from w w w . j av a 2 s .c o m*/ } return s; }
From source file:de.vandermeer.asciithemes.TA_ItemizeList.java
/** * Creates a new itemize list with unlimited levels for given character. * @param label character as label/*w w w . ja va 2 s.c om*/ * @param description list description * @return new list */ public static TA_ItemizeList create(final Character label, final String description) { Validate.notNull(label); Validate.notBlank(description); return new TA_ItemizeList() { @Override public int getMaxLevel() { return -1; } @Override public String getLabel(int level) { return label.toString(); } @Override public String getDescription() { return description; } }; }