Package ptolemy.math

Class Precision.PrecisionFormat

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMMA_OR_FORWARDSLASH
      Regular expression definition for a comma "," or a forward slash "/".
      static java.lang.String OPTIONAL_L_PARAN
      Regular expression definition for an optional left parenthesis.
      static java.lang.String OPTIONAL_L_PARANBRACKET
      Regular expression definition for an optional left parenthesis or left bracket.
      static java.lang.String OPTIONAL_R_PARAN
      Regular expression definition for an optional right parenthesis.
      static java.lang.String OPTIONAL_R_PARANBRACKET
      Regular expression definition for an optional right parenthesis or left bracket.
      static java.lang.String OPTIONAL_U_OR_S_GROUP
      Regular expression for an optional 'S' or 'U' "group".
      static java.lang.String OPTIONAL_WHITE_SPACE
      Regular expression for optional white space.
      static java.lang.String PERIOD
      Regular expression definition for a Period ".".
      static java.lang.String SIGNED_INTEGER_GROUP
      Regular expression for a grouped signed integer (positive or negative).
      static java.lang.String UNSIGNED_INTEGER_GROUP
      Regular expression for a grouped unsigned integer.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrecisionFormat()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static int parseInteger​(java.lang.String str)
      Parse a String as an integer.
      static int parseSignString​(java.lang.String str)
      Parse the 'U' or 'S' sign specifier.
      abstract Precision parseString​(java.lang.String str)
      Parse the given String argument using the rules of the specific PrecisionFormat that is defined.
      abstract java.lang.String printPrecisionFormat​(Precision p)
      Creates a valid String representation of the Precision object based on the rules of the given string format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMMA_OR_FORWARDSLASH

        public static final java.lang.String COMMA_OR_FORWARDSLASH
        Regular expression definition for a comma "," or a forward slash "/".
        See Also:
        Constant Field Values
      • OPTIONAL_L_PARAN

        public static final java.lang.String OPTIONAL_L_PARAN
        Regular expression definition for an optional left parenthesis.
        See Also:
        Constant Field Values
      • OPTIONAL_L_PARANBRACKET

        public static final java.lang.String OPTIONAL_L_PARANBRACKET
        Regular expression definition for an optional left parenthesis or left bracket.
        See Also:
        Constant Field Values
      • OPTIONAL_R_PARAN

        public static final java.lang.String OPTIONAL_R_PARAN
        Regular expression definition for an optional right parenthesis.
        See Also:
        Constant Field Values
      • OPTIONAL_R_PARANBRACKET

        public static final java.lang.String OPTIONAL_R_PARANBRACKET
        Regular expression definition for an optional right parenthesis or left bracket.
        See Also:
        Constant Field Values
      • PERIOD

        public static final java.lang.String PERIOD
        Regular expression definition for a Period ".".
        See Also:
        Constant Field Values
      • SIGNED_INTEGER_GROUP

        public static final java.lang.String SIGNED_INTEGER_GROUP
        Regular expression for a grouped signed integer (positive or negative).
        See Also:
        Constant Field Values
      • OPTIONAL_U_OR_S_GROUP

        public static final java.lang.String OPTIONAL_U_OR_S_GROUP
        Regular expression for an optional 'S' or 'U' "group".
        See Also:
        Constant Field Values
      • UNSIGNED_INTEGER_GROUP

        public static final java.lang.String UNSIGNED_INTEGER_GROUP
        Regular expression for a grouped unsigned integer.
        See Also:
        Constant Field Values
      • OPTIONAL_WHITE_SPACE

        public static final java.lang.String OPTIONAL_WHITE_SPACE
        Regular expression for optional white space.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PrecisionFormat

        public PrecisionFormat()
    • Method Detail

      • parseString

        public abstract Precision parseString​(java.lang.String str)
                                       throws java.lang.IllegalArgumentException
        Parse the given String argument using the rules of the specific PrecisionFormat that is defined. This method will return a valid Precision object from the String. If the String parsing does not produce a valid match, this method will return a null. If the String match is successful but there is a problem in the interpretation of the match, this method will throw a IllegalArgumentException.
        Parameters:
        str - String to parse
        Returns:
        A Precision object. Returns a null if the String does not match the particular string format.
        Throws:
        java.lang.IllegalArgumentException - If there is a problem parsing the String (i.e. an illegal string).
      • printPrecisionFormat

        public abstract java.lang.String printPrecisionFormat​(Precision p)
        Creates a valid String representation of the Precision object based on the rules of the given string format. The format of this String should be consistent with the format used in the parseString method.
        Parameters:
        p - Precision object to represent as a String.
        Returns:
        String representing the Precision object
      • parseInteger

        public static int parseInteger​(java.lang.String str)
                                throws java.lang.IllegalArgumentException
        Parse a String as an integer. This method calls the Integer.parseInt method but throws the IllegalArgumentException instead of the NumberFormatException when there is a problem.
        Parameters:
        str - The integer string to parse
        Returns:
        The integer value of the string.
        Throws:
        java.lang.IllegalArgumentException - If the parsing of the Integer value fails (i.e. NumberFormatException).
      • parseSignString

        public static int parseSignString​(java.lang.String str)
                                   throws java.lang.IllegalArgumentException
        Parse the 'U' or 'S' sign specifier.
        Parameters:
        str - String to parse for a sign indicator.
        Returns:
        Return a 0 for unsigned and a 1 for signed.
        Throws:
        java.lang.IllegalArgumentException - If the string does not match the 'U' or 'S' characters.