Package org.apache.axis.utils
Class JavaUtils
java.lang.Object
org.apache.axis.utils.JavaUtils
Utility class to deal with Java language related issues, such
as type conversions.
- Author:
- Glen Daniels (gdaniels@apache.org)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceIt 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 class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectUtility function to convert an Object to some desired Class.static ObjectgetHolderValue(Object holder) Gets the Holder value.static ClassgetHolderValueType(Class type) Determines if the Class is a Holder class.static Imagestatic StringgetLoadableClassName(String text) Converts text of the form Foo[] to the proper class name for loading [LFoostatic ClassgetPrimitiveClass(Class wrapper) static ClassgetPrimitiveClassFromName(String primitive) static StringgetTextClassName(String text) Converts text of the form [LFoo to the Foo[]static StringgetUniqueValue(Collection values, String initValue) Makes the value passed ininitValueunique among theStringvalues contained invaluesby suffixing it with a decimal digit suffix.static StringgetWrapper(String primitive) static ClassgetWrapperClass(Class primitive) static booleanDetermine whether attachments are supported by checking if the following classes are available: javax.activation.DataHandler, javax.mail.internet.MimeMultipart.static booleanstatic booleanisConvertable(Object obj, Class dest) static booleanisConvertable(Object obj, Class dest, boolean isEncoded) static booleanisEnumClass(Class cls) Determine if the class is a JAX-RPC enum class.static final booleanstatic final booleanTests the Object 'value': if its null, return default.static final booleanTests 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 final booleanisFalseExplicitly(Object value) static final booleanisFalseExplicitly(Object value, boolean defaultVal) Tests the Object 'value': if its null, return default.static final booleanisFalseExplicitly(String value) Tests the String 'value': return 'true' if its null, 'false', '0', or 'no' - else 'false'static booleanisJavaId Returns true if the name is a valid java identifier.static booleanisJavaKeyword(String keyword) checks if the input string is a valid java keyword.static final booleanstatic final booleanTests the Object 'value': if its null, return default.static final booleanTests 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 final booleanisTrueExplicitly(Object value) static final booleanisTrueExplicitly(Object value, boolean defaultVal) Tests the Object 'value': if its null, return default.static final booleanisTrueExplicitly(String value) Tests the String 'value': return 'true' if its 'true', '1', or 'yes' - else 'false'static StringmakeNonJavaKeyword(String keyword) Turn a java keyword string into a non-Java keyword string.static StringmimeToJava(String mime) Given the MIME type string, return the Java mapping.static final Stringreplace: Like String.replace except that the old new items are strings.static voidsetHolderValue(Object holder, Object value) Sets the Holder value.static Stringstatic StringxmlNameToJava(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 Details
-
log
protected static org.apache.commons.logging.Log log -
NL
public static final char NL- See Also:
-
CR
public static final char CR- See Also:
-
LS
The prefered line separator
-
-
Method Details
-
getWrapperClass
-
getWrapper
-
getPrimitiveClass
-
getPrimitiveClassFromName
-
isBasic
-
convert
Utility function to convert an Object to some desired Class. Right now this works for: arrays invalid input: '<'-> Lists, Holders invalid input: '<'-> held values- Parameters:
arg- the array to convertdestClass- the actual class we want
-
isConvertable
-
isConvertable
-
getImageFromStream
-
isJavaId
isJavaId Returns true if the name is a valid java identifier.- Parameters:
id- to check- Returns:
- boolean true/false
-
isJavaKeyword
checks if the input string is a valid java keyword.- Returns:
- boolean true/false
-
makeNonJavaKeyword
Turn a java keyword string into a non-Java keyword string. (Right now this simply means appending an underscore.) -
getLoadableClassName
Converts text of the form Foo[] to the proper class name for loading [LFoo -
getTextClassName
Converts text of the form [LFoo to the Foo[] -
xmlNameToJava
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
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
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
Gets the Holder value.- Parameters:
holder- Holder object- Returns:
- value object
- Throws:
JavaUtils.HolderException
-
setHolderValue
Sets the Holder value.- Parameters:
holder- Holder objectvalue- is the object value- Throws:
JavaUtils.HolderException
-
isEnumClass
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
-
isTrue
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
Tests the String 'value': return 'true' if its 'true', '1', or 'yes' - else 'false' -
isTrueExplicitly
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
-
isTrue
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
-
isFalse
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
Tests the String 'value': return 'true' if its null, 'false', '0', or 'no' - else 'false' -
isFalseExplicitly
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
-
isFalse
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
-
mimeToJava
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
Makes the value passed ininitValueunique among theStringvalues contained invaluesby suffixing it with a decimal digit suffix.
-