Methods Summary |
---|
public synchronized void | addElement(javax.bluetooth.DataElement elem)
/*
* We can't optimize this by invoking the
* this.insertElementAt(elem, getSize()), because
* the ClassCastException may be thrown from getSize()
* which gives us improper stack trace.
*/
if (valueType != DATSEQ && valueType != DATALT) {
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
if (elem == null) {
throw new NullPointerException("Specified element is null");
}
((Vector) miscValue).addElement(elem);
|
public boolean | getBoolean()
if (valueType != BOOL) {
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
return booleanValue;
|
public int | getDataType()
return valueType;
|
public long | getLong()
switch (valueType) {
case U_INT_1: /* falls through */
case U_INT_2: /* falls through */
case U_INT_4: /* falls through */
case INT_1: /* falls through */
case INT_2: /* falls through */
case INT_4: /* falls through */
case INT_8:
break;
default:
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
return longValue;
|
public synchronized int | getSize()
if (valueType != DATSEQ && valueType != DATALT) {
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
return ((Vector) miscValue).size();
|
public synchronized java.lang.Object | getValue()
Object retValue = miscValue;
/*
* According to cldc & bluetooth specifications, the String and UUID
* are immutable, so we may not return a clone object to safe
* the stored one.
*
* The Vector.elements() returns an Enumeration, which does not allow
* to break the Vector either.
*
* The array may be modified by reference, so we have to return
* a clone.
*/
switch (valueType) {
case URL: /* falls through */
case STRING: /* falls through */
case UUID:
break;
case DATALT: /* falls through */
case DATSEQ:
retValue = ((Vector) miscValue).elements();
break;
case U_INT_8: /* falls through */
case U_INT_16: /* falls through */
case INT_16:
int length = ((byte[]) miscValue).length;
retValue = new byte[length];
System.arraycopy(miscValue, 0, retValue, 0, length);
break;
default:
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
return retValue;
|
public synchronized void | insertElementAt(javax.bluetooth.DataElement elem, int index)
if (valueType != DATSEQ && valueType != DATALT) {
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
if (elem == null) {
throw new NullPointerException("Specified element is null");
}
/*
* We can't use the Vector.insertElementAt check for out of
* bounds, because Vector throws ArrayIndexOutOfBoundsException
* in this case.
*/
if (index < 0 || index > ((Vector) miscValue).size()) {
throw new IndexOutOfBoundsException(
"Specified index is out of range");
}
((Vector) miscValue).insertElementAt(elem, index);
|
public boolean | removeElement(javax.bluetooth.DataElement elem)
if (valueType != DATSEQ && valueType != DATALT) {
throw new ClassCastException(
"Invalid element type for this method: " + valueType);
}
if (elem == null) {
throw new NullPointerException("Specified element is null");
}
/*
* The Bluetooth spec says the two DataElement equals if their
* references are equal. According to cldc1.1 ref impl sources,
* the Vector uses 'equals' call, and the Object.equls uses
* a references compare, so we may not care about doing this here.
*/
return ((Vector) miscValue).removeElement(elem);
|