List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:com.albert.util.StringUtilCommon.java
/** * Determine if the given OEN passed the OEN verification rule. * @param oen/*from w ww . j a v a2 s .c o m*/ * @return boolean */ public static boolean isValidOenFormat(String oen) { String OEN_MASK = "0246813579135792468024680357913579146802468025791357913680246802479135791358024680246913579135702468"; int MIN_OEN = 60000000; if (isEmpty(oen) || !isNumerical(oen) || oen.length() != 9 || Integer.parseInt(oen) < MIN_OEN) { return false; } int maskValue = 0; int checkDigit = 0; String oenNumber = oen; String[] oenGroup = null; oenGroup = oenNumber.split("(?<=\\G.{2})"); for (int i = 0; i < 4; i++) { maskValue = maskValue + Integer.parseInt(Character.toString(OEN_MASK.charAt((Integer.parseInt(oenGroup[i]))))); } checkDigit = ((maskValue / 10 + 1) * 10) - maskValue; if (checkDigit == 10) { checkDigit = 0; } return (Integer.parseInt(oenGroup[oenGroup.length - 1]) == checkDigit); }
From source file:com.roncoo.pay.permission.utils.ValidateUtils.java
/** * ?/*from ww w . j a va2s .co m*/ * * @param orgCode * @return */ public static final boolean isOrgCode(String orgCode) { String[] codeNo = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; String[] staVal = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35" }; Pattern pat = Pattern.compile("^[0-9A-Z]{8}-[0-9X]$"); Matcher matcher = pat.matcher(orgCode); if (!matcher.matches()) { return false; } Map map = new HashMap(); for (int i = 0; i < codeNo.length; i++) { map.put(codeNo[i], staVal[i]); } final int[] wi = { 3, 7, 9, 10, 5, 8, 4, 2 }; String[] all = orgCode.split("-"); final char[] values = all[0].toCharArray(); int parity = 0; for (int i = 0; i < values.length; i++) { final String val = Character.toString(values[i]); parity += wi[i] * Integer.parseInt(map.get(val).toString()); } String cheak = (11 - parity % 11) == 10 ? "X" : Integer.toString((11 - parity % 11)); return cheak.equals(all[1]); }
From source file:eu.stratosphere.runtime.fs.s3.S3FileSystem.java
@Override public boolean mkdirs(final Path f) throws IOException { final S3BucketObjectPair bop = this.directoryStructure.toBucketObjectPair(f); if (!bop.hasBucket() && !bop.hasObject()) { // Ignore this call return false; }/*w w w.java 2s . c o m*/ boolean retCode = false; try { // Make sure the bucket exists if (bop.hasBucket()) { if (this.s3Client.doesBucketExist(bop.getBucket())) { } else { this.s3Client.createBucket(bop.getBucket()); retCode = true; } } if (bop.hasObject()) { // Make sure object name ends with a directory separator character String object = bop.getObject(); if (!object.isEmpty()) { if (object.charAt(object.length() - 1) != S3_DIRECTORY_SEPARATOR) { object = object.concat(Character.toString(S3_DIRECTORY_SEPARATOR)); } } while (true) { try { this.s3Client.getObjectMetadata(bop.getBucket(), object); } catch (AmazonServiceException e) { if (e.getStatusCode() == HTTP_RESOURCE_NOT_FOUND_CODE) { createEmptyObject(bop.getBucket(), object); if (object.length() > 1) { final int nextPos = object.lastIndexOf(S3_DIRECTORY_SEPARATOR, object.length() - 2); if (nextPos >= 0) { object = object.substring(0, nextPos + 1); continue; } } } else { // Rethrow the exception throw e; } } // Object already exists, exit break; } } } catch (AmazonClientException e) { throw new IOException(StringUtils.stringifyException(e)); } return retCode; }
From source file:com.rs.worldserver.io.IOClient.java
public PlayerDetails loadGame(String playerName, String playerPass) { PlayerDetails tempPlayer;/*from ww w . j av a 2 s . c o m*/ String file = ""; String firstLetters = Character.toString(playerName.charAt(0)); file = "./savedGames/" + firstLetters.toLowerCase() + "/" + playerName + ".json"; try { File f = new File(file); if (!f.exists()) f.createNewFile(); BufferedReader br = new BufferedReader(new FileReader(file)); //convert the json string back to object tempPlayer = new Gson().fromJson(br, PlayerDetails.class); br.close(); } catch (Exception e) { return null; } return tempPlayer; }
From source file:ml.shifu.shifu.core.binning.EqualPopulationBinning.java
public void stringToObj(String objValStr) { super.stringToObj(objValStr); String[] objStrArr = objValStr.split(Character.toString(FIELD_SEPARATOR), -1); maxHistogramUnitCnt = Integer.parseInt(objStrArr[4]); if (objStrArr.length > 5 && StringUtils.isNotBlank(objStrArr[5])) { String[] histogramStrArr = objStrArr[5].split(Character.toString(SETLIST_SEPARATOR), -1); for (String histogramStr : histogramStrArr) { HistogramUnit hu = HistogramUnit.stringToObj(histogramStr); this.insertWithTrim(new LinkNode<HistogramUnit>(hu)); }//from w ww .j a v a2 s.c om } else { log.warn("Empty categorical bin - " + objValStr); } }
From source file:eu.stratosphere.nephele.fs.s3.S3FileSystem.java
/** * {@inheritDoc}// ww w.j a v a2s .c o m */ @Override public boolean mkdirs(final Path f) throws IOException { final S3BucketObjectPair bop = this.directoryStructure.toBucketObjectPair(f); if (!bop.hasBucket() && !bop.hasObject()) { // Ignore this call return false; } boolean retCode = false; try { // Make sure the bucket exists if (bop.hasBucket()) { if (this.s3Client.doesBucketExist(bop.getBucket())) { } else { this.s3Client.createBucket(bop.getBucket()); retCode = true; } } if (bop.hasObject()) { // Make sure object name ends with a directory separator character String object = bop.getObject(); if (!object.isEmpty()) { if (object.charAt(object.length() - 1) != S3_DIRECTORY_SEPARATOR) { object = object.concat(Character.toString(S3_DIRECTORY_SEPARATOR)); } } while (true) { try { this.s3Client.getObjectMetadata(bop.getBucket(), object); } catch (AmazonServiceException e) { if (e.getStatusCode() == HTTP_RESOURCE_NOT_FOUND_CODE) { createEmptyObject(bop.getBucket(), object); if (object.length() > 1) { final int nextPos = object.lastIndexOf(S3_DIRECTORY_SEPARATOR, object.length() - 2); if (nextPos >= 0) { object = object.substring(0, nextPos + 1); continue; } } } else { // Rethrow the exception throw e; } } // Object already exists, exit break; } } } catch (AmazonClientException e) { throw new IOException(StringUtils.stringifyException(e)); } return retCode; }
From source file:edu.pitt.dbmi.facebase.hd.HumanDataController.java
/** generates and returns one-time-password * OTP is a long sent to Hub demonstrating that http request is legit, Hub checks it against * This should thwart any bogus/malicious but similar HTTP requests from Internet, since bogus * requesters won't be able to generate a hash that passes muster...Hub ignores requests with bad OTP * @return code, based on current time/* w w w. j a va 2 s .c o m*/ */ public static long getOTP() { long w = 100; long t = System.currentTimeMillis() / 1000; long r = (long) Math.floor(t / w) * w; long s = 0; Long rLong = new Long(r); String sString = rLong.toString(); for (int i = 0; i < sString.length(); i++) { char aChar = sString.charAt(i); String oneCharString = Character.toString(aChar); s += Integer.parseInt(oneCharString); } long p = (long) Math.pow(s, 5); return (r % p); }
From source file:org.apache.hadoop.fs.FileSystemContractBaseTest.java
/** * Convert a byte to a character for printing. If the * byte value is < 32 -and hence unprintable- the byte is * returned as a two digit hex value/* www. jav a 2 s . c om*/ * @param b byte * @return the printable character string */ protected String toChar(byte b) { if (b >= 0x20) { return Character.toString((char) b); } else { return String.format("%02x", b); } }
From source file:cx.ring.fragments.CallFragment.java
public void onKeyUp(int keyCode, KeyEvent event) { try {/* w ww .j av a 2 s . co m*/ switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: break; default: String toSend = Character.toString(event.getDisplayLabel()); toSend = toSend.toUpperCase(Locale.getDefault()); Log.d(TAG, "toSend " + toSend); mCallbacks.getRemoteService().playDtmf(toSend); break; } } catch (RemoteException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.joinproperty.JoinMapGrid.java
private HashMap<String, List<String>> setMapOfInputFieldsPerPort() { HashMap<String, List<String>> inputFieldMap = new HashMap<String, List<String>>(); int j = 0;/* w ww . j a v a2 s. c o m*/ for (List<FilterProperties> inputFieldList : joinInputSchemaList) { List<String> inputFieldListPerPort = new ArrayList<>(); for (FilterProperties inputField : inputFieldList) { for (LookupMapProperty lookupMapProperty : joinOutputList) { char charactor = ' '; if (lookupMapProperty.getSource_Field().length() >= 3) { charactor = lookupMapProperty.getSource_Field().charAt(2); } if (Character.toString(charactor).equalsIgnoreCase(Integer.toString(j))) { if (!inputFieldListPerPort.contains(inputField.getPropertyname())) { inputFieldListPerPort.add(inputField.getPropertyname()); } } } } inputFieldMap.put(IN + j, inputFieldListPerPort); j++; } return inputFieldMap; }