Skip to content

Commit 9314653

Browse files
committed
Update the docs, optimize some expressions in code
1 parent ecdfc29 commit 9314653

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/mcs/mvnu/vestaboard/VestaBoard.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.net.http.HttpRequest;
1414
import java.net.http.HttpResponse;
1515
import java.util.ArrayList;
16+
import java.util.Arrays;
1617
import java.util.List;
1718
import java.util.regex.Matcher;
1819
import java.util.regex.Pattern;
@@ -27,15 +28,15 @@ public class VestaBoard {
2728
/**
2829
* Return whether VestaBoard object is representing a white on black Vestaboard or a black on white Vestaboard.
2930
* Default is white on black Vestaboard
30-
* @return
31+
* @return board type (white lettering on black frame or black lettering on white frame)
3132
*/
3233
public BoardType getVestaBoardType() {
3334
return bt;
3435
}
3536

3637
/**
3738
* Configure whether Vestaboard object is a white on black Vestaboard or a black on white Vestaboard
38-
* Default is white on black Vestaboard
39+
* Default is white lettering on black Vestaboard frame
3940
* @param bt
4041
*/
4142
public void setVestaBoardType(BoardType bt) {
@@ -91,8 +92,8 @@ public enum BoardType {
9192
private final int COLS=22; // number of cols in Vestaboard
9293
private final int RETRIES=5; // number of attempts to send board to VestaBoard
9394

94-
private boolean truncate = false;
95-
private boolean wrap = true;
95+
private boolean truncate = false; // Not used yet, VestaBoard came out w/ concept of VBML json support
96+
private boolean wrap = true; // Not used yet, VestaBoard came out w/ concept of VBML json support
9697
private final String api_key; // Key to allow use of Vestaboard Installable APIs
9798
private final String api_secret;
9899
private final String api_rw_key; // Key to use for direct reading/writing of Vestaboard (max 1 per board)
@@ -176,7 +177,7 @@ public VestaBoard(String filename) throws IOException, ConfigurationException {
176177
* [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
177178
* [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
178179
* [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]]'
179-
* https://rw.vestaboard.com/
180+
* <a href="https://rw.vestaboard.com/">...</a>
180181
*
181182
* Prints an A in the last location
182183
*
@@ -215,8 +216,9 @@ private String convertBoardToString() {
215216
/**
216217
* Wipe the internal virtual vestaboard object
217218
* NOTE: Does not send to the web to avoid wearing out mechanical tiles.
218-
* @throws IOException
219-
* @throws InterruptedException
219+
* @throws IOException Input/Output Exception
220+
* @throws InterruptedException Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is
221+
* interrupted, either before or during the activity
220222
*/
221223
public void wipeBoard () throws IOException, InterruptedException {
222224
for (int i = 0; i < ROWS; i++) {
@@ -228,9 +230,10 @@ public void wipeBoard () throws IOException, InterruptedException {
228230

229231
/**
230232
* Sends virtual vestaboard to company's app or real board based on configuration
231-
* @return
232-
* @throws IOException
233-
* @throws InterruptedException
233+
* @return Status code
234+
* @throws IOException Input/Output Exception
235+
* @throws InterruptedException Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is
236+
* interrupted, either before or during the activity.
234237
*/
235238
private int sendOverTheWeb() throws IOException, InterruptedException {
236239
/* Prepare Request-Response HTTP Post message to write to the VestaBoard
@@ -391,16 +394,13 @@ public String readMessage() throws IOException, InterruptedException {
391394
List<String> elements = new ArrayList<String>();
392395
for(String aMatch : allMatches) {
393396
String[] elementsInARow = aMatch.split(",");
394-
for(String e : elementsInARow) {
395-
elements.add(e);
396-
}
397+
elements.addAll(Arrays.asList(elementsInARow));
397398
}
398399

399-
for(int i = 0; i < elements.size(); i++) {
400-
int value = Integer.valueOf(elements.get(i));
401-
if (value == '[' || value == ']')
402-
continue;
403-
else if (value == VestaChars.PoppyRed.getCharValue())
400+
for (String element : elements) {
401+
int value = Integer.valueOf(element);
402+
if (value == '[' || value == ']') {
403+
} else if (value == VestaChars.PoppyRed.getCharValue())
404404
convertedString.append(UNICODE_UTF16_RED);
405405
else if (value == VestaChars.Yellow.getCharValue())
406406
convertedString.append(UNICODE_UTF16_YELLOW);
@@ -533,7 +533,7 @@ else if (value == VestaChars.Period.getCharValue())
533533
else
534534
convertedString.append("");
535535

536-
}
536+
}
537537

538538
System.out.println(convertedString);
539539
return convertedString.toString();

0 commit comments

Comments
 (0)