JAL-1807 still testing
[jalviewjs.git] / unused / com / stevesoft / pat / patInt.java
index df0d028..72e0d2c 100644 (file)
-//
-// 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;
-
-/**
- * This is just an integer that can have infinite value. It is used internally
- * to implement the *, and + parts of regular expressions.
- */
-public class patInt
-{
-  int i;
-
-  boolean inf;
-
-  /** Initialize to zero. */
-  public patInt()
-  {
-    i = 0;
-    inf = false;
-  }
-
-  /** Initialize to the value of init. */
-  public patInt(int init)
-  {
-    i = init;
-    inf = false;
-  }
-
-  /** Initialize to the value of p. */
-  public patInt(patInt p)
-  {
-    i = p.i;
-    inf = p.inf;
-  }
-
-  /** set this int to infinity. */
-  public void setInf(boolean b)
-  {
-    inf = b;
-    if (b)
-    {
-      i = Integer.MAX_VALUE;
-    }
-  }
-
-  /** Increment the value of this by 1. */
-  public final void inc()
-  {
-    if (!inf)
-    {
-      i++;
-    }
-  }
-
-  /** Decrement the value of this by 1. */
-  public final void dec()
-  {
-    if (!inf)
-    {
-      i--;
-    }
-  }
-
-  /** Test to see if this is less than or equal to j. */
-  public final boolean lessEq(patInt j)
-  { /*
-     * if(inf) return false; if(j.inf) return true; return i <= j.i;
-     */
-    return !inf && (j.inf || i <= j.i);
-  }
-
-  /** Test to see if two patterns are equal. */
-  public final boolean equals(patInt j)
-  {
-    return !j.inf && !inf && i == j.i;
-  }
-
-  /**
-   * Formats the pattern as a String. Contrary to what you might expect,
-   * infinity is formatted as ""
-   */
-  final public String toString()
-  {
-    if (inf)
-    {
-      return "";
-    }
-    else
-    {
-      return "" + i;
-    }
-  }
-
-  /**
-   * This would be operator+=(patInt) if I were programming in C++.
-   */
-  public final patInt pluseq(patInt p)
-  {
-    if (inf || p.inf)
-    {
-      setInf(true);
-    }
-    else
-    {
-      i += p.i;
-    }
-    return this;
-  }
-
-  /**
-   * Returns a patInt with value equal to the product of the value of p and
-   * this.
-   */
-  public final patInt mul(patInt p)
-  {
-    if (inf || p.inf)
-    {
-      return new patInf();
-    }
-    return new patInt(i * p.i);
-  }
-
-  /**
-   * If the argument p has a smaller value than this, then set this Object equal
-   * to p.
-   */
-  public final patInt mineq(patInt p)
-  {
-    if (p.inf)
-    {
-      return this;
-    }
-    if (inf)
-    {
-      i = p.i;
-    }
-    else if (p.i < i)
-    {
-      i = p.i;
-    }
-    setInf(false);
-    return this;
-  }
-
-  /**
-   * If the argument p has a greater than this, then set this object equal to p.
-   */
-  public final patInt maxeq(patInt p)
-  {
-    if (inf || p.inf)
-    {
-      setInf(true);
-      return this;
-    }
-    if (p.i > i)
-    {
-      i = p.i;
-    }
-    return this;
-  }
-
-  /** Tests to see if this represents an infinite quantity. */
-  public boolean finite()
-  {
-    return !inf;
-  }
-
-  /**
-   * Converts to a patInt to an int. Infinity is mapped Integer.MAX_VALUE;
-   */
-  public int intValue()
-  {
-    return inf ? Integer.MAX_VALUE : i;
-  }
-};
+//\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
+\r
+/**\r
+ * This is just an integer that can have infinite value. It is used internally\r
+ * to implement the *, and + parts of regular expressions.\r
+ */\r
+public class patInt\r
+{\r
+  int i;\r
+\r
+  boolean inf;\r
+\r
+  /** Initialize to zero. */\r
+  public patInt()\r
+  {\r
+    i = 0;\r
+    inf = false;\r
+  }\r
+\r
+  /** Initialize to the value of init. */\r
+  public patInt(int init)\r
+  {\r
+    i = init;\r
+    inf = false;\r
+  }\r
+\r
+  /** Initialize to the value of p. */\r
+  public patInt(patInt p)\r
+  {\r
+    i = p.i;\r
+    inf = p.inf;\r
+  }\r
+\r
+  /** set this int to infinity. */\r
+  public void setInf(boolean b)\r
+  {\r
+    inf = b;\r
+    if (b)\r
+    {\r
+      i = Integer.MAX_VALUE;\r
+    }\r
+  }\r
+\r
+  /** Increment the value of this by 1. */\r
+  public final void inc()\r
+  {\r
+    if (!inf)\r
+    {\r
+      i++;\r
+    }\r
+  }\r
+\r
+  /** Decrement the value of this by 1. */\r
+  public final void dec()\r
+  {\r
+    if (!inf)\r
+    {\r
+      i--;\r
+    }\r
+  }\r
+\r
+  /** Test to see if this is less than or equal to j. */\r
+  public final boolean lessEq(patInt j)\r
+  { /*\r
+     * if(inf) return false; if(j.inf) return true; return i <= j.i;\r
+     */\r
+    return !inf && (j.inf || i <= j.i);\r
+  }\r
+\r
+  /** Test to see if two patterns are equal. */\r
+  public final boolean equals(patInt j)\r
+  {\r
+    return !j.inf && !inf && i == j.i;\r
+  }\r
+\r
+  /**\r
+   * Formats the pattern as a String. Contrary to what you might expect,\r
+   * infinity is formatted as ""\r
+   */\r
+  final public String toString()\r
+  {\r
+    if (inf)\r
+    {\r
+      return "";\r
+    }\r
+    else\r
+    {\r
+      return "" + i;\r
+    }\r
+  }\r
+\r
+  /**\r
+   * This would be operator+=(patInt) if I were programming in C++.\r
+   */\r
+  public final patInt pluseq(patInt p)\r
+  {\r
+    if (inf || p.inf)\r
+    {\r
+      setInf(true);\r
+    }\r
+    else\r
+    {\r
+      i += p.i;\r
+    }\r
+    return this;\r
+  }\r
+\r
+  /**\r
+   * Returns a patInt with value equal to the product of the value of p and\r
+   * this.\r
+   */\r
+  public final patInt mul(patInt p)\r
+  {\r
+    if (inf || p.inf)\r
+    {\r
+      return new patInf();\r
+    }\r
+    return new patInt(i * p.i);\r
+  }\r
+\r
+  /**\r
+   * If the argument p has a smaller value than this, then set this Object equal\r
+   * to p.\r
+   */\r
+  public final patInt mineq(patInt p)\r
+  {\r
+    if (p.inf)\r
+    {\r
+      return this;\r
+    }\r
+    if (inf)\r
+    {\r
+      i = p.i;\r
+    }\r
+    else if (p.i < i)\r
+    {\r
+      i = p.i;\r
+    }\r
+    setInf(false);\r
+    return this;\r
+  }\r
+\r
+  /**\r
+   * If the argument p has a greater than this, then set this object equal to p.\r
+   */\r
+  public final patInt maxeq(patInt p)\r
+  {\r
+    if (inf || p.inf)\r
+    {\r
+      setInf(true);\r
+      return this;\r
+    }\r
+    if (p.i > i)\r
+    {\r
+      i = p.i;\r
+    }\r
+    return this;\r
+  }\r
+\r
+  /** Tests to see if this represents an infinite quantity. */\r
+  public boolean finite()\r
+  {\r
+    return !inf;\r
+  }\r
+\r
+  /**\r
+   * Converts to a patInt to an int. Infinity is mapped Integer.MAX_VALUE;\r
+   */\r
+  public int intValue()\r
+  {\r
+    return inf ? Integer.MAX_VALUE : i;\r
+  }\r
+};\r