List of usage examples for java.lang Character MAX_RADIX
int MAX_RADIX
To view the source code for java.lang Character MAX_RADIX.
Click Source Link
From source file:at.irian.myfaces.wscope.renderkit.html.WsServerSideStateCacheImpl.java
public Object encodeSerializedState(FacesContext facesContext, Object serializedView) { Object[] identifier = new Object[2]; identifier[JSF_SEQUENCE_INDEX] = Integer.toString(getNextViewSequence(facesContext), Character.MAX_RADIX); return identifier; }
From source file:org.latticesoft.util.common.MiscUtil.java
/** * Generates a random alpha numeric string according to the format. * X: upper case letters/*from ww w . j ava 2s . c om*/ * x: lower case letters * n: numeric numbers * @param format the format of the random string * @param maxSleep the randomness seed of the sleep */ public static String getRandomString(String format, int maxSleep) { char c = ' '; if (format == null || format.length() == 0) { return ""; } StringBuffer sb = new StringBuffer(); int theChar = 0; String s = null; for (int i = 0; i < format.length(); i++) { c = format.charAt(i); s = " "; if (c == 'X' || c == 'A') { theChar = 10 + (NumeralUtil.getRandomInt(26 * 5000) % 26); c = Character.forDigit(theChar, Character.MAX_RADIX); s = "" + Character.toUpperCase(c); sb.append(s); } else if (c == 'x' || c == 'a') { theChar = 10 + (NumeralUtil.getRandomInt(26 * 5000) % 26); c = Character.forDigit(theChar, Character.MAX_RADIX); s = "" + Character.toLowerCase(c); sb.append(s); } else if (c == 'n' || c == 'N' || c == '0') { s = "" + (NumeralUtil.getRandomInt(5000) % 10); sb.append(s); } else if (c == 'y' || c == 'Y') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'y' || c1 == 'Y') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2 || size == 4) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 'M') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'M') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2 || size == 3) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 'd') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'd') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 'H') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'H') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 'm') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'm') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 's') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 's') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 2) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else if (c == 'S') { char c1 = ' '; StringBuffer sb2 = new StringBuffer(); for (int j = i; j < format.length(); j++) { c1 = format.charAt(j); if (c1 == 'S') { sb2.append(c1); } else { break; } } int size = sb2.length(); Timestamp ts = DateUtil.getCurrentTimestamp(); if (size == 3) { sb.append(DateUtil.formatDate(sb2.toString(), ts)); } else { sb.append(sb2.toString()); } i += size - 1; } else { s = "" + c; sb.append(s); } ThreadUtil.randomSleep(maxSleep); } return sb.toString(); }
From source file:org.exjello.mail.Exchange2003Connection.java
private static String generateMessageName() { synchronized (RANDOM) { return new BigInteger(200, RANDOM).toString(Character.MAX_RADIX); }/*from w w w.j av a2s. c o m*/ }
From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java
static public String makeAnonymousPsc() throws IOException { Properties properties = new Properties(); String anonEmail = Long.toString(System.currentTimeMillis(), Character.MAX_RADIX) + Long.toString(Math.round(Math.random()) % Character.MAX_RADIX, Character.MAX_RADIX) + "@anonym.ous"; DeploymentKey.adminUser.setValue(properties, 1, anonEmail); DeploymentKey.adminPassword.setValue(properties, 1, ""); DeploymentKey.server.setValue(properties, 1, ""); ByteArrayOutputStream os = new ByteArrayOutputStream(); properties.store(os, " PSC file"); String psc = new String(os.toByteArray(), "iso8859-1"); psc = Crypto2.encodeToHexString("registration", psc); return psc;/*from w w w .ja va2 s . c o m*/ }
From source file:org.apache.lucene.index.IndexWriter.java
final String newSegmentName() { // Cannot synchronize on IndexWriter because that causes // deadlock/* w w w .ja va 2s . c o m*/ synchronized (segmentInfos) { // Important to increment changeCount so that the // segmentInfos is written on close. Otherwise we // could close, re-open and re-return the same segment // name that was previously returned which can cause // problems at least with ConcurrentMergeScheduler. changeCount++; segmentInfos.changed(); return "_" + Integer.toString(segmentInfos.counter++, Character.MAX_RADIX); } }