@@ -37,7 +37,7 @@ public BoardType getVestaBoardType() {
3737 /**
3838 * Configure whether Vestaboard object is a white on black Vestaboard or a black on white Vestaboard
3939 * Default is white lettering on black Vestaboard frame
40- * @param bt
40+ * @param bt board type
4141 */
4242 public void setVestaBoardType (BoardType bt ) {
4343 this .bt = bt ;
@@ -92,16 +92,14 @@ public enum BoardType {
9292 private final int COLS =22 ; // number of cols in Vestaboard
9393 private final int RETRIES =5 ; // number of attempts to send board to VestaBoard
9494
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
95+ private final boolean truncate = false ; // Not used yet, VestaBoard came out w/ concept of VBML json support
96+ private final boolean wrap = true ; // Not used yet, VestaBoard came out w/ concept of VBML json support
9797 private final String api_key ; // Key to allow use of Vestaboard Installable APIs
9898 private final String api_secret ;
9999 private final String api_rw_key ; // Key to use for direct reading/writing of Vestaboard (max 1 per board)
100100
101101 private final String content_type = "application/json" ; // new edition 4-2003
102102
103- private final HttpClient httpClient ; // Used to communicate with VestaBoard APIs
104-
105103 private final VestaChars [][] board ; // Data Structure Representation of VestaBoard
106104
107105 public static final char UNICODE_UTF16_RED = '\uDFE5' ; // {63} in VestaBoard char codes
@@ -110,8 +108,8 @@ public enum BoardType {
110108 public static final char UNICODE_UTF16_YELLOW = '\uDFE8' ; // {65} in VestaBoard char codes
111109 public static final char UNICODE_UTF16_GREEN = '\uDFE9' ; // {66} in VestaBoard char codes
112110 public static final char UNICODE_UTF16_VIOLET = '\uDFEA' ; // {68} in VestaBoard char codes
113- public static final char UNICODE_UTF16_WHITE = '\u25A1 ' ; // {69} in VestaBoard char codes
114- public static final char UNICODE_UTF16_BLACK = '\u25A0 ' ; // {70} in VestaBoard char codes
111+ public static final char UNICODE_UTF16_WHITE = '□ ' ; // Unicode 25A1 or {69} in VestaBoard char codes
112+ public static final char UNICODE_UTF16_BLACK = '■ ' ; // Unicode 25A0 {70} in VestaBoard char codes
115113
116114 // BoardType
117115 private BoardType bt ; // Board type is white lettering on black or black lettering on white
@@ -148,7 +146,6 @@ public VestaBoard(String filename) throws IOException, ConfigurationException {
148146 board [i ][j ] = VestaChars .Blank ;
149147 }
150148 }
151- httpClient = HttpClient .newHttpClient ();
152149
153150 // Read in ini file
154151 INIConfiguration iniConfiguration = new INIConfiguration ();
@@ -178,12 +175,9 @@ public VestaBoard(String filename) throws IOException, ConfigurationException {
178175 * [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
179176 * [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]]'
180177 * <a href="https://rw.vestaboard.com/">...</a>
181- *
182178 * Prints an A in the last location
183- *
184179 * The string values in each cell must be the Vesta character encoding
185180 * and not the ASCII encoding
186- *
187181 * @see <a href="https://docs.vestaboard.com/read-write">...</a>
188182 * @see <a href="https://docs.vestaboard.com/characters">...</a>
189183 * @return curl data compatible string
@@ -379,25 +373,23 @@ public String readMessage() throws IOException, InterruptedException {
379373 JSONObject jsonObjCM = jsonObj .getJSONObject ("currentMessage" );
380374 String layoutArray = jsonObjCM .getString ("layout" );
381375
382- char [] layoutArrayAsCharArr = layoutArray .toCharArray ();
383376 StringBuilder convertedString = new StringBuilder ();
384377 layoutArray = layoutArray .substring (1 ,layoutArray .length ()-1 );
385378 final Pattern pattern = Pattern .compile ("([0-9]+(,[0-9]+)+)" );
386379 final Matcher matcher = pattern .matcher (layoutArray );
387- List <String > allMatches = new ArrayList <String >();
380+ List <String > allMatches = new ArrayList <>();
388381 while (matcher .find ()) {
389382 allMatches .add (matcher .group ());
390383 }
391- List <String > elements = new ArrayList <String >();
384+ List <String > elements = new ArrayList <>();
392385 for (String aMatch : allMatches ) {
393386 String [] elementsInARow = aMatch .split ("," );
394387 elements .addAll (Arrays .asList (elementsInARow ));
395388 }
396389
397390 for (String element : elements ) {
398- int value = Integer .valueOf (element );
399- if (value == '[' || value == ']' ) {
400- } else if (value == VestaChars .PoppyRed .getCharValue ())
391+ int value = Integer .parseInt (element );
392+ if (value == VestaChars .PoppyRed .getCharValue ())
401393 convertedString .append (UNICODE_UTF16_RED );
402394 else if (value == VestaChars .Yellow .getCharValue ())
403395 convertedString .append (UNICODE_UTF16_YELLOW );
@@ -525,8 +517,6 @@ else if (value == VestaChars.Comma.getCharValue())
525517 convertedString .append (',' );
526518 else if (value == VestaChars .Period .getCharValue ())
527519 convertedString .append ('.' );
528- else
529- convertedString .append ("" );
530520
531521 }
532522
@@ -544,6 +534,12 @@ else if (value == VestaChars.Period.getCharValue())
544534 public static void main (String [] args ) throws ConfigurationException , IOException , InterruptedException {
545535 VestaBoard v = new VestaBoard ("credentials-virtual.ini" );
546536 System .out .println (v .readMessage ());
547- v .postMessage ("TEST2" );
537+ int result = v .postMessage ("TEST7" );
538+ if (result != 200 ) {
539+ System .err .println ("Problem occurred" );
540+ }
541+ else {
542+ System .out .println ("Everything is good." );
543+ }
548544 }
549545}
0 commit comments