EventValueDescriptionpublic final class EventValueDescription extends Object Describes an {@link EventContainer} value.
This is a stand-alone object, not linked to a particular Event. It describes the value, by
name, type ({@link EventValueType}), and (if needed) value unit ({@link ValueType}).
The index of the value is not contained within this class, and is instead dependent on the
index of this particular object in the array of {@link EventValueDescription} returned by
{@link EventLogParser#getEventInfoMap()} when queried for a particular event tag. |
Fields Summary |
---|
private String | mName | private com.android.ddmlib.log.EventContainer.EventValueType | mEventValueType | private ValueType | mValueType |
Constructors Summary |
---|
EventValueDescription(String name, com.android.ddmlib.log.EventContainer.EventValueType type)Builds a {@link EventValueDescription} with a name and a type.
If the type is {@link EventValueType#INT} or {@link EventValueType#LONG}, the
{@link #mValueType} is set to {@link ValueType#BYTES} by default. It set to
{@link ValueType#NOT_APPLICABLE} for all other {@link EventValueType} values.
mName = name;
mEventValueType = type;
if (mEventValueType == EventValueType.INT || mEventValueType == EventValueType.LONG) {
mValueType = ValueType.BYTES;
} else {
mValueType = ValueType.NOT_APPLICABLE;
}
| EventValueDescription(String name, com.android.ddmlib.log.EventContainer.EventValueType type, ValueType valueType)Builds a {@link EventValueDescription} with a name and a type, and a {@link ValueType}.
mName = name;
mEventValueType = type;
mValueType = valueType;
mValueType.checkType(mEventValueType);
|
Methods Summary |
---|
public boolean | checkForType(java.lang.Object value)Checks if the value is of the proper type for this receiver.
switch (mEventValueType) {
case INT:
return value instanceof Integer;
case LONG:
return value instanceof Long;
case STRING:
return value instanceof String;
case LIST:
return value instanceof Object[];
}
return false;
| public com.android.ddmlib.log.EventContainer.EventValueType | getEventValueType()
return mEventValueType;
| public java.lang.String | getName()
return mName;
| public java.lang.Object | getObjectFromString(java.lang.String value)Returns an object of a valid type (based on the value returned by
{@link #getEventValueType()}) from a String value.
IMPORTANT {@link EventValueType#LIST} and {@link EventValueType#TREE} are not
supported.
switch (mEventValueType) {
case INT:
try {
return Integer.valueOf(value);
} catch (NumberFormatException e) {
return null;
}
case LONG:
try {
return Long.valueOf(value);
} catch (NumberFormatException e) {
return null;
}
case STRING:
return value;
}
return null;
| public com.android.ddmlib.log.EventValueDescription$ValueType | getValueType()
return mValueType;
| public java.lang.String | toString()
if (mValueType != ValueType.NOT_APPLICABLE) {
return String.format("%1$s (%2$s, %3$s)", mName, mEventValueType.toString(),
mValueType.toString());
}
return String.format("%1$s (%2$s)", mName, mEventValueType.toString());
|
|