1 /*
2 *
3 * Fosstrak LLRP Commander (www.fosstrak.org)
4 *
5 * Copyright (C) 2008 ETH Zurich
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>
19 *
20 */
21
22 package org.fosstrak.llrp.commander.views;
23
24 import java.util.ArrayList;
25
26
27 /**
28 * Models an object in the reader tree (eg. adapter or reader).
29 * @author zhanghao
30 *
31 */
32 public class ReaderTreeObject extends MessageBoxTreeObject {
33
34 private ArrayList<MessageBoxTreeObject> children;
35
36 private boolean isConnected;
37 private boolean isReader;
38 private boolean isGetReaderConfig;
39 private boolean isGetReaderROSpec;
40
41
42 public ReaderTreeObject(String name) {
43 super(name);
44 children = new ArrayList<MessageBoxTreeObject>();
45 setConnected(false);
46 setReader(false);
47 setGetReaderConfig(false);
48 setGetReaderROSpec(false);
49 }
50
51 public void addChild(MessageBoxTreeObject child) {
52 children.add(child);
53 child.setParent(this);
54 }
55
56 public void removeChild(MessageBoxTreeObject child) {
57 children.remove(child);
58 child.setParent(null);
59 }
60 public MessageBoxTreeObject [] getChildren() {
61 return (MessageBoxTreeObject [])children.toArray(new MessageBoxTreeObject[children.size()]);
62 }
63 public boolean hasChildren() {
64 return children.size()>0;
65 }
66
67 /**
68 * Return whether the reader is connected.
69 * @return Reader is connected or not.
70 */
71 public boolean isConnected() {
72 return isConnected;
73 }
74
75 /**
76 * Set the flag to indicate whether the reader is connected.
77 * @param isConnected Reader is connected or not.
78 */
79 public void setConnected(boolean isConnected) {
80 this.isConnected = isConnected;
81 }
82
83 /**
84 * Return whether the node represent a reader.
85 * @return This node is a reader or not
86 */
87 public boolean isReader() {
88 return isReader;
89 }
90
91 /**
92 * Set the flag to indicate whether the node represent a reader.
93 * @param isReader This node is a reader or not
94 */
95 public void setReader(boolean isReader) {
96 this.isReader = isReader;
97 }
98
99 /**
100 * Return whether the reader get GET_READER_CONFIG_RESPONSE message.
101 * @return Get GET_READER_CONFIG_RESPONSE message or not
102 */
103 public boolean isGetReaderConfig() {
104 return isGetReaderConfig;
105 }
106
107 /**
108 * Set the flag to indicate the reader get GET_READER_CONFIG_RESPONSE message.
109 * @param isGetReaderConfig Get GET_READER_CONFIG_RESPONSE message or not
110 */
111 public void setGetReaderConfig(boolean isGetReaderConfig) {
112 this.isGetReaderConfig = isGetReaderConfig;
113 }
114
115 /**
116 * Return whether the reader get GET_ROSPECS_RESPONSE message.
117 * @return Get GET_ROSPECS_RESPONSE message or not
118 */
119 public boolean isGetReaderROSpec() {
120 return isGetReaderROSpec;
121 }
122
123 /**
124 * Set the flag to indicate the reader get GET_ROSPECS_RESPONSE message.
125 * @param isGetReaderROSpec Get GET_ROSPECS_RESPONSE message or not
126 */
127 public void setGetReaderROSpec(boolean isGetReaderROSpec) {
128 this.isGetReaderROSpec = isGetReaderROSpec;
129 }
130 }