de.avetana.bluetooth.sdp
Class LocalServiceRecord

java.lang.Object
  extended byde.avetana.bluetooth.sdp.SDPServiceRecord
      extended byde.avetana.bluetooth.sdp.LocalServiceRecord
All Implemented Interfaces:
ServiceRecord

public class LocalServiceRecord
extends SDPServiceRecord

The class used to manage local service records.

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:
This class is used to manage the local service records. As requested by the JSR82 Specification, the class is an instance of javax.bluetooth.ServiceRecord. However, some methods like getRemoteDevice() throw a RuntimeExcepion because there is logically no RemoteDevice for a local Service Record. The most used method is certainly the static method createSerialSvcRecord, which creates with few parameters a complete local Service record.
Other methods like getSDPRecordXML() were implemented in order to fullfill OS specific needs.


Field Summary
 
Fields inherited from class de.avetana.bluetooth.sdp.SDPServiceRecord
m_attributes, m_recordHandle
 
Fields inherited from interface javax.bluetooth.ServiceRecord
AUTHENTICATE_ENCRYPT, AUTHENTICATE_NOENCRYPT, NOAUTHENTICATE_NOENCRYPT
 
Constructor Summary
LocalServiceRecord()
          Default constructor: creates a new LocalServiceRecord object
LocalServiceRecord(long recordHandle)
          Creates a new LocalServiceRecord and sets its record handle
 
Method Summary
static LocalServiceRecord createSerialSvcRecord(UUID svcID, java.lang.String name, int channel, short protocol)
          Creates a new local Service Record with desired options
 DataElement getChannelNumberElement()
          Gets the channel/PSM number of the local service record
 java.lang.String getConnectionURL(int requiredSecurity, boolean mustBeMaster)
          Method not available for a local service record.
 RemoteDevice getHostDevice()
          Method not available for a local service record.
 short getProtocol()
          Returns the protocol supported by this local service record.
 java.lang.String getSDPRecordXML()
          Transforms the service record object into an XML element and returns the string representation of this XML element.
 UUID getServiceClassID()
          Returns the ServiceClassID of this service
 UUID[] getServiceClassIDList()
           
 boolean populateRecord(int[] attrIDs)
          Method not available for a local service record.
 void setDeviceServiceClasses(int classes)
          Method not yet supported.
 void updateChannelNumber(int newChannel)
          Changes the channel number of an RFCOMM local service record
 
Methods inherited from class de.avetana.bluetooth.sdp.SDPServiceRecord
getAttributeIDs, getAttributeValue, getRecordHandle, setAttributeValue, setRecordHandle, toByteArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalServiceRecord

public LocalServiceRecord()
Default constructor: creates a new LocalServiceRecord object


LocalServiceRecord

public LocalServiceRecord(long recordHandle)
Creates a new LocalServiceRecord and sets its record handle

Parameters:
recordHandle - The record handle of the service record
Method Detail

getProtocol

public short getProtocol()
Returns the protocol supported by this local service record. In the case of a service record supporting more than one protocol (for example L2CAP and RFCOMM), the protocol code identifying the highest level protocol is returned (with the previous example, this would be JSR82URL.PROTOCOL_RFCOMM).

Returns:
The protocol code.

createSerialSvcRecord

public static LocalServiceRecord createSerialSvcRecord(UUID svcID,
                                                       java.lang.String name,
                                                       int channel,
                                                       short protocol)
Creates a new local Service Record with desired options

Parameters:
svcID - The UUID of the local service record
name - The name of the local service record
channel - The Channel/PSM value
protocol - The protocol code identifying the highest level protocol
Returns:
The new local service record defined.

getSDPRecordXML

public java.lang.String getSDPRecordXML()
Transforms the service record object into an XML element and returns the string representation of this XML element. Useful for the Mac implementation

Returns:
The XML-based string representation of the service record

updateChannelNumber

public void updateChannelNumber(int newChannel)
Changes the channel number of an RFCOMM local service record

Parameters:
newChannel - The new Channel number

getChannelNumberElement

public DataElement getChannelNumberElement()
Gets the channel/PSM number of the local service record

Returns:
The channel/PSM number of the local service record

getHostDevice

public RemoteDevice getHostDevice()
Method not available for a local service record.
This method always returns null. (This returned value is the one requested by the JSR82 specification version 1.0)

Specified by:
getHostDevice in interface ServiceRecord
Specified by:
getHostDevice in class SDPServiceRecord
Returns:
null

populateRecord

public boolean populateRecord(int[] attrIDs)
                       throws java.io.IOException
Method not available for a local service record. Throws a new exception.

Parameters:
attrIDs - the list of service attributes IDs whose value are to be retrieved; the number of attributes cannot exceed the property bluetooth.sd.attr.retrievable.max; the attributes in the request must be legal, i.e. their values are in the range of [0, 216-1]. The input attribute IDs can include attribute IDs from the default attribute set too.
Returns:
nothing - Throws an Exception
Throws:
java.io.IOException - if the local device is unable to connect to the remote Bluetooth device that was the source of this ServiceRecord; if this ServiceRecord was deleted from the SDDB of the remote device

getConnectionURL

public java.lang.String getConnectionURL(int requiredSecurity,
                                         boolean mustBeMaster)
Method not available for a local service record. Throws a new exception.

Parameters:
requiredSecurity - determines whether authentication or encryption are required for a connection
mustBeMaster - true indicates that this device must play the role of master in connections to this service; false indicates that the local device is willing to be either the master or the slave
Returns:
nothing - Throws an Exception
See Also:
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_ENCRYPT

setDeviceServiceClasses

public void setDeviceServiceClasses(int classes)
Method not yet supported. Throws a new exception.

Parameters:
classes - an integer whose binary representation indicates the major service class bits that should be activated
Returns:
nothing - Throws an Exception

getServiceClassID

public UUID getServiceClassID()
Returns the ServiceClassID of this service

Returns:
serviceClassID UUID

getServiceClassIDList

public UUID[] getServiceClassIDList()