Package org.apache.axis.utils
Class JavaUtils
- java.lang.Object
-
- org.apache.axis.utils.JavaUtils
-
public class JavaUtils extends java.lang.ObjectUtility class to deal with Java language related issues, such as type conversions.- Author:
- Glen Daniels (gdaniels@apache.org)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJavaUtils.ConvertCacheIt the argument to the convert(...) method implements the ConvertCache interface, the convert(...) method will use the set/get methods to store and retrieve converted values.static classJavaUtils.HolderException
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Objectconvert(java.lang.Object arg, java.lang.Class destClass)Utility function to convert an Object to some desired Class.static java.lang.ObjectgetHolderValue(java.lang.Object holder)Gets the Holder value.static java.lang.ClassgetHolderValueType(java.lang.Class type)Determines if the Class is a Holder class.static java.awt.ImagegetImageFromStream(java.io.InputStream is)static java.lang.StringgetLoadableClassName(java.lang.String text)Converts text of the form Foo[] to the proper class name for loading [LFoostatic java.lang.ClassgetPrimitiveClass(java.lang.Class wrapper)static java.lang.ClassgetPrimitiveClassFromName(java.lang.String primitive)static java.lang.StringgetTextClassName(java.lang.String text)Converts text of the form [LFoo to the Foo[]static java.lang.StringgetUniqueValue(java.util.Collection values, java.lang.String initValue)Makes the value passed ininitValueunique among theStringvalues contained invaluesby suffixing it with a decimal digit suffix.static java.lang.StringgetWrapper(java.lang.String primitive)static java.lang.ClassgetWrapperClass(java.lang.Class primitive)static booleanisAttachmentSupported()Determine whether attachments are supported by checking if the following classes are available: javax.activation.DataHandler, javax.mail.internet.MimeMultipart.static booleanisBasic(java.lang.Class javaType)static booleanisConvertable(java.lang.Object obj, java.lang.Class dest)static booleanisConvertable(java.lang.Object obj, java.lang.Class dest, boolean isEncoded)static booleanisEnumClass(java.lang.Class cls)Determine if the class is a JAX-RPC enum class.static booleanisFalse(java.lang.Object value)static booleanisFalse(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default.static booleanisFalse(java.lang.String value)Tests the String 'value': return 'true' if its 'false', '0', or 'no' - else 'false' Follow in 'C' tradition of boolean values: false is specific (0), everything else is true;static booleanisFalseExplicitly(java.lang.Object value)static booleanisFalseExplicitly(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default.static booleanisFalseExplicitly(java.lang.String value)Tests the String 'value': return 'true' if its null, 'false', '0', or 'no' - else 'false'static booleanisJavaId(java.lang.String id)isJavaId Returns true if the name is a valid java identifier.static booleanisJavaKeyword(java.lang.String keyword)checks if the input string is a valid java keyword.static booleanisTrue(java.lang.Object value)static booleanisTrue(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default.static booleanisTrue(java.lang.String value)Tests the String 'value': return 'false' if its 'false', '0', or 'no' - else 'true' Follow in 'C' tradition of boolean values: false is specific (0), everything else is true;static booleanisTrueExplicitly(java.lang.Object value)static booleanisTrueExplicitly(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default.static booleanisTrueExplicitly(java.lang.String value)Tests the String 'value': return 'true' if its 'true', '1', or 'yes' - else 'false'static java.lang.StringmakeNonJavaKeyword(java.lang.String keyword)Turn a java keyword string into a non-Java keyword string.static java.lang.StringmimeToJava(java.lang.String mime)Given the MIME type string, return the Java mapping.static java.lang.Stringreplace(java.lang.String name, java.lang.String oldT, java.lang.String newT)replace: Like String.replace except that the old new items are strings.static voidsetHolderValue(java.lang.Object holder, java.lang.Object value)Sets the Holder value.static java.lang.StringstackToString(java.lang.Throwable e)static java.lang.StringxmlNameToJava(java.lang.String name)Map an XML name to a Java identifier per the mapping rules of JSR 101 (in version 1.0 this is "Chapter 20: Appendix: Mapping of XML Names"
-
-
-
Field Detail
-
log
protected static org.apache.commons.logging.Log log
-
NL
public static final char NL
- See Also:
- Constant Field Values
-
CR
public static final char CR
- See Also:
- Constant Field Values
-
LS
public static final java.lang.String LS
The prefered line separator
-
-
Method Detail
-
getWrapperClass
public static java.lang.Class getWrapperClass(java.lang.Class primitive)
-
getWrapper
public static java.lang.String getWrapper(java.lang.String primitive)
-
getPrimitiveClass
public static java.lang.Class getPrimitiveClass(java.lang.Class wrapper)
-
getPrimitiveClassFromName
public static java.lang.Class getPrimitiveClassFromName(java.lang.String primitive)
-
isBasic
public static boolean isBasic(java.lang.Class javaType)
-
convert
public static java.lang.Object convert(java.lang.Object arg, java.lang.Class destClass)Utility function to convert an Object to some desired Class. Right now this works for: arrays <-> Lists, Holders <-> held values- Parameters:
arg- the array to convertdestClass- the actual class we want
-
isConvertable
public static boolean isConvertable(java.lang.Object obj, java.lang.Class dest)
-
isConvertable
public static boolean isConvertable(java.lang.Object obj, java.lang.Class dest, boolean isEncoded)
-
getImageFromStream
public static java.awt.Image getImageFromStream(java.io.InputStream is)
-
isJavaId
public static boolean isJavaId(java.lang.String id)
isJavaId Returns true if the name is a valid java identifier.- Parameters:
id- to check- Returns:
- boolean true/false
-
isJavaKeyword
public static boolean isJavaKeyword(java.lang.String keyword)
checks if the input string is a valid java keyword.- Returns:
- boolean true/false
-
makeNonJavaKeyword
public static java.lang.String makeNonJavaKeyword(java.lang.String keyword)
Turn a java keyword string into a non-Java keyword string. (Right now this simply means appending an underscore.)
-
getLoadableClassName
public static java.lang.String getLoadableClassName(java.lang.String text)
Converts text of the form Foo[] to the proper class name for loading [LFoo
-
getTextClassName
public static java.lang.String getTextClassName(java.lang.String text)
Converts text of the form [LFoo to the Foo[]
-
xmlNameToJava
public static java.lang.String xmlNameToJava(java.lang.String name)
Map an XML name to a Java identifier per the mapping rules of JSR 101 (in version 1.0 this is "Chapter 20: Appendix: Mapping of XML Names"- Parameters:
name- is the xml name- Returns:
- the java name per JSR 101 specification
-
replace
public static final java.lang.String replace(java.lang.String name, java.lang.String oldT, java.lang.String newT)replace: Like String.replace except that the old new items are strings.- Parameters:
name- stringoldT- old text to replacenewT- new text to use- Returns:
- replacement string
-
getHolderValueType
public static java.lang.Class getHolderValueType(java.lang.Class type)
Determines if the Class is a Holder class. If so returns Class of held type else returns null- Parameters:
type- the suspected Holder Class- Returns:
- class of held type or null
-
getHolderValue
public static java.lang.Object getHolderValue(java.lang.Object holder) throws JavaUtils.HolderExceptionGets the Holder value.- Parameters:
holder- Holder object- Returns:
- value object
- Throws:
JavaUtils.HolderException
-
setHolderValue
public static void setHolderValue(java.lang.Object holder, java.lang.Object value) throws JavaUtils.HolderExceptionSets the Holder value.- Parameters:
holder- Holder objectvalue- is the object value- Throws:
JavaUtils.HolderException
-
isEnumClass
public static boolean isEnumClass(java.lang.Class cls)
Determine if the class is a JAX-RPC enum class. An enumeration class is recognized by a getValue() method, a toString() method, a fromString(String) method a fromValue(type) method and the lack of a setValue(type) method
-
stackToString
public static java.lang.String stackToString(java.lang.Throwable e)
-
isTrue
public static final boolean isTrue(java.lang.String value)
Tests the String 'value': return 'false' if its 'false', '0', or 'no' - else 'true' Follow in 'C' tradition of boolean values: false is specific (0), everything else is true;
-
isTrueExplicitly
public static final boolean isTrueExplicitly(java.lang.String value)
Tests the String 'value': return 'true' if its 'true', '1', or 'yes' - else 'false'
-
isTrueExplicitly
public static final boolean isTrueExplicitly(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default. if its a Boolean, return booleanValue() if its an Integer, return 'false' if its '0' else 'true' if its a String, return isTrueExplicitly((String)value). All other types return 'true'
-
isTrueExplicitly
public static final boolean isTrueExplicitly(java.lang.Object value)
-
isTrue
public static final boolean isTrue(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default. if its a Boolean, return booleanValue() if its an Integer, return 'false' if its '0' else 'true' if its a String, return 'false' if its 'false', 'no', or '0' - else 'true' All other types return 'true'
-
isTrue
public static final boolean isTrue(java.lang.Object value)
-
isFalse
public static final boolean isFalse(java.lang.String value)
Tests the String 'value': return 'true' if its 'false', '0', or 'no' - else 'false' Follow in 'C' tradition of boolean values: false is specific (0), everything else is true;
-
isFalseExplicitly
public static final boolean isFalseExplicitly(java.lang.String value)
Tests the String 'value': return 'true' if its null, 'false', '0', or 'no' - else 'false'
-
isFalseExplicitly
public static final boolean isFalseExplicitly(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default. if its a Boolean, return !booleanValue() if its an Integer, return 'true' if its '0' else 'false' if its a String, return isFalseExplicitly((String)value). All other types return 'false'
-
isFalseExplicitly
public static final boolean isFalseExplicitly(java.lang.Object value)
-
isFalse
public static final boolean isFalse(java.lang.Object value, boolean defaultVal)Tests the Object 'value': if its null, return default. if its a Boolean, return booleanValue() if its an Integer, return 'false' if its '0' else 'true' if its a String, return 'false' if its 'false', 'no', or '0' - else 'true' All other types return 'true'
-
isFalse
public static final boolean isFalse(java.lang.Object value)
-
mimeToJava
public static java.lang.String mimeToJava(java.lang.String mime)
Given the MIME type string, return the Java mapping.
-
isAttachmentSupported
public static boolean isAttachmentSupported()
Determine whether attachments are supported by checking if the following classes are available: javax.activation.DataHandler, javax.mail.internet.MimeMultipart.
-
getUniqueValue
public static java.lang.String getUniqueValue(java.util.Collection values, java.lang.String initValue)Makes the value passed ininitValueunique among theStringvalues contained invaluesby suffixing it with a decimal digit suffix.
-
-