-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectionListStore.java
142 lines (127 loc) · 3.05 KB
/
ConnectionListStore.java
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Department of Computer Science, University at Buffalo
*
* CSE 589 Project - 1
*
* Authors: Sharath Chandrashekhara - [email protected]
* Sanket Kulkarni - [email protected]
*
* Date: 14th October, 2012
*
* This is file contains Helper utility functions for input validation
*
*/
import java.util.ArrayList;
import java.util.Iterator;
/**
* The Class ConnectionListStore.
*/
public class ConnectionListStore{
/** The counter in connections. */
private int counterInConnections = 0;
/** The Out going connections. */
private ArrayList<ConnectionStatus> OutGoingConnections;
/** The In coming connections. */
private ArrayList<ConnectionStatus> InComingConnections;
/**
* Instantiates a new connection list store.
*/
public ConnectionListStore(){
this.OutGoingConnections = new ArrayList<ConnectionStatus>();
this.InComingConnections = new ArrayList<ConnectionStatus>();
}
/**
* Gets the out going connections.
*
* @return the out going connections
*/
public ArrayList<ConnectionStatus> getOutGoingConnections() {
return OutGoingConnections;
}
/**
* Sets the out going connections.
*
* @param outGoingConnections the new out going connections
*/
public void setOutGoingConnections(
ArrayList<ConnectionStatus> outGoingConnections) {
OutGoingConnections = outGoingConnections;
}
/**
* Gets the in coming connections.
*
* @return the in coming connections
*/
public ArrayList<ConnectionStatus> getInComingConnections() {
return InComingConnections;
}
/**
* Sets the in coming connections.
*
* @param inComingConnections the new in coming connections
*/
public void setInComingConnections(
ArrayList<ConnectionStatus> inComingConnections) {
InComingConnections = inComingConnections;
}
/**
* Gets the counter in connections.
*
* @return the counter in connections
*/
public int getCounterInConnections() {
return counterInConnections;
}
/**
* Sets the counter in connections.
*
* @param counterInConnections the new counter in connections
*/
public void setCounterInConnections(int counterInConnections) {
this.counterInConnections = counterInConnections;
}
/**
* Check empty.
*
* @param param the param
* @return true, if successful
*/
public boolean checkEmpty(String param){
if("in".equals(param)){
return InComingConnections.isEmpty();
}
else{
return OutGoingConnections.isEmpty();
}
}
/**
* Gets the iterator.
*
* @param param the param
* @return the iterator
*/
public Iterator<ConnectionStatus> getIterator(String param){
if("in".equals(param)){
return InComingConnections.iterator();
}
else{
return OutGoingConnections.iterator();
}
}
/**
* Reset count.
*
* @param count the count
*/
public void resetCount(String count){
if(count.equals("in")){
for (int i = 0; i < InComingConnections.size(); i++) {
InComingConnections.get(i).setConnectionID(i+1);
}
}else{
for (int i = 0; i < OutGoingConnections.size(); i++) {
OutGoingConnections.get(i).setConnectionID(i+1);
}
}
}
}