diff src/org/tn5250j/framework/tn5250/KeyStrokenizer.java @ 112:77ac18bc1b2f

cleanup java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 18 Jun 2014 13:03:01 -0700
parents 1e931ef5f776
children e2a56e383bad
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java	Wed Jun 18 13:00:19 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java	Wed Jun 18 13:03:01 2014 -0700
@@ -34,125 +34,127 @@
 
 
 
-   public KeyStrokenizer() {
+    public KeyStrokenizer() {
+        sb = new StringBuffer();
+        setKeyStrokes(null);
+    }
 
-      sb = new StringBuffer();
-      setKeyStrokes(null);
-   }
+    public void setKeyStrokes(String strokes) {
+        if (strokes != null) {
+            keyStrokes.setLength(0);
+            Log.d(TAG, "set " + keyStrokes);
+            length = strokes.length();
+        }
+        else {
+            keyStrokes = new StringBuffer();
+            length = 0;
+        }
 
-   public void setKeyStrokes (String strokes) {
+        keyStrokes.append(strokes);
+        index = 0;
+    }
 
-      if (strokes != null) {
-         keyStrokes.setLength(0);
-		 Log.d(TAG,"set "+ keyStrokes);
-         length = strokes.length();
-      }
-      else {
+    public boolean hasMoreKeyStrokes() {
+        return length > index;
+    }
 
-         keyStrokes = new StringBuffer();
-         length = 0;
+    public String nextKeyStroke() {
+        String s = "";
+        boolean gotOne = false;
+
+        if (length > index) {
+            sb.setLength(0);
+            char c = keyStrokes.charAt(index);
 
-      }
-      keyStrokes.append(strokes);
-      index = 0;
+            switch (c) {
+                case '[':
+                    sb.append(c);
+                    index++;
 
-   }
-
-   public boolean hasMoreKeyStrokes() {
-      return length > index;
-   }
+                    // we need to throw an error here
+                    if (index >= length) {
+                        Log.w(TAG, " mnemonic key was incomplete :1 " +
+                              "at position " + index + " len " + length);
+                    }
+                    else {
+                        c = keyStrokes.charAt(index);
 
-   public String nextKeyStroke() {
+                        if (c == '[')
+                            index++;
+                        else {
+                            while (!gotOne) {
+                                if (c == ']') { // did we find an ending
+                                    sb.append(c);
+                                    index++;
+                                    gotOne = true;
+                                }
+                                else {
+                                    sb.append(c);
+                                    index++;
 
-      String s = "";
-      boolean gotOne = false;
-      if(length > index) {
-         sb.setLength(0);
-
-         char c = keyStrokes.charAt(index);
-         switch(c) {
-            case '[':
-               sb.append(c);
-               index++;
+                                    // we need to throw an error here because we did not
+                                    //   find an ending for the potential mnemonic
+                                    if (index >= length) {
+                                        Log.w(TAG,
+                                              " mnemonic key was incomplete ending not found :2 " +
+                                              "at position " + index);
+                                    }
 
-               // we need to throw an error here
-               if(index >= length) {
-                  Log.w(TAG," mnemonic key was incomplete :1 " +
-                                       "at position " + index + " len " + length );
-               }
-               else {
-                  c = keyStrokes.charAt(index);
+                                    c = keyStrokes.charAt(index);
+                                }
+                            }
+                        }
+                    }
+
+                    break;
+
+                case ']':
+                    index++;
 
-                  if(c == '[')
-                       index++;
-                  else {
-                     while(!gotOne) {
+                    if (index >= length) {
+                        Log.w(TAG,
+                              " mnemonic key was incomplete ending not found :3 " +
+                              "at position " + index);
+                        sb.append(c);
+                        index++;
+                    }
+                    else {
+                        c = keyStrokes.charAt(index);
 
-                        if(c == ']') { // did we find an ending
-                           sb.append(c);
-                           index++;
-                           gotOne = true;
+                        if (c == ']') {
+                            sb.append(c);
+                            index++;
                         }
                         else {
-                           sb.append(c);
-                           index++;
-                           // we need to throw an error here because we did not
-                           //   find an ending for the potential mnemonic
-                           if(index >= length) {
-                              Log.w(TAG,
-                              " mnemonic key was incomplete ending not found :2 " +
-                                          "at position " + index);
-                           }
-                           c = keyStrokes.charAt(index);
+                            Log.w(TAG,
+                                  " mnemonic key was incomplete beginning not found :4 " +
+                                  "at position " + index);
                         }
-                     }
-                  }
-               }
-               break;
+                    }
+
+                    break;
 
-            case ']':
-               index++;
-               if(index >= length) {
-                  Log.w(TAG,
-                  " mnemonic key was incomplete ending not found :3 " +
-                              "at position " + index);
-                  sb.append(c);
-                  index++;
+                default:
+                    sb.append(c);
+                    index++;
+                    break;
+            }
 
-               }
-               else {
-                  c = keyStrokes.charAt(index);
-                  if(c == ']') {
-                     sb.append(c);
-                     index++;
-                  }
-                  else {
-                     Log.w(TAG,
-                     " mnemonic key was incomplete beginning not found :4 " +
-                                 "at position " + index);
-                  }
-               }
-               break;
-            default:
-               sb.append(c);
-               index++;
-               break;
-         }
-         if(sb != null) {
-            s = new String(sb);
-         }
+            if (sb != null) {
+                s = new String(sb);
+            }
+        }
 
-      }
-	  Log.d(TAG,"next "+ keyStrokes);
-
-      return s;
-   }
+        Log.d(TAG, "next " + keyStrokes);
+        return s;
+    }
 
-   public String getUnprocessedKeyStroked() {
-      if(index >= length) {
-    	  return null;
-      }
-      return keyStrokes.substring(index);
-   }
+    public String getUnprocessedKeyStroked() {
+        if (index >= length) {
+            return null;
+        }
+
+        return keyStrokes.substring(index);
+    }
 
 }
\ No newline at end of file