de.avetana.bluetooth.sdp
Class SDPServiceRecord

java.lang.Object
  extended byde.avetana.bluetooth.sdp.SDPServiceRecord
All Implemented Interfaces:
ServiceRecord
Direct Known Subclasses:
LocalServiceRecord, RemoteServiceRecord

public abstract class SDPServiceRecord
extends java.lang.Object
implements ServiceRecord

The top-class implementing methods common with all instances of Service Record.

COPYRIGHT:
(c) Copyright 2004 Avetana GmbH ALL RIGHTS RESERVED.

This file is part of the Avetana bluetooth API for Linux.

The Avetana bluetooth API for Linux is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

The Avetana bluetooth API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The development of the Avetana bluetooth API is based on the work of Christian Lorenz (see the Javabluetooth Stack at http://www.javabluetooth.org) for some classes, on the work of the jbluez team (see http://jbluez.sourceforge.net/) and on the work of the bluez team (see the BlueZ linux Stack at http://www.bluez.org) for the C code. Classes, part of classes, C functions or part of C functions programmed by these teams and/or persons are explicitly mentioned.



Description:
The Avetana Bluetooth implementation provides two classes, which aim to manage the service record, and separates therefore local from remote service record.
This separation is made in order to better implement the JSR82 specification. But common methods of these two classes exist. The SDPServiceRecord class aims to implement these common methods.


Field Summary
protected  java.util.Hashtable m_attributes
          The Hashtable containing the service attributes and their related DataElement
protected  long m_recordHandle
          The handle of this service record
 
Fields inherited from interface javax.bluetooth.ServiceRecord
AUTHENTICATE_ENCRYPT, AUTHENTICATE_NOENCRYPT, NOAUTHENTICATE_NOENCRYPT
 
Constructor Summary
SDPServiceRecord()
          Creates a new SDP service record.
SDPServiceRecord(long recordHandle)
          Creates a new SDP service record, initializes the different class variables and sets the record handle.
 
Method Summary
 int[] getAttributeIDs()
          Returns the service attribute IDs whose value could be retrieved by a call to getAttributeValue().
 DataElement getAttributeValue(int attrID)
          Returns the DataElement corresponding to the given attribute
abstract  RemoteDevice getHostDevice()
          Returns the remote Bluetooth device that populated the service record with attribute values.
 long getRecordHandle()
          Returns the record handle.
 boolean setAttributeValue(int attrID, DataElement attrDesc)
          Modifies this ServiceRecord to contain the service attribute defined by the attribute-value pair (attrID, attrValue).
 void setRecordHandle(long recordHandle)
          Sets the record handle
 byte[] toByteArray()
          The byte representation of this record.
 java.lang.String toString()
          Returns the String representation of a service record, which lists all attributes and their corresponding DataElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.bluetooth.ServiceRecord
getConnectionURL, populateRecord, setDeviceServiceClasses
 

Field Detail

m_attributes

protected java.util.Hashtable m_attributes
The Hashtable containing the service attributes and their related DataElement


m_recordHandle

protected long m_recordHandle
The handle of this service record

Constructor Detail

SDPServiceRecord

public SDPServiceRecord()
Creates a new SDP service record.
Initializes the different class variables except the record handle.


SDPServiceRecord

public SDPServiceRecord(long recordHandle)
Creates a new SDP service record, initializes the different class variables and sets the record handle.

Parameters:
recordHandle -
Method Detail

setRecordHandle

public void setRecordHandle(long recordHandle)
Sets the record handle

Parameters:
recordHandle - The value of the record handle

getRecordHandle

public long getRecordHandle()
Returns the record handle.

Returns:
The record handle.

getAttributeValue

public DataElement getAttributeValue(int attrID)
Returns the DataElement corresponding to the given attribute

Specified by:
getAttributeValue in interface ServiceRecord
Parameters:
attrID - The value of the attribute
Returns:
  • The DataElement corresponding to the given attribute if it exists
  • null - Otherwise

getHostDevice

public abstract RemoteDevice getHostDevice()
Description copied from interface: ServiceRecord
Returns the remote Bluetooth device that populated the service record with attribute values. It is important to note that the Bluetooth device that provided the value might not be reachable anymore, since it can move, turn off, or change its security mode denying all further transactions.

Specified by:
getHostDevice in interface ServiceRecord
Returns:
the remote Bluetooth device that populated the service record, or null if the local device populated this ServiceRecord

getAttributeIDs

public int[] getAttributeIDs()
Description copied from interface: ServiceRecord
Returns the service attribute IDs whose value could be retrieved by a call to getAttributeValue(). The list of attributes being returned is not sorted and includes default attributes.

Specified by:
getAttributeIDs in interface ServiceRecord
Returns:
an array of service attribute IDs that are in this object and have values for them; if there are no attribute IDs that have values, this method will return an array of length zero.
See Also:
ServiceRecord.getAttributeValue(int)

setAttributeValue

public boolean setAttributeValue(int attrID,
                                 DataElement attrDesc)
Description copied from interface: ServiceRecord
Modifies this ServiceRecord to contain the service attribute defined by the attribute-value pair (attrID, attrValue). If the attrID does not exist in the ServiceRecord, this attribute-value pair is added to this ServiceRecord object. If the attrID is already in this ServiceRecord, the value of the attribute is changed to attrValue. If attrValue is null, the attribute with the attribute ID of attrID is removed from this ServiceRecord object. If attrValue is null and attrID does not exist in this object, this method will return false.

This method makes no modifications to a service record in the SDDB. In order for any changes made by this method to be reflected in the SDDB, a call must be made to the acceptAndOpen() method of the associated notifier to add this ServiceRecord to the SDDB for the first time, or a call must be made to the updateRecord() method of LocalDevice to modify the version of this ServiceRecord that is already in the SDDB.

This method prevents the ServiceRecordHandle from being modified by throwing an IllegalArgumentException.

Specified by:
setAttributeValue in interface ServiceRecord
Parameters:
attrID -
attrDesc -
Returns:

toString

public java.lang.String toString()
Returns the String representation of a service record, which lists all attributes and their corresponding DataElement

Returns:
The String representation of a service record.

toByteArray

public byte[] toByteArray()
The byte representation of this record.

Returns:
The byte representation of this record.