JAL-1355
[jalview.git] / src / com / stevesoft / pat / Bracket.java
index 9f60179..cec8af4 100755 (executable)
@@ -1,48 +1,88 @@
-//\r
-// This software is now distributed according to\r
-// the Lesser Gnu Public License.  Please see\r
-// http://www.gnu.org/copyleft/lesser.txt for\r
-// the details.\r
-//    -- Happy Computing!\r
-//\r
-package com.stevesoft.pat;\r
-import java.util.Vector;\r
-import java.util.Hashtable;\r
-\r
-/** The Bracket is a form of the Or class,\r
- implements the pattern element [  ]. */\r
-class Bracket extends Or {\r
-    boolean neg;\r
-    Bracket(boolean n) { neg = n; }\r
-    String leftForm() {\r
-        if(neg)\r
-            return "[^";\r
-        else\r
-            return "[";\r
-    }\r
-    String rightForm() { return "]"; }\r
-    String sepForm() { return ""; }\r
-    public int matchInternal(int pos,Pthings pt) {\r
-        if(pos >= pt.src.length()) return -1;\r
-        int r = super.matchInternal(pos,pt);\r
-        if((neg && r<0)||(!neg && r>=0))\r
-            return nextMatch(pos+1,pt);\r
-        return -1;\r
-    }\r
-    public patInt minChars() { return new patInt(1); }\r
-    public patInt maxChars() { return new patInt(1); }\r
-\r
-    public Or addOr(Pattern p) {\r
-        pv = null;\r
-        v.addElement(p);\r
-        p.setParent(null);\r
-        return this;\r
-    }\r
-    public Pattern clone1(Hashtable h) {\r
-        Bracket b = new Bracket(neg);\r
-        b.v = new Vector();\r
-        for(int i=0;i<v.size();i++)\r
-            b.v.addElement( ((Pattern)v.elementAt(i)).clone1(h) );\r
-        return b;\r
-    }\r
-};\r
+//
+// This software is now distributed according to
+// the Lesser Gnu Public License.  Please see
+// http://www.gnu.org/copyleft/lesser.txt for
+// the details.
+//    -- Happy Computing!
+//
+package com.stevesoft.pat;
+
+import java.util.*;
+
+/**
+ * The Bracket is a form of the Or class, implements the pattern element [ ].
+ */
+class Bracket extends Or
+{
+  boolean neg;
+
+  Bracket(boolean n)
+  {
+    neg = n;
+  }
+
+  String leftForm()
+  {
+    if (neg)
+    {
+      return "[^";
+    }
+    else
+    {
+      return "[";
+    }
+  }
+
+  String rightForm()
+  {
+    return "]";
+  }
+
+  String sepForm()
+  {
+    return "";
+  }
+
+  public int matchInternal(int pos, Pthings pt)
+  {
+    if (pos >= pt.src.length())
+    {
+      return -1;
+    }
+    int r = super.matchInternal(pos, pt);
+    if ((neg && r < 0) || (!neg && r >= 0))
+    {
+      return nextMatch(pos + 1, pt);
+    }
+    return -1;
+  }
+
+  public patInt minChars()
+  {
+    return new patInt(1);
+  }
+
+  public patInt maxChars()
+  {
+    return new patInt(1);
+  }
+
+  public Or addOr(Pattern p)
+  {
+    pv = null;
+    v.addElement(p);
+    p.setParent(null);
+    return this;
+  }
+
+  public Pattern clone1(Hashtable h)
+  {
+    Bracket b = new Bracket(neg);
+    b.v = new Vector();
+    for (int i = 0; i < v.size(); i++)
+    {
+      b.v.addElement(((Pattern) v.elementAt(i)).clone1(h));
+    }
+    return b;
+  }
+};