FileDocCategorySizeDatePackage
EventValueDescription.javaAPI DocAndroid 1.5 API6781Wed May 06 22:41:08 BST 2009com.android.ddmlib.log

EventValueDescription

public 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.

param
name
param
type

        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}.

param
name
param
type
param
valueType
throws
InvalidValueTypeException if type and valuetype are not compatible.

        mName = name;
        mEventValueType = type;
        mValueType = valueType;
        mValueType.checkType(mEventValueType);
    
Methods Summary
public booleancheckForType(java.lang.Object value)
Checks if the value is of the proper type for this receiver.

param
value the value to check.
return
true 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.EventValueTypegetEventValueType()

return
the {@link EventValueType}.

        return mEventValueType;
    
public java.lang.StringgetName()

return
the Name.

        return mName;
    
public java.lang.ObjectgetObjectFromString(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.

param
value the value of the object expressed as a string.
return
an object or null if the conversion could not be done.

        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$ValueTypegetValueType()

return
the {@link ValueType}.

        return mValueType;
    
public java.lang.StringtoString()

        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());