de.avetana.bluetooth.connection
Class JSR82URL

java.lang.Object
  extended byde.avetana.bluetooth.connection.JSR82URL

public class JSR82URL
extends java.lang.Object

The class used to manage connection URLs.

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 store the different connection URLs. It parses the URL represented as string, verifies their correctness, identifies the protocols and stores all connection attributes in easy-to.use objects.
This utility class is therefore used among most of the classes of the Avetana JSR82 implementation


Field Summary
static short PROTOCOL_L2CAP
          The variable that identifies the L2CAP protocol.
static short PROTOCOL_OBEX
          The variable that identifies the OBEX protocol.
static short PROTOCOL_RFCOMM
          The variable that identifies the RFCOMM protocol.
 
Constructor Summary
JSR82URL(java.lang.String url)
          Creates a new instance of JSR82URL, initializes the different class variables and parses the string given in argument
 
Method Summary
 int getAttrNumber()
          Returns the value of the PSM or of the channel number.
 BTAddress getBTAddress()
          Returns the BT device address or null in the case of a server connection URL.
 java.lang.String getLocalServiceUUID()
          Returns the string representation of the local service UUID or null in the case of a client connection URL.
 java.lang.Object getParameter(java.lang.String paramName)
          Returns the value of the option named paramName.
 java.lang.String[] getParameterKeys()
          Returns the array of connection options.
 java.util.Hashtable getParameters()
          Returns the hashtable containing all connection options.
 short getProtocol()
          Returns the integer code of protocol used by this connection URL.
 boolean isAuthenticated()
          Returns the value of the option Authenticate.
 boolean isAuthorized()
          Returns the value of the option authorize.
 boolean isEncrypted()
          Returns the value of the option encrypt.
 boolean isLocalMaster()
          Returns the value of the option master.
 void setAttrNumber(int num)
          Sets the PSM or the channel number (depending on the protocol used).
 void setParameter(java.lang.String name, java.lang.Object value)
          Sets the value of a connection option.
 void setProtocol(short protocol)
          Sets the protocol.
 java.lang.String toString()
          Returns the string representation of the connection url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL_L2CAP

public static final short PROTOCOL_L2CAP
The variable that identifies the L2CAP protocol. (Note: the UUID of the protocol was not used their because the numbers 0x100, 0x3, 0x8 are not a clear sequence that can be used for indexing arrays).

See Also:
Constant Field Values

PROTOCOL_RFCOMM

public static final short PROTOCOL_RFCOMM
The variable that identifies the RFCOMM protocol. (Note: the UUID of the protocol was not used their because the numbers 0x100, 0x3, 0x8 are not a clear sequence that can be used for indexing arrays).

See Also:
Constant Field Values

PROTOCOL_OBEX

public static final short PROTOCOL_OBEX
The variable that identifies the OBEX protocol. (Note: the UUID of the protocol was not used their because the numbers 0x100, 0x3, 0x8 are not a clear sequence that can be used for indexing arrays).

See Also:
Constant Field Values
Constructor Detail

JSR82URL

public JSR82URL(java.lang.String url)
         throws BadURLFormat,
                java.lang.Exception
Creates a new instance of JSR82URL, initializes the different class variables and parses the string given in argument

Parameters:
url - A string representation of a connection URL.
Throws:
BadURLFormat - If the connection URL is not valid.
java.lang.Exception - If some other exception occurs.
Method Detail

isAuthenticated

public boolean isAuthenticated()
Returns the value of the option Authenticate.

Returns:
true - If the connection option authenticate is set to true.
false - Otherwise.

isEncrypted

public boolean isEncrypted()
Returns the value of the option encrypt.

Returns:
true - If the connection option authenticate is set to true.
false - Otherwise.

isAuthorized

public boolean isAuthorized()
Returns the value of the option authorize.

Returns:
true - If the connection option authorize is set to true.
false - Otherwise.

isLocalMaster

public boolean isLocalMaster()
Returns the value of the option master.

Returns:
true - If the connection option master is set to true.
false - Otherwise

setAttrNumber

public void setAttrNumber(int num)
Sets the PSM or the channel number (depending on the protocol used). This "number" is meant to be as universal as possible and does therefore not identify any protocol-specific variable.

Parameters:
num - The new PSM or channel number.

toString

public java.lang.String toString()
Returns the string representation of the connection url.

Returns:
The string representation of the connection url.

getParameterKeys

public java.lang.String[] getParameterKeys()
Returns the array of connection options.

Returns:
The array representation of all connection options.

getParameters

public java.util.Hashtable getParameters()
Returns the hashtable containing all connection options. The usual options are
Option NameObject typeProtocolServer/Client connections?
name String All Server
receiveMTU String L2CAP Both
transmitMTU String L2CAP Both
authenticate Boolean All Both
master Boolean All Both
encryptBooleanAllBoth
authorizeBooleanAllBoth
Other optionsBoolean??
Note: the options receiveMTU and transmitMTU, which are only available with the L2CAP protocol, have a default value set to null. Please keep in mind that the default values given in the above table are the values FOR the methods of this class. The L2CAP connection classes are using a default value for receiveMTU set to 672, for example.

Returns:
The hashtable containin all connection options.

getParameter

public java.lang.Object getParameter(java.lang.String paramName)
Returns the value of the option named paramName.

Parameters:
paramName - The option's name.
Returns:
the value of this option or null if the option is not set.

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object value)
Sets the value of a connection option.

Parameters:
name - The name of the option
value - The value of this option.

setProtocol

public void setProtocol(short protocol)
Sets the protocol.

Parameters:
protocol - The protocol code of the new protocol.

getBTAddress

public BTAddress getBTAddress()
Returns the BT device address or null in the case of a server connection URL.

Returns:
  • The BT device address if it exists
  • null - Otherwise

getLocalServiceUUID

public java.lang.String getLocalServiceUUID()
Returns the string representation of the local service UUID or null in the case of a client connection URL.

Returns:
  • The string representation of the local service UUID if it exists
  • null - Otherwise

getAttrNumber

public int getAttrNumber()
Returns the value of the PSM or of the channel number.

Returns:
The value of the PSM or of the channel number.

getProtocol

public short getProtocol()
Returns the integer code of protocol used by this connection URL.

Returns:
The integer code of protocol used by this connection URL