Methods Summary |
---|
public final java.lang.Integer | getInt()Returns the data as an int.
if (getType(mData) == EventValueType.INT) {
return (Integer)mData;
}
throw new InvalidTypeException();
|
public final java.lang.Long | getLong()Returns the data as a long.
if (getType(mData) == EventValueType.LONG) {
return (Long)mData;
}
throw new InvalidTypeException();
|
public final java.lang.String | getString()Returns the data as a String.
if (getType(mData) == EventValueType.STRING) {
return (String)mData;
}
throw new InvalidTypeException();
|
public final com.android.ddmlib.log.EventContainer$EventValueType | getType(java.lang.Object data)Returns the type of an object.
if (data instanceof Integer) {
return EventValueType.INT;
} else if (data instanceof Long) {
return EventValueType.LONG;
} else if (data instanceof String) {
return EventValueType.STRING;
} else if (data instanceof Object[]) {
// loop through the list to see if we have another list
Object[] objects = (Object[])data;
for (Object obj : objects) {
EventValueType type = getType(obj);
if (type == EventValueType.LIST || type == EventValueType.TREE) {
return EventValueType.TREE;
}
}
return EventValueType.LIST;
}
return EventValueType.UNKNOWN;
|
public com.android.ddmlib.log.EventContainer$EventValueType | getType()Returns the type of the data.
return getType(mData);
|
private final java.lang.Object | getValue(java.lang.Object data, int valueIndex, boolean recursive)
EventValueType type = getType(data);
switch (type) {
case INT:
case LONG:
case STRING:
return data;
case LIST:
if (recursive) {
Object[] list = (Object[]) data;
if (valueIndex >= 0 && valueIndex < list.length) {
return getValue(list[valueIndex], valueIndex, false);
}
}
}
return null;
|
public java.lang.Object | getValue(int valueIndex)Returns a value by index. The return type is defined by its type.
return getValue(mData, valueIndex, true);
|
private final double | getValueAsDouble(java.lang.Object data, int valueIndex, boolean recursive)
EventValueType type = getType(data);
switch (type) {
case INT:
return ((Integer)data).doubleValue();
case LONG:
return ((Long)data).doubleValue();
case STRING:
throw new InvalidTypeException();
case LIST:
if (recursive) {
Object[] list = (Object[]) data;
if (valueIndex >= 0 && valueIndex < list.length) {
return getValueAsDouble(list[valueIndex], valueIndex, false);
}
}
}
throw new InvalidTypeException();
|
public double | getValueAsDouble(int valueIndex)Returns a value by index as a double.
return getValueAsDouble(mData, valueIndex, true);
|
private final java.lang.String | getValueAsString(java.lang.Object data, int valueIndex, boolean recursive)
EventValueType type = getType(data);
switch (type) {
case INT:
return ((Integer)data).toString();
case LONG:
return ((Long)data).toString();
case STRING:
return (String)data;
case LIST:
if (recursive) {
Object[] list = (Object[]) data;
if (valueIndex >= 0 && valueIndex < list.length) {
return getValueAsString(list[valueIndex], valueIndex, false);
}
} else {
throw new InvalidTypeException(
"getValueAsString() doesn't support EventValueType.TREE");
}
}
throw new InvalidTypeException(
"getValueAsString() unsupported type:" + type);
|
public java.lang.String | getValueAsString(int valueIndex)Returns a value by index as a String.
return getValueAsString(mData, valueIndex, true);
|
public boolean | testValue(int index, java.lang.Object value, com.android.ddmlib.log.EventContainer$CompareMethod compareMethod)Checks that the index -th value of this event against a provided value.
EventValueType type = getType(mData);
if (index > 0 && type != EventValueType.LIST) {
throw new InvalidTypeException();
}
Object data = mData;
if (type == EventValueType.LIST) {
data = ((Object[])mData)[index];
}
if (data.getClass().equals(data.getClass()) == false) {
throw new InvalidTypeException();
}
switch (compareMethod) {
case EQUAL_TO:
return data.equals(value);
case LESSER_THAN:
if (data instanceof Integer) {
return (((Integer)data).compareTo((Integer)value) <= 0);
} else if (data instanceof Long) {
return (((Long)data).compareTo((Long)value) <= 0);
}
// other types can't use this compare method.
throw new InvalidTypeException();
case LESSER_THAN_STRICT:
if (data instanceof Integer) {
return (((Integer)data).compareTo((Integer)value) < 0);
} else if (data instanceof Long) {
return (((Long)data).compareTo((Long)value) < 0);
}
// other types can't use this compare method.
throw new InvalidTypeException();
case GREATER_THAN:
if (data instanceof Integer) {
return (((Integer)data).compareTo((Integer)value) >= 0);
} else if (data instanceof Long) {
return (((Long)data).compareTo((Long)value) >= 0);
}
// other types can't use this compare method.
throw new InvalidTypeException();
case GREATER_THAN_STRICT:
if (data instanceof Integer) {
return (((Integer)data).compareTo((Integer)value) > 0);
} else if (data instanceof Long) {
return (((Long)data).compareTo((Long)value) > 0);
}
// other types can't use this compare method.
throw new InvalidTypeException();
case BIT_CHECK:
if (data instanceof Integer) {
return (((Integer)data).intValue() & ((Integer)value).intValue()) != 0;
} else if (data instanceof Long) {
return (((Long)data).longValue() & ((Long)value).longValue()) != 0;
}
// other types can't use this compare method.
throw new InvalidTypeException();
default :
throw new InvalidTypeException();
}
|