Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
DBTObject.java
Go to the documentation of this file.
1 /**
2  * Author: Sven Gothel <sgothel@jausoft.com>
3  * Copyright (c) 2020 Gothel Software e.K.
4  * Copyright (c) 2020 ZAFENA AB
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 package jau.direct_bt;
27 
28 import org.direct_bt.BTObject;
29 import org.direct_bt.BTType;
30 
31 public abstract class DBTObject extends DBTNativeDownlink implements BTObject
32 {
33  private final int hashValue;
34 
35  /* pp */ static int compHash(final String a, final String b) {
36  // 31 * x == (x << 5) - x
37  final int hash = 31 + a.hashCode();
38  return ((hash << 5) - hash) + b.hashCode();
39  }
40  /* pp */ static int compHash(final int a, final int b) {
41  // 31 * x == (x << 5) - x
42  final int hash = 31 + a;
43  return ((hash << 5) - hash) + b;
44  }
45 
46  protected DBTObject(final long nativeInstance, final int hashValue)
47  {
48  super(nativeInstance);
49  this.hashValue = hashValue;
50  }
51 
52  static BTType class_type() { return BTType.NONE; }
53 
54  @Override
55  public abstract boolean equals(final Object obj);
56 
57  @Override
58  public final int hashCode() {
59  return hashValue;
60  }
61 
62  @Override
63  protected void finalize()
64  {
65  close();
66  }
67 
68  @Override
69  public synchronized void close() {
70  delete();
71  }
72 
73  @Override
74  public BTObject clone()
75  { throw new UnsupportedOperationException(); } // FIXME
76 
77 }
jau.direct_bt.DBTObject.equals
abstract boolean equals(final Object obj)
jau.direct_bt.DBTObject.DBTObject
DBTObject(final long nativeInstance, final int hashValue)
Definition: DBTObject.java:46
org.direct_bt
Author: Sven Gothel sgothel@jausoft.com Copyright (c) 2020 Gothel Software e.K.
jau.direct_bt.DBTObject.hashCode
final int hashCode()
Definition: DBTObject.java:58
org.direct_bt.BTObject.hashCode
int hashCode()
jau.direct_bt.DBTObject.close
synchronized void close()
Release the native memory associated with this object The object should not be used following a call ...
Definition: DBTObject.java:69
jau.direct_bt.DBTObject.finalize
void finalize()
Definition: DBTObject.java:63
org.direct_bt.BTType.NONE
NONE
Definition: BTType.java:29
org
org.direct_bt.BTType
Definition: BTType.java:28
jau.direct_bt.DBTObject.clone
BTObject clone()
Definition: DBTObject.java:74
org.direct_bt.BTObject
Definition: BTObject.java:31
jau.direct_bt.DBTObject
Definition: DBTObject.java:32