List of usage examples for java.lang Character getNumericValue
public static int getNumericValue(int codePoint)
From source file:Main.java
public static void main(String[] args) { int cp1 = 88, cp2 = 0x0f30; int i1 = Character.getNumericValue(cp1); int i2 = Character.getNumericValue(cp2); String str1 = "Numeric value of code point cp1 is " + i1; String str2 = "Numeric value of code point cp2 is " + i2; // print i1, i2 values System.out.println(str1);//w ww . j a v a 2 s . c o m System.out.println(str2); }
From source file:Main.java
public static void main(String[] argv) { Character character1 = new Character('a'); Character character2 = new Character('a'); System.out.println(character1.toString()); System.out.println(Character.getNumericValue(character2)); }
From source file:Main.java
public static boolean isLuhnValid(String input) { if (input.length() >= 10) { int sum = 0; boolean alternate = false; for (int i = input.length() - 1; i >= 0; i--) { int num = Character.getNumericValue(input.charAt(i)); if (!alternate) { num = num * 1;/*from w ww .ja va 2 s . c om*/ } else { num = num * 2; } if (num > 9) { num -= 9; } sum += num; alternate = !alternate; } return (sum % 10 == 0); } return false; }
From source file:Main.java
/** * Escape html entities.// ww w . j a v a 2s . com * @param str The input string. * @return The HTML escaped output string. */ public static String htmlEscape(String str) { StringBuilder sb = new StringBuilder(); int size = str.length(); for (int i = 0; i < size; i++) { char c = str.charAt(i); switch (c) { case '<': { sb.append("<"); break; } case '>': { sb.append(">"); break; } case '"': { sb.append("""); break; } case '&': { sb.append("&"); break; } default: { int cc = Character.getNumericValue(c); if (cc < 0xA0) { sb.append(c); } else { // encode in unicode reference sb.append("&#").append(Integer.toString(cc)).append(';'); } break; } } } return sb.toString(); }
From source file:Main.java
public static int ConvertFromHexadecimalToDecimal(String num) { int a;/*from w w w . ja v a 2s. com*/ int ctr = 0; double prod = 0; for (int i = num.length(); i > 0; i--) { if (num.charAt(i - 1) == 'a' || num.charAt(i - 1) == 'A') a = 10; else if (num.charAt(i - 1) == 'b' || num.charAt(i - 1) == 'B') a = 11; else if (num.charAt(i - 1) == 'c' || num.charAt(i - 1) == 'C') a = 12; else if (num.charAt(i - 1) == 'd' || num.charAt(i - 1) == 'D') a = 13; else if (num.charAt(i - 1) == 'e' || num.charAt(i - 1) == 'E') a = 14; else if (num.charAt(i - 1) == 'f' || num.charAt(i - 1) == 'F') a = 15; else a = Character.getNumericValue(num.charAt(i - 1)); prod = prod + (a * Math.pow(16, ctr)); ctr++; } return (int) prod; }
From source file:be.fgov.minfin.webForm.util.ISINValidationUtil.java
public int calculcateModulus(String code, boolean includesCheckDigit) throws CheckDigitException { StringBuilder transformed = new StringBuilder(code.length() * 2); if (includesCheckDigit) { char checkDigit = code.charAt(code.length() - 1); // Choppe le dernier caractre if (!Character.isDigit(checkDigit)) { throw new CheckDigitException("Invalid checkdigit[" + checkDigit + "] in " + code); }// w ww . j a v a2s. co m } for (int i = 0; i < code.length(); i++) { int charValue = Character.getNumericValue(code.charAt(i)); if (charValue < 0 || charValue > 35) { throw new CheckDigitException("Invalid Character[" + (i + 1) + "] = '" + charValue + "'"); } transformed.append(charValue); } //Doit retourner 0 pour que ce soit valide return super.calculateModulus(transformed.toString(), includesCheckDigit); }
From source file:Main.java
License:asdf
public static ArrayList<String> filter(String[] input, String filter, Integer maxlinelength) { init();/*www . jav a 2s .c om*/ //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.talend.dataquality.datamasking.functions.GenerateUniqueSsnChn.java
private String computeChineseKey(String ssnNumber) { int key = 0;//w w w. j a v a 2 s . com for (int i = 0; i < 17; i++) { key += Character.getNumericValue(ssnNumber.charAt(i)) * keyWeight.get(i); } key = key % KEYMOD; return keyString.get(key); }
From source file:org.talend.dataquality.datamasking.functions.GenerateSsnChn.java
private String computeChineseKey(String ssnNumber) { int key = 0;/*from ww w . j a v a 2 s. com*/ for (int i = 0; i < 17; i++) { key += Character.getNumericValue(ssnNumber.charAt(i)) * keyWeight.get(i); } key = key % KEY_MOD; return keyString.get(key); }
From source file:org.paxml.selenium.rc.AccountNumberValidator.java
/** * Method to Validate Account Number./*from w w w . j av a 2s. c o m*/ * * @param accNo for modula11 validation. * @return boolean */ public static boolean modula11(String accNo) { boolean result = false; int l = accNo.length(); int total = 0; try { for (int i = 0; i < l; i++) { int j = Character.getNumericValue(accNo.charAt(i)) * (l - i); total += j; } total = total % ELEVEN; if (total == 0) { result = true; } } catch (NumberFormatException e) { if (LOG.isErrorEnabled()) { LOG.error("Error1: " + e.getMessage()); } } return result; }