The following example shows how the ValueDescriptor class can
be used to list field information of all types.
void printTypes() { Map<String, List<ValueDescriptor>> typeMap = new LinkedHashMap<>(); for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) { findTypes(typeMap, eventType.getName(), eventType.getFields()); } for (String type : typeMap.keySet()) { System.out.println("Type: " + type); for (ValueDescriptor field : typeMap.get(type)) { System.out.println(" Field: " + field.getName()); String arrayBrackets = field.isArray() ? "[]" : ""; System.out.println(" Type: " + field.getTypeName() + arrayBrackets); if (field.getLabel() != null) { System.out.println(" Label: " + field.getLabel()); } if (field.getDescription() != null) { System.out.println(" Description: " + field.getDescription()); } if (field.getContentType() != null) { System.out.println(" Content Types: " + field.getContentType()); } } System.out.println(); } } void findTypes(Map<String, List<ValueDescriptor>> typeMap, String typeName, List<ValueDescriptor> fields) { if (!typeMap.containsKey(typeName)) { typeMap.put(typeName, fields); for (ValueDescriptor subField : fields) { findTypes(typeMap, subField.getTypeName(), subField.getFields()); } } }
| Modifier and Type | Field and Description |
|---|---|
| private final AnnotationConstruct | |
| private final boolean | |
| private String | |
| private final boolean | |
| private final String | |
| private String | |
| private final String | |
| private final Type | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| pack-priv | ValueDescriptor(Type type, String name, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName)
|
| public | ValueDescriptor(Class<?>
the type, not type, String nullthe name, not name)nullConstructs a value descriptor, useful for dynamically creating event types and annotations. |
| public | ValueDescriptor(Class<?>
the type, not type, String nullthe name, not name, List<AnnotationElement> nullthe annotations on the value descriptors, not
annotations)nullConstructs a value descriptor, useful for dynamically creating event types and annotations. |
| pack-priv | ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray)
|
| Modifier and Type | Method and Description |
|---|---|
| public < the type of the annotation to query for and return if present A extends Annotation> A | Returns: this element's annotation for the specified annotation type if directly present, elsenullthe Class object that corresponds to the annotation
type, not annotationType)nullReturns the first annotation for the specified type if an annotation
element with the same name is directly present for this value descriptor,
|
| public List | Returns: a list of annotations, notnullReturns an immutable list of annotation elements for this value descriptor. |
| public String | Returns: the content type, ornull if doesn't existReturns a textual identifier that specifies how a value represented by
this |
| public String | Returns: the description, ornull if doesn't existReturns a sentence describing the value (for example, |
| public List | Returns: a list of value descriptors, notnullReturns an immutable list of value descriptors if the type is complex, else an empty list. |
| pack-priv String | |
| public String | Returns: a human-readable name, ornull if doesn't existReturns a human-readable name that describes the value (for example,
|
| public String | |
| pack-priv Type | |
| public long | Returns: the type ID, not negativeReturns a unique ID for the type in the Java virtual Machine (JVM). |
| public String | Returns: the type name, notnullReturns the fully qualified class name of the type that is associated with this value descriptor. |
| public boolean | Returns: true if it is an array type, false otherwiseReturns if this value descriptor is an array type. |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv void |
| annotationConstruct | back to summary |
|---|---|
| private final AnnotationConstruct annotationConstruct | |
| constantPool | back to summary |
|---|---|
| private final boolean constantPool | |
| contentType | back to summary |
|---|---|
| private String contentType | |
| isArray | back to summary |
|---|---|
| private final boolean isArray | |
| javaFieldName | back to summary |
|---|---|
| private final String javaFieldName | |
| label | back to summary |
|---|---|
| private String label | |
| name | back to summary |
|---|---|
| private final String name | |
| type | back to summary |
|---|---|
| private final Type type | |
| UNKNOWN | back to summary |
|---|---|
| private static final String UNKNOWN | |
| ValueDescriptor | back to summary |
|---|---|
| pack-priv ValueDescriptor(Type type, String name, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName) | |
| ValueDescriptor | back to summary |
|---|---|
| public ValueDescriptor(Class<?> type, String name) Constructs a value descriptor, useful for dynamically creating event types and annotations. The following types are supported:
The name must be a valid Java identifier (for example,
| |
| ValueDescriptor | back to summary |
|---|---|
| public ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations) Constructs a value descriptor, useful for dynamically creating event types and annotations. The following types are supported:
The name must be a valid Java identifier (for example,
| |
| ValueDescriptor | back to summary |
|---|---|
| pack-priv ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray) | |
| getAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getAnnotation(Class<A> annotationType) Returns the first annotation for the specified type if an annotation
element with the same name is directly present for this value descriptor,
| |
| getAnnotationElements | back to summary |
|---|---|
| public List Returns an immutable list of annotation elements for this value descriptor.
| |
| getContentType | back to summary |
|---|---|
| public String getContentType() Returns a textual identifier that specifies how a value represented by
this
For example, if the value descriptor's type is The JDK provides the following predefined content types:
User-defined content types can be created by using the
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Returns a sentence describing the value (for example,
| |
| getFields | back to summary |
|---|---|
| public List Returns an immutable list of value descriptors if the type is complex, else an empty list.
| |
| getJavaFieldName | back to summary |
|---|---|
| pack-priv String getJavaFieldName() | |
| getLabel | back to summary |
|---|---|
| public String getLabel() Returns a human-readable name that describes the value (for example,
| |
| getName | back to summary |
|---|---|
| public String getName() Returns the name of the value (for example,
| |
| getType | back to summary |
|---|---|
| pack-priv Type getType() | |
| getTypeId | back to summary |
|---|---|
| public long getTypeId() Returns a unique ID for the type in the Java virtual Machine (JVM). The ID might not be the same between JVM instances.
| |
| getTypeName | back to summary |
|---|---|
| public String getTypeName() Returns the fully qualified class name of the type that is associated with this value descriptor.
| |
| isArray | back to summary |
|---|---|
| public boolean isArray() Returns if this value descriptor is an array type.
| |
| isConstantPool | back to summary |
|---|---|
| pack-priv boolean isConstantPool() | |
| isUnsigned | back to summary |
|---|---|
| pack-priv boolean isUnsigned() | |
| setAnnotations | back to summary |
|---|---|
| pack-priv void setAnnotations(List<AnnotationElement> anno) | |