| java.lang.Object org.netbeans.modules.schema2beansdev.gen.JavaUtil
JavaUtil | public class JavaUtil (Code) | | Various utility methods dealing with Java
|
Inner Class :public static class N2AFilter extends FilterWriter | |
Inner Class :public static class InputMonitor implements Runnable | |
Method Summary | |
public static String | baseClassOfArray(String className) | public static String | baseName(String fullClassName) This will return a name from @param fullClassName where everything upto
and including the last '.' is removed. | public static boolean | canProduceNoXMLMetaChars(String className) | public static boolean | checkValueToType(String type, String value) checkValueToType will make sure that a given value is
acceptable for a given type. | public static String | compareTo(String value1, String type1, String value2) Convert @param value2 (a literal) to @param type1 and then
compare that to @param value1. | public static String | compareToText(String value1, String type1, String value2Text) Just like compareTo, but the second value (@param value2Text) is
unquoted text. | public 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. | public 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. | public static String | escapeCharForInstance(char c, char illegalChar) A helper method for instanceFrom. | public static List | exceptionsFromParsingText(String type) What exceptions might we encounter from doing the result of
genParseText. | public static List | exceptionsFromParsingText(String type, boolean fromParsing) | public static String | exprToInt(String type, String expr) Given a scalar type, figure out how to make it into an int
(ie, hash code). | public static String | fromObject(String type, String expr) | public static String | fromObjectType(String classType) Take a Java boxed object (like Integer) and return it's primitive type. | public static String | genEquals(String type, String attr1, String attr2) | public static String | genEquals(String type, String attr1, String attr2, boolean attr1CanBeNull) | public static String | genNewDefault(String type) | public static String | genParseText(String type, String expr, boolean j2me) | public static String | genParseText(String type, String expr) 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. | public static String | genParseText(String type, String expr, String var) 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. | public static String | genParseText(String type, String expr, String var, boolean j2me) | public 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. | public static String | getCanonicalClassName(Class cls) | public static int | getOptimialHashMapSize(Object[] keys) | public static int | getOptimialHashMapSize(Object[] keys, int maxSize) Using reflection figure out the optimal initial capacity for a
HashMap given some keys. | public static Class | getPrimitive(String className) | public static String | instanceFrom(String type, String value) Take a String (@param value) and generate Java code to coerce it. | public static boolean | isCloneable(String className) Looks for the class and sees if it's cloneable. | public 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. | public 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. | public static boolean | isPrimitiveType(String className) | public static void | native2ascii(Writer out, Reader in) | public static String | nullValueForType(String type) | public static boolean | reservedWord(String name) | public static String | toObject(String expr, String classType) Convert primitives into Objects and leave objects as is. | public static String | toObject(String expr, String classType, boolean j2me) | public static String | toObjectType(String classType) Take a Java primitive and return it's object type. | public static String | typeToString(String type, String expr) Convert expr into a String. | public static String | uencode(char c) Take a character and return the \ u (Unicode) representation of it. |
BUFFER_SIZE | final public static int BUFFER_SIZE(Code) | | |
baseName | public static String baseName(String fullClassName)(Code) | | This will return a name from @param fullClassName where everything upto
and including the last '.' is removed.
eg: "java.lang.String[]" -> "String[]"
"java.util.ArrayList" -> "ArrayList"
|
canProduceNoXMLMetaChars | public static boolean canProduceNoXMLMetaChars(String className)(Code) | | |
checkValueToType | public static boolean checkValueToType(String type, String value)(Code) | | checkValueToType will make sure that a given value is
acceptable for a given type. To make the problem more
tractable, this is limited to simple types.
eg:
("java.lang.Integer", "1") -> true
("java.lang.Integer", "1.5") -> false
("java.lang.String", "ksadjflkjas24#@") -> true
("short", "12345") -> true
("short", "123456") -> false
Note that the 'tostr' template in javaGenLibrary.xsl has very
similar code and any changes should be made there too.
|
compareTo | public static String compareTo(String value1, String type1, String value2)(Code) | | Convert @param value2 (a literal) to @param type1 and then
compare that to @param value1.
Java code in a String, that returns negative, 0, or positiveif value1 < value2, value1 == value2, or value1 > value2.("foo", "java.math.BigDecimal", "1") -> 'foo.compareTo(new java.math.BigDecimal("1"))' |
compareToText | public static String compareToText(String value1, String type1, String value2Text)(Code) | | Just like compareTo, but the second value (@param value2Text) is
unquoted text.
|
copyStream | public static int copyStream(Writer out, Reader in) throws java.io.IOException(Code) | | copyStream is not really a Java Utility method, but it's needed by
one of them, and so is here.
the total length of the stream (in char's) copied. |
copyStream | public static int copyStream(OutputStream out, InputStream in) throws java.io.IOException(Code) | | copyStream is not really a Java Utility method, but it's needed by
one of them, and so is here.
the total length of the stream (in char's) copied. |
escapeCharForInstance | public static String escapeCharForInstance(char c, char illegalChar)(Code) | | A helper method for instanceFrom. We escape 1 char at a time here.
|
exceptionsFromParsingText | public static List exceptionsFromParsingText(String type)(Code) | | What exceptions might we encounter from doing the result of
genParseText. These exceptions are ones that we'd have to declare.
|
exceptionsFromParsingText | public static List exceptionsFromParsingText(String type, boolean fromParsing)(Code) | | |
exprToInt | public static String exprToInt(String type, String expr)(Code) | | Given a scalar type, figure out how to make it into an int
(ie, hash code).
|
fromObject | public static String fromObject(String type, String expr)(Code) | | Parameters: expr - is an Object type, and we will convert itto a primitive.eg: ('java.lang.Double', expr) -> '(java.lang.Double) expr'eg: ('int', 'obj') -> '((java.lang.Integer)obj).intValue()' |
fromObjectType | public static String fromObjectType(String classType)(Code) | | Take a Java boxed object (like Integer) and return it's primitive type.
Return the same type if there isn't a primitive version.
|
genEquals | public static String genEquals(String type, String attr1, String attr2)(Code) | | an expression to compare to expressions; this can be put rightinto an if statement.('int', 'var1', 'var2') -> 'var1 == var2'('String', 'word', '"hello"') -> 'word == null ? "hello" == null : word.equals("hello")'('float', 'var1', 'var2') -> 'Float.floatToIntBits(var1) == Float.floatToIntBits(var2)' |
genEquals | public static String genEquals(String type, String attr1, String attr2, boolean attr1CanBeNull)(Code) | | Parameters: attr1CanBeNull - whether or not attr1 could be null. |
genNewDefault | public static String genNewDefault(String type)(Code) | | Parameters: type - is the name of a class a default value for that type.eg: X -> new X()java.math.BigDecimal -> new java.math.BigDecimal("0")Integer -> new Integer("0") |
genParseText | public static String genParseText(String type, String expr)(Code) | | 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.
The value of @param expr should be a String.
eg: ('java.lang.Integer', 'node.getNodeValue()')
-> 'new java.lang.Integer(node.getNodeValue())'
|
genParseText | public static String genParseText(String type, String expr, String var)(Code) | | 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.
The value of @param expr should be a String.
|
genParseTextME | public static String genParseTextME(String type, String name)(Code) | | 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.
The value of @param expr should be a String.
These work in *MIDP/J2ME*.
eg: ('java.lang.Integer', 'node.getNodeValue()')
-> 'new java.lang.Integer(node.getNodeValue())'
|
getOptimialHashMapSize | public static int getOptimialHashMapSize(Object[] keys)(Code) | | |
getOptimialHashMapSize | public static int getOptimialHashMapSize(Object[] keys, int maxSize)(Code) | | Using reflection figure out the optimal initial capacity for a
HashMap given some keys. This uses a load factor of 1.0f.
By optimal, the table does not need resizing and there are
no lists (or chaining) being done in a HashMap.Entry.
Parameters: maxSize - the point at which to give up (the maximum size to try) |
instanceFrom | public static String instanceFrom(String type, String value)(Code) | | Take a String (@param value) and generate Java code to coerce it.
eg: ('String', "Hello") -> '"Hello"'
('int', '10') -> '10'
('Integer', '43') -> 'new Integer(43)'
('java.util.Locale', 'Locale.US') -> 'Locale.US'
|
isCloneable | public static boolean isCloneable(String className)(Code) | | Looks for the class and sees if it's cloneable.
|
isImmutable | public static boolean isImmutable(String className)(Code) | | Is @param className immutable? An immutable object can hold state,
but after it's been constructed that state cannot change.
|
isInstantiable | public static boolean isInstantiable(String className)(Code) | | Is the class not an interface and not abstract; i.e., it's possible
to call a constructor on this class. (Note that primitives fail.)
|
isPrimitiveType | public static boolean isPrimitiveType(String className)(Code) | | |
reservedWord | public static boolean reservedWord(String name)(Code) | | |
toObject | public static String toObject(String expr, String classType)(Code) | | Convert primitives into Objects and leave objects as is.
Parameters: expr - the text expression representing some value Parameters: classType - the current type of @param expr('age', 'int') -> 'new java.lang.Integer(age)'('age', 'Integer') -> 'age' |
toObjectType | public static String toObjectType(String classType)(Code) | | Take a Java primitive and return it's object type.
Return the same type if there isn't an object version.
|
typeToString | public static String typeToString(String type, String expr)(Code) | | Convert expr into a String. Similar to toObject.
Parameters: expr - the value to convert into a String Parameters: type - is the name of the current type('String', 'value') -> 'value'('int', '42') -> '""+42'('Integer', 'age') -> 'age.toString()' |
uencode | public static String uencode(char c)(Code) | | Take a character and return the \ u (Unicode) representation of it.
|
|
|