|
Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.2.1) Part Number E55141-01 P4 Change 1723563 on 2015/10/09 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JAnnotationValue
Represents a member value of a JAnnotation.
A note regarding enums
The presence of metadata of 'enum' types poses a bit of a challenge in the untyped view of metadata that is presented by JAnnotationValue. Because JAM cannot assume that the enum definitions have been compiled, it is not possible for JAM to return an instance of an enumuerated type. In other words, it is not possible for JAnnotationValue to provide an asEnum() method.
If JAM encounters an annotation value of an enumerated type, it will represent it with a JAnnotationValue such that calling myAnnotationValue.getType().isEnumType()
will return true. Moreover, calling myAnnotationValue.asString()
will return the name of the enumeration field, exactly as it appears in the type declaration.
Method Summary | |
---|---|
abstract JAnnotation |
asAnnotation() If this member is complex (i.e. |
abstract JAnnotation[] |
asAnnotationArray() If this member is known to be an array of annotations (i.e. |
abstract boolean |
asBoolean() Returns the member's value as a boolean. |
abstract boolean[] |
asBooleanArray() Returns this member's value as an array of booleans. |
abstract byte |
asByte() Returns the member's value as a byte. |
abstract byte[] |
asByteArray() Returns this member's value as an array of bytes. |
abstract char |
asChar() Returns the member's value as a char. |
abstract char[] |
asCharArray() Returns this member's value as an array of bytes. |
abstract JClass |
asClass() Returns the value of this member as a JClass. |
abstract JClass[] |
asClassArray() If this member is known to be an array of classes, returns an array of JClass representations of those classes. |
abstract double |
asDouble() Returns the member's value as a double. |
abstract double[] |
asDoubleArray() Returns this member's value as an array of doubles. |
abstract float |
asFloat() Returns the member's value as a float. |
abstract float[] |
asFloatArray() Returns this member's value as an array of floats. |
abstract int |
asInt() Returns the member's value as an int. |
abstract int[] |
asIntArray() Returns this member's value as an array of ints. |
abstract long |
asLong() Returns the member's value as a long. |
abstract long[] |
asLongArray() Returns this member's value as an array of longs. |
abstract short |
asShort() Returns the member's value as a short. |
abstract short[] |
asShortArray() Returns this member's value as an array of shorts. |
abstract String |
asString() Returns the String value of the annotation. |
abstract String[] |
asStringArray() Returns this member's value as an array of Strings. |
abstract String |
getName() |
abstract JClass |
getType() |
abstract Object |
getValue() Deprecated. DO NOT CALL THIS METHOD. IT WILL BE REMOVED SOON. This method is a bad thing because it forces/allows the caller to make assumptions about how the annotation value is actually represented in the underlying implementation. Please use a combination of getType() and the various as...() methods instead. |
abstract boolean |
isDefaultValueUsed() Returns true if the member's value was not explicitly set in the annotation instance but was instead taken from the member definition's default. |
Method Detail |
---|
String getName()
JClass getType()
JAnnotation asAnnotation()
If this member is complex (i.e. an instance of another annotation type), this method returns a representation of the annotation instance. Returns null in all other samples. This method always returns null if the annotation is a javdoc tag, as such tags only support one level of nesting.
JClass asClass()
Returns the value of this member as a JClass. Returns null if the value cannot be understood as a class name or if the type of the member is known to be something other than java.lang.Class.
String asString()
Returns the String value of the annotation. If the value is known to be a simple, non-array type other than String, it will be converted in a resonable manner (with an appropriate toString() or String.valueOf() method). If the value is known to be complex or is an array, this method will return null.
If no type information is available for the annotation member (i.e. it's a javadoc tag), then the raw textual value of the member is returned.
int asInt() throws NumberFormatException
Returns the member's value as an int. If the value is not known to be an int, (because it's a javadoc tag or because it's a 175 annotation member of a type other than int) asString() is called. If the result is null, NumberFormatException is thrown. Otherwise, the String is converted to an int with Integer.valueOf(), which again may throw NumberFormatException.
NumberFormatException
boolean asBoolean() throws IllegalArgumentException
Returns the member's value as a boolean. If necessary, type conversion is performed in a similar manner as described for asInt(), except that IllegalArgumentException is thrown instead of NumberFormatException.
IllegalArgumentException
long asLong() throws NumberFormatException
Returns the member's value as a long. If necessary, type conversion is performed in a similar manner as described for asInt().
NumberFormatException
short asShort() throws NumberFormatException
Returns the member's value as a short. If necessary, type conversion is performed in a similar manner as described for asInt().
NumberFormatException
double asDouble() throws NumberFormatException
Returns the member's value as a double. If necessary, type conversion is performed in a similar manner as described for asInt().
NumberFormatException
float asFloat() throws NumberFormatException
Returns the member's value as a float. If necessary, type conversion is performed in a similar manner as described for asInt().
NumberFormatException
byte asByte() throws NumberFormatException
Returns the member's value as a byte. If necessary, type conversion is performed in a similar manner as described for asInt().
NumberFormatException
char asChar() throws IllegalArgumentException
Returns the member's value as a char. If necessary, type conversion is performed by calling getStringValue(). If the result is null or is a String that is not exactly of length 1, IllegalArgumentException is thrown.
IllegalArgumentException
JClass[] asClassArray()
If this member is known to be an array of classes, returns an array of JClass representations of those classes. If the memeber is known to be an array of a simple non-array type, this method will call asStringArray() and attempt to return a JClass by treating each string in the returned array as a qualified classname. Returns null otherwise.
This method always returns null for javadoc tags.
JAnnotation[] asAnnotationArray()
If this member is known to be an array of annotations (i.e. complex, nested types), this method returns an array containing each complex value as a JAnnotation. Returns null in all other samples.
This method always returns null for javadoc tags.
String[] asStringArray()
Returns this member's value as an array of Strings. If this member is not of an array type, or is an array of arrays or complex annotations, this method returns null. If it is an array of a simple, non-array type other than String, conversion on each component will be attempted as described under getStringValue().
This method always returns null for javadoc tags.
int[] asIntArray() throws NumberFormatException
Returns this member's value as an array of ints. If this member is not of an array type, or is an array of arrays or complex annotations, this method returns null. If it is an array of a simple, non-array type other than int, conversion on each component will be attempted as described under getIntValue().
This method always returns null for javadoc tags.
NumberFormatException
boolean[] asBooleanArray() throws IllegalArgumentException
Returns this member's value as an array of booleans. If necessary, type conversion is performed in a similar manner as described for asIntArray(), except that IllegalArgumentException may be thrown instead of NumberFormatException.
This method always returns null for javadoc tags.
IllegalArgumentException
short[] asShortArray() throws NumberFormatException
Returns this member's value as an array of shorts. If necessary, type conversion is performed in a similar manner as described for asIntArray().
This method always returns null for javadoc tags.
NumberFormatException
long[] asLongArray() throws NumberFormatException
Returns this member's value as an array of longs. If necessary, type conversion is performed in a similar manner as described for asIntArray().
This method always returns null for javadoc tags.
NumberFormatException
double[] asDoubleArray() throws NumberFormatException
Returns this member's value as an array of doubles. If necessary, type conversion is performed in a similar manner as described for asIntArray().
This method always returns null for javadoc tags.
NumberFormatException
float[] asFloatArray() throws NumberFormatException
Returns this member's value as an array of floats. If necessary, type conversion is performed in a similar manner as described for asIntArray().
This method always returns null for javadoc tags.
NumberFormatException
byte[] asByteArray() throws NumberFormatException
Returns this member's value as an array of bytes. If necessary, type conversion is performed in a similar manner as described for asIntArray().
This method always returns null for javadoc tags.
NumberFormatException
char[] asCharArray() throws IllegalArgumentException
Returns this member's value as an array of bytes. If necessary, type conversion is performed in a similar manner as described for asIntArray() and asChar()..
This method always returns null for javadoc tags.
IllegalArgumentException
boolean isDefaultValueUsed()
Returns true if the member's value was not explicitly set in the annotation instance but was instead taken from the member definition's default.
Note that not all JAM implementations may be able to distinguish the case where the value is explicitly declared to be the same value as the member's default from the case where the value is not declared and the value is implicitly default. In this event, this method will return true if and only if the effective value of the annotation is the same as the default value (regardless of how that value was declared).
Object getValue()
|
Copyright 1996, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Oracle Fusion Middleware Java API Reference for Oracle WebLogic Server 12c (12.2.1) Part Number E55141-01 P4 Change 1723563 on 2015/10/09 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |