checkstyle'd
[fanfix.git] / src / jexer / bits / MnemonicString.java
index 0567c99def9872045535d721e524667c612add2f..0537bbedfaa2991894ba4d4f7a034d8f1e305dd3 100644 (file)
@@ -1,16 +1,11 @@
 /**
  * Jexer - Java Text User Interface
  *
- * Version: $Id$
- *
- * Author: Kevin Lamonte, <a href="mailto:kevin.lamonte@gmail.com">kevin.lamonte@gmail.com</a>
- *
  * License: LGPLv3 or later
  *
- * Copyright: This module is licensed under the GNU Lesser General
- * Public License Version 3.  Please see the file "COPYING" in this
- * directory for more information about the GNU Lesser General Public
- * License Version 3.
+ * This module is licensed under the GNU Lesser General Public License
+ * Version 3.  Please see the file "COPYING" in this directory for more
+ * information about the GNU Lesser General Public License Version 3.
  *
  *     Copyright (C) 2015  Kevin Lamonte
  *
@@ -29,6 +24,9 @@
  * http://www.gnu.org/licenses/, or write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA
+ *
+ * @author Kevin Lamonte [kevin.lamonte@gmail.com]
+ * @version 1
  */
 package jexer.bits;
 
@@ -41,57 +39,56 @@ package jexer.bits;
 public class MnemonicString {
 
     /**
-     * Keyboard shortcut to activate this item
+     * Keyboard shortcut to activate this item.
      */
-    public char shortcut;
+    private char shortcut;
 
     /**
-     * Location of the highlighted character
+     * Location of the highlighted character.
      */
-    public int shortcutIdx = -1;
+    private int shortcutIdx = -1;
 
     /**
-     * The raw (uncolored) string
+     * The raw (uncolored) string.
      */
-    public String rawLabel;
+    private String rawLabel;
 
     /**
-     * Public constructor
+     * Public constructor.
      *
      * @param label widget label or title.  Label must contain a keyboard
      * shortcut, denoted by prefixing a letter with "&", e.g. "&File"
      */
-    public MnemonicString(String label) {
+    public MnemonicString(final String label) {
 
-       // Setup the menu shortcut
-       String newLabel = "";
-       boolean foundAmp = false;
-       boolean foundShortcut = false;
-       int shortcutIdx = 0;
-       for (int i = 0; i < label.length(); i++) {
-           char c = label.charAt(i);
-           if (c == '&') {
-               if (foundAmp == true) {
-                   newLabel += '&';
-                   shortcutIdx++;
-               } else {
-                   foundAmp = true;
-               }
-           } else {
-               newLabel += c;
-               if (foundAmp == true) {
-                   if (foundShortcut == false) {
-                       shortcut = c;
-                       foundAmp = false;
-                       foundShortcut = true;
-                       this.shortcutIdx = shortcutIdx;
-                   }
-               } else {
-                   shortcutIdx++;
-               }
-           }
-       }
-       this.rawLabel = newLabel;
+        // Setup the menu shortcut
+        String newLabel = "";
+        boolean foundAmp = false;
+        boolean foundShortcut = false;
+        int scanShortcutIdx = 0;
+        for (int i = 0; i < label.length(); i++) {
+            char c = label.charAt(i);
+            if (c == '&') {
+                if (foundAmp) {
+                    newLabel += '&';
+                    scanShortcutIdx++;
+                } else {
+                    foundAmp = true;
+                }
+            } else {
+                newLabel += c;
+                if (foundAmp) {
+                    if (!foundShortcut) {
+                        shortcut = c;
+                        foundAmp = false;
+                        foundShortcut = true;
+                        shortcutIdx = scanShortcutIdx;
+                    }
+                } else {
+                    scanShortcutIdx++;
+                }
+            }
+        }
+        this.rawLabel = newLabel;
     }
 }
-