Methods Summary |
---|
public void | createAuthenticationChallenge(java.lang.String realm, boolean userID, boolean access)
ObexAuth auth = ObexAuth.createChallenge(realm, userID, access);
challenges.addElement(auth);
|
public java.lang.Object | getHeader(int headerID)
Object value = headers.get(new Integer(headerID));
if (value != null) {
return value;
}
// check validness of headerID
int type = internalType(headerID);
if (type >= TYPE_UNSUPPORTED) {
throw new IllegalArgumentException("bad header id");
}
return null;
|
public int[] | getHeaderList()
synchronized (headers) {
if (headers.isEmpty()) {
return null;
}
Enumeration keys = headers.keys();
int[] ids = new int[headers.size()];
int i = 0;
while (keys.hasMoreElements()) {
Object obj = keys.nextElement();
ids[i++] = ((Integer)obj).intValue();
}
return ids;
}
|
public int | getResponseCode()
if (owner != OWNER_CLIENT) {
throw new IOException("invalid use");
}
if (packetType == ObexPacketStream.OPCODE_CONTINUE) {
throw new IOException("operation not finished");
}
return packetType;
|
static final int | internalType(int headerID)
if ((headerID & ~0xFF) != 0) {
return TYPE_UNSUPPORTED;
}
if ((headerID & 0x30) == 0x30) {
// user defined
return headerID >> 6;
}
switch (headerID) {
case HeaderSet.TIME_ISO_8601:
return TYPE_SPECIAL_TIME_ISO;
case HeaderSet.TIME_4_BYTE:
return TYPE_SPECIAL_TIME_4;
case HeaderSet.TYPE:
return TYPE_SPECIAL_TYPE;
case HeaderSet.COUNT:
case HeaderSet.LENGTH:
return TYPE_LONG;
case HeaderSet.NAME:
case HeaderSet.DESCRIPTION:
return TYPE_UNICODE;
case HeaderSet.TARGET:
case HeaderSet.HTTP:
case HeaderSet.WHO:
case HeaderSet.OBJECT_CLASS:
case HeaderSet.APPLICATION_PARAMETER:
return TYPE_BYTEARRAY;
case ObexPacketStream.HEADER_AUTH_CHALLENGE:
return TYPE_AUTH_CHALLENGE;
case ObexPacketStream.HEADER_AUTH_RESPONSE:
return TYPE_AUTH_RESPONSE;
default:
return TYPE_UNSUPPORTED;
}
|
boolean | isSendable()
return owner >= OWNER_SERVER_USER;
|
void | merge(com.sun.kvem.jsr082.obex.HeaderSetImpl h)Adds headers from h to this HeaderSet.
int[] idList = h.getHeaderList();
if (idList == null) {
return;
}
for (int i = 0; i < idList.length; i++) {
int id = idList[i];
Object val = h.getHeader(id);
int type = internalType(id);
switch (type) {
case TYPE_UNICODE:
case TYPE_BYTE:
case TYPE_LONG:
case TYPE_SPECIAL_TYPE:
setHeader(id, val);
break;
case TYPE_BYTEARRAY:
byte[] array = (byte[]) val;
byte[] copy = new byte[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
setHeader(id, (Object) copy);
break;
case TYPE_SPECIAL_TIME_4:
case TYPE_SPECIAL_TIME_ISO:
Calendar cal = (Calendar) val;
Calendar calCopy = Calendar.getInstance();
calCopy.setTime(cal.getTime());
setHeader(id, (Object) calCopy);
break;
default:
// no default
if (DEBUG) {
System.out.println("Debug: unknown header id");
}
}
}
|
public void | setHeader(int headerID, java.lang.Object headerValue)
int type = internalType(headerID);
String errormsg = "incompatible header object";
if (type >= TYPE_UNSUPPORTED) {
throw new IllegalArgumentException("bad header id");
}
if (headerValue == null) {
synchronized (headers) {
headers.remove(new Integer(headerID));
}
return;
}
boolean fail = false;
switch (type) {
case TYPE_UNICODE:
if (!(headerValue instanceof String)) fail = true;
break;
case TYPE_BYTEARRAY:
if (!(headerValue instanceof byte[])) fail = true;
break;
case TYPE_BYTE:
if (!(headerValue instanceof Byte)) fail = true;
break;
case TYPE_LONG:
if (!(headerValue instanceof Long)) {
fail = true;
break;
}
long value = ((Long)headerValue).longValue();
if (value < 0L || value > 0xFFFFFFFFL) {
errormsg = "long value out of range 0 .. 0xFFFFFFFF";
fail = true;
}
break;
case TYPE_SPECIAL_TIME_4:
if (!(headerValue instanceof Calendar)) fail = true;
break;
case TYPE_SPECIAL_TIME_ISO:
if (!(headerValue instanceof Calendar)) fail = true;
break;
case TYPE_SPECIAL_TYPE:
if (!(headerValue instanceof String)) fail = true;
break;
// no default
}
if (fail) {
throw new IllegalArgumentException(errormsg);
}
synchronized (headers) {
headers.put(new Integer(headerID), headerValue);
}
|