public class JavaUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JavaUtil.InputMonitor |
static class |
JavaUtil.N2AFilter |
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE |
| Modifier and Type | Method and Description |
|---|---|
static String |
baseClassOfArray(String className) |
static String |
baseName(String fullClassName)
This will return a name from @param fullClassName where everything upto
and including the last '.' is removed.
|
static boolean |
canProduceNoXMLMetaChars(String className) |
static boolean |
checkValueToType(String type,
String value)
checkValueToType will make sure that a given value is
acceptable for a given type.
|
static String |
compareTo(String value1,
String type1,
String value2)
Convert @param value2 (a literal) to @param type1 and then
compare that to @param value1.
|
static String |
compareToText(String value1,
String type1,
String value2Text)
Just like compareTo, but the second value (@param value2Text) is
unquoted text.
|
static int |
copyStream(OutputStream out,
InputStream in)
copyStream is not really a Java Utility method, but it's needed by
one of them, and so is here.
|
static int |
copyStream(Writer out,
Reader in)
copyStream is not really a Java Utility method, but it's needed by
one of them, and so is here.
|
static String |
escapeCharForInstance(char c,
char illegalChar)
A helper method for instanceFrom.
|
static List |
exceptionsFromParsingText(String type)
What exceptions might we encounter from doing the result of
genParseText.
|
static List |
exceptionsFromParsingText(String type,
boolean fromParsing) |
static String |
exprToInt(String type,
String expr)
Given a scalar type, figure out how to make it into an int
(ie, hash code).
|
static String |
fromObject(String type,
String expr) |
static String |
fromObjectType(String classType)
Take a Java boxed object (like Integer) and return it's primitive type.
|
static String |
genEquals(String type,
String attr1,
String attr2) |
static String |
genEquals(String type,
String attr1,
String attr2,
boolean attr1CanBeNull) |
static String |
genNewDefault(String type) |
static String |
genParseText(String type,
String expr,
boolean java5)
Take a particular @param type (eg: "java.lang.Integer") and return a
String that will parse the @param expr and make it into that type.
|
static String |
genParseText(String type,
String expr,
boolean j2me,
boolean java5) |
static String |
genParseText(String type,
String expr,
String var,
boolean java5)
Take a particular @param type (eg: "java.lang.Integer") and return a
String that will parse the @param expr, making it into that type,
and storing the value into @param var.
|
static String |
genParseText(String type,
String expr,
String var,
boolean j2me,
boolean java5) |
static String |
genParseTextME(String type,
String name)
Take a particular @param type (eg: "java.lang.Integer") and return a
String that will parse the @param expr and make it into that type.
|
static String |
getCanonicalClassName(Class cls) |
static int |
getOptimialHashMapSize(Object[] keys) |
static int |
getOptimialHashMapSize(Object[] keys,
int maxSize)
Using reflection figure out the optimal initial capacity for a
HashMap given some keys.
|
static Class |
getPrimitive(String className) |
static String |
instanceFrom(String type,
String value)
Take a String (@param value) and generate Java code to coerce it.
|
static boolean |
isCloneable(String className)
Looks for the class and sees if it's cloneable.
|
static boolean |
isImmutable(String className)
Is @param className immutable? An immutable object can hold state,
but after it's been constructed that state cannot change.
|
static boolean |
isInstantiable(String className)
Is the class not an interface and not abstract; i.e., it's possible
to call a constructor on this class.
|
static boolean |
isPrimitiveType(String className) |
static void |
native2ascii(Writer out,
Reader in) |
static String |
nullValueForType(String type) |
static boolean |
reservedWord(String name) |
static String |
toObject(String expr,
String classType,
boolean j2me,
boolean java5) |
static String |
toObjectType(String classType)
Take a Java primitive and return it's object type.
|
static String |
typeToString(String type,
String expr)
Convert expr into a String.
|
static String |
uencode(char c)
Take a character and return the \ u (Unicode) representation of it.
|
public static final int BUFFER_SIZE
public static String toObjectType(String classType)
public static String fromObjectType(String classType)
public static String typeToString(String type, String expr)
expr - the value to convert into a Stringtype - is the name of the current type
('String', 'value') -> 'value'
('int', '42') -> '""+42'
('Integer', 'age') -> 'age.toString()'public static String fromObject(String type, String expr)
expr - is an Object type, and we will convert it
to a primitive.
eg: ('java.lang.Double', expr) -> '(java.lang.Double) expr'
eg: ('int', 'obj') -> '((java.lang.Integer)obj).intValue()'public static boolean isImmutable(String className)
public static String instanceFrom(String type, String value)
public static String escapeCharForInstance(char c, char illegalChar)
public static String compareTo(String value1, String type1, String value2)
public static String compareToText(String value1, String type1, String value2Text)
public static String genParseText(String type, String expr, boolean j2me, boolean java5)
public static String genParseText(String type, String expr, boolean java5)
public static String genParseTextME(String type, String name)
public static String genParseText(String type, String expr, String var, boolean java5)
public static String genParseText(String type, String expr, String var, boolean j2me, boolean java5)
public static List exceptionsFromParsingText(String type)
public static List exceptionsFromParsingText(String type, boolean fromParsing)
public static boolean isPrimitiveType(String className)
public static boolean canProduceNoXMLMetaChars(String className)
public static String genNewDefault(String type)
type - is the name of a classpublic static String exprToInt(String type, String expr)
public static String genEquals(String type, String attr1, String attr2)
public static String genEquals(String type, String attr1, String attr2, boolean attr1CanBeNull)
attr1CanBeNull - whether or not attr1 could be null.public static boolean isCloneable(String className)
public static boolean isInstantiable(String className)
public static boolean checkValueToType(String type, String value)
public static String baseName(String fullClassName)
public static int getOptimialHashMapSize(Object[] keys)
public static int getOptimialHashMapSize(Object[] keys, int maxSize)
maxSize - the point at which to give up (the maximum size to try)public static void native2ascii(Writer out, Reader in) throws IOException
IOExceptionpublic static String uencode(char c)
public static int copyStream(Writer out, Reader in) throws IOException
IOExceptionpublic static int copyStream(OutputStream out, InputStream in) throws IOException
IOExceptionpublic static boolean reservedWord(String name)
Copyright © 2017. All Rights Reserved.