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:Main.java
public static void main(String[] args) { System.out.println("Character.MAX_RADIX:" + Character.MAX_RADIX); }
From source file:Main.java
public static synchronized String getNonce() { SecureRandom sr = new SecureRandom(); return Long.toString(Math.abs(sr.nextLong()), Character.MAX_RADIX); }
From source file:Main.java
public static int parseInt(char[] string, int start, int length, int radix) throws NumberFormatException { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException("Invalid radix: " + radix); }//from w w w. j ava 2 s .co m if (string == null) { throw new NumberFormatException(new String(string, start, length)); } int i = 0; if (length == 0) { throw new NumberFormatException(new String(string, start, length)); } boolean negative = string[start + i] == '-'; if (negative && ++i == length) { throw new NumberFormatException(new String(string, start, length)); } return parse(string, start, length, i, radix, negative); }
From source file:Main.java
/** * Returns a unique ID which can be used for example as the value of an * attribute of type ID.//from w ww. ja v a 2 s .co m */ public static final String getUniqueId() { StringBuffer buffer = new StringBuffer(); buffer.append("___"); buffer.append(Long.toString(System.currentTimeMillis(), Character.MAX_RADIX)); buffer.append("."); buffer.append(Integer.toString(uniqueId++, Character.MAX_RADIX)); return buffer.toString(); }
From source file:Main.java
/** * Utility method to check validity of the provided code. The version must be base 36 encoded. * * @param code the code string to check. * @param expectedLength the length the code must be. * @param codeVersionStartIndex the start index (INCLUSIVE) to get the code version from. * @param codeVersionEndIndex the end index (EXCLUSIVE) to get the code version from. * @param expectedVersion the version code that the code's version should be checked against. * @return true if the code passes the expected length and version checks. */// w w w .ja v a2s . c o m public static boolean isValidCode(@NonNull final String code, final int expectedLength, final int codeVersionStartIndex, final int codeVersionEndIndex, final int expectedVersion) { boolean isValid = true; if (code.length() != expectedLength) { isValid = false; } else { final String versionCode = code.substring(codeVersionStartIndex, codeVersionEndIndex); final BigInteger i = new BigInteger(versionCode, Character.MAX_RADIX); if (i.intValue() != expectedVersion) { isValid = false; } } return isValid; }
From source file:org.coffeeking.api.ConnectedCupServiceImpl.java
private static String shortUUID() { UUID uuid = UUID.randomUUID(); long l = ByteBuffer.wrap(uuid.toString().getBytes(StandardCharsets.UTF_8)).getLong(); return Long.toString(l, Character.MAX_RADIX); }
From source file:com.machinepublishers.jbrowserdriver.Util.java
private static String randomAlphanumeric() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < 4; i++) { builder.append(Long.toString(Math.abs(secureRand.nextInt()), Math.min(36, Character.MAX_RADIX))); }/* w w w. j a va 2s.com*/ return builder.toString(); }
From source file:Main.java
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. The second argument specifies the radix to use when parsing * the value./* w w w . j ava 2 s. co m*/ * * @param chars a string representation of an int quantity. * @param radix the base to use for conversion. * @return int the value represented by the argument * @throws NumberFormatException if the argument could not be parsed as an int quantity. */ public static int parseInt(char[] chars, int offset, int len, int radix) throws NumberFormatException { if (chars == null || radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException(); } int i = 0; if (len == 0) { throw new NumberFormatException("chars length is 0"); } boolean negative = chars[offset + i] == '-'; if (negative && ++i == len) { throw new NumberFormatException("can't convert to an int"); } if (negative == true) { offset++; len--; } return parse(chars, offset, len, radix, negative); }
From source file:org.gravidence.gravifon.util.BasicUtils.java
/** * Generates secure random token of specified length.<p> * Generated token contains following characters: <code>[0-9a-z]</code>. * /*w w w.j a va 2 s .com*/ * @param numberOfBits token length in bits * @return secure random token */ public static String generateToken(int numberOfBits) { return new BigInteger(numberOfBits, SECURE_RANDOM).toString(Character.MAX_RADIX); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperBigInteger.java
/** * Returns the {@code String} representation of the specified {@link BigInteger}. * * @param bi The {@link BigInteger} to be converted. * @return The {@code String} representation of the specified {@link BigInteger}. *//*from ww w . j a va2s . c om*/ private static String encode(BigInteger bi) { return bi.toString(Character.MAX_RADIX); }