Class RangeUtils

java.lang.Object
net.mtrop.doom.util.RangeUtils

public final class RangeUtils extends Object
Holds a series of helpful methods for testing data integrity for Doom map data export.
Author:
Matthew Tropiano
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkASCIIString(String dataName, String value)
    Checks if a string's length is 8 or less or not null nor blank and convertible to ASCII.
    static void
    checkBoolean(String dataName, boolean flag, boolean value)
    Checks if a value is either true or false.
    static void
    checkByte(String dataName, int value)
    Checks if a value falls in the -128 to 127 range.
    static void
    checkByteUnsigned(String dataName, int value)
    Checks if a value falls in the 0 to 255 range.
    static void
    checkEqual(String dataName, float equalVal, float value)
    Checks if a value equals a particular floating-point value.
    static void
    checkEqual(String dataName, String equalVal, String value)
    Checks if a value equals a particular String value.
    static void
    checkFalse(String dataName, boolean value)
    Checks if a value is false.
    static void
    checkNegativeOne(String dataName, int value)
    Checks if a value is negative one.
    static void
    checkNotNull(String dataName, Object value)
    Checks if a value is not null.
    static void
    checkRange(String dataName, int min, int max, int value)
    Checks if a value falls in an inclusive range.
    static void
    checkShort(String dataName, int value)
    Checks if a value falls in the -32767 to 32768 range.
    static void
    checkShortUnsigned(String dataName, int value)
    Checks if a value falls in the 0 to 65535 range.
    static void
    checkTrue(String dataName, boolean value)
    Checks if a value is true.
    static void
    checkWhole(String dataName, float value)
    Checks if a value is a whole number, without a mantissa.
    static void
    checkZero(String dataName, int value)
    Checks if a value is zero.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • checkNotNull

      public static void checkNotNull(String dataName, Object value) throws IllegalArgumentException
      Checks if a value is not null.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkRange

      public static void checkRange(String dataName, int min, int max, int value) throws IllegalArgumentException
      Checks if a value falls in an inclusive range.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      min - the minimum value.
      max - the maximum value.
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkEqual

      public static void checkEqual(String dataName, float equalVal, float value) throws IllegalArgumentException
      Checks if a value equals a particular floating-point value.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      equalVal - the equality value.
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkEqual

      public static void checkEqual(String dataName, String equalVal, String value) throws IllegalArgumentException
      Checks if a value equals a particular String value.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      equalVal - the equality value.
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkBoolean

      public static void checkBoolean(String dataName, boolean flag, boolean value) throws IllegalArgumentException
      Checks if a value is either true or false.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      flag - the flag value.
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkWhole

      public static void checkWhole(String dataName, float value) throws IllegalArgumentException
      Checks if a value is a whole number, without a mantissa.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkZero

      public static void checkZero(String dataName, int value) throws IllegalArgumentException
      Checks if a value is zero.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkNegativeOne

      public static void checkNegativeOne(String dataName, int value) throws IllegalArgumentException
      Checks if a value is negative one.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkASCIIString

      public static void checkASCIIString(String dataName, String value) throws IllegalArgumentException
      Checks if a string's length is 8 or less or not null nor blank and convertible to ASCII.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkByteUnsigned

      public static void checkByteUnsigned(String dataName, int value) throws IllegalArgumentException
      Checks if a value falls in the 0 to 255 range.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkByte

      public static void checkByte(String dataName, int value) throws IllegalArgumentException
      Checks if a value falls in the -128 to 127 range.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkShort

      public static void checkShort(String dataName, int value) throws IllegalArgumentException
      Checks if a value falls in the -32767 to 32768 range.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkShortUnsigned

      public static void checkShortUnsigned(String dataName, int value) throws IllegalArgumentException
      Checks if a value falls in the 0 to 65535 range.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkTrue

      public static void checkTrue(String dataName, boolean value) throws IllegalArgumentException
      Checks if a value is true.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.
    • checkFalse

      public static void checkFalse(String dataName, boolean value) throws IllegalArgumentException
      Checks if a value is false.
      Parameters:
      dataName - the name of the data field (appears in exception text).
      value - the value to check.
      Throws:
      IllegalArgumentException - if criteria not met.