1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sf.bluecove.obex;
26
27 import java.io.IOException;
28 import java.util.StringTokenizer;
29
30 class DeviceInfo implements Storable {
31
32 String btAddress;
33
34 String name;
35
36 String obexUrl;
37
38 boolean obexServiceFound = false;
39
40 public String toString() {
41 if ((name != null) && (name.length() > 0)) {
42 return name;
43 } else {
44 return btAddress;
45 }
46 }
47
48 private String fixNull(String str) {
49 if (str.equalsIgnoreCase("null")) {
50 return null;
51 }
52 return str;
53 }
54
55 public void loadFromLine(String line) throws IOException {
56 StringTokenizer st = new StringTokenizer(line, "|");
57 if (!st.hasMoreTokens()) {
58 throw new IOException();
59 }
60 btAddress = fixNull(st.nextToken());
61 if (!st.hasMoreTokens()) {
62 throw new IOException();
63 }
64 name = fixNull(st.nextToken());
65 if (!st.hasMoreTokens()) {
66 throw new IOException();
67 }
68 obexUrl = fixNull(st.nextToken());
69 }
70
71 public String saveAsLine() {
72 return btAddress + "|" + name + "|" + obexUrl;
73 }
74
75 public boolean isValid() {
76 if ((obexUrl == null) || (btAddress == null)) {
77 return false;
78 }
79 return (obexUrl.toLowerCase().indexOf("://" + btAddress.toLowerCase() + ":") != -1);
80 }
81 }