Class AreaCodeTableMaker


  • public class AreaCodeTableMaker
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.json.JSONObject areaCodeTable  
      protected static int current  
      protected static java.util.ArrayList<java.lang.String> finalStates  
      protected static boolean generateGeoTable  
      protected static int inputChars  
      protected static org.apache.log4j.Logger logger  
      protected static java.util.HashMap<java.lang.String,​java.lang.Integer> reverseFinalStates  
      protected static java.util.HashMap<java.lang.String,​java.lang.Integer> reverseStateMap  
      protected static java.util.ArrayList<java.lang.String> stateMap  
      protected static java.util.ArrayList<java.lang.String> stringsToLocalize  
      protected static java.util.HashMap<java.lang.String,​FixedArray> table  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.Integer getFinalState​(java.lang.String name)
      Return the numerical number identifying the given final state in a transitions table.
      protected static int getIndex​(char ch)
      Return the index into a transitions table for a given character.
      protected static java.lang.Integer getState​(java.lang.String name)
      Return the index into the state table of the given state name.
      protected static FixedArray getTransitions​(java.lang.String state)
      Return the transitions table for the given state.
      protected static void initStates()  
      static void main​(java.lang.String[] args)  
      protected static void processLine​(java.lang.String line)
      Each line should be of the form: number final_state \n Each line is parsed into the number and the final state.
      protected static void usage()  
      protected static void writeOutput​(java.io.PrintStream out, java.lang.String name)
      Write out a state table in javascript format.
      • Methods inherited from class java.lang.Object

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

      • logger

        protected static org.apache.log4j.Logger logger
      • table

        protected static java.util.HashMap<java.lang.String,​FixedArray> table
      • current

        protected static int current
      • stateMap

        protected static java.util.ArrayList<java.lang.String> stateMap
      • reverseStateMap

        protected static java.util.HashMap<java.lang.String,​java.lang.Integer> reverseStateMap
      • finalStates

        protected static java.util.ArrayList<java.lang.String> finalStates
      • reverseFinalStates

        protected static java.util.HashMap<java.lang.String,​java.lang.Integer> reverseFinalStates
      • areaCodeTable

        protected static org.json.JSONObject areaCodeTable
      • generateGeoTable

        protected static boolean generateGeoTable
      • stringsToLocalize

        protected static java.util.ArrayList<java.lang.String> stringsToLocalize
    • Constructor Detail

      • AreaCodeTableMaker

        public AreaCodeTableMaker()
    • Method Detail

      • initStates

        protected static void initStates()
      • getIndex

        protected static int getIndex​(char ch)
        Return the index into a transitions table for a given character. If the character is not a valid phone number char, returns -1.
        Parameters:
        ch -
        Returns:
        index of passed character
      • getState

        protected static java.lang.Integer getState​(java.lang.String name)
        Return the index into the state table of the given state name.
        Parameters:
        name -
        Returns:
        state of name
      • getFinalState

        protected static java.lang.Integer getFinalState​(java.lang.String name)
        Return the numerical number identifying the given final state in a transitions table.
        Parameters:
        name -
        Returns:
        final state of name
      • getTransitions

        protected static FixedArray getTransitions​(java.lang.String state)
        Return the transitions table for the given state. The state is a partial prefix of the phone number.
        Parameters:
        state -
        Returns:
        transitions for current state
      • processLine

        protected static void processLine​(java.lang.String line)
        Each line should be of the form: number final_state \n Each line is parsed into the number and the final state. From the number, a states table is built up as a set of transition tables. A transition table specifies that given a particular prefix and a new character to add to the end of the prefix, here is the next state to go to next. A number on the line is parsed for progressive prefixes and next chars until the whole number is used up. At that point, the transition table gets an entry for the given final state. Example: line is "4321 area" First round: state "begin", next char "4" -> goes to the table for the prefix "4" Second round: state is "4", next char "3" -> goes to the table for the prefix "43" Third round: state is "43", next char "2" -> goes to the table for the prefix "432" Fourth round: state is "432", next char "1" -> last char, so the entry for "1" in the transitions table for state "432" is given the numerical code for final state "area"(-7)
        Parameters:
        line -
      • writeOutput

        protected static void writeOutput​(java.io.PrintStream out,
                                          java.lang.String name)
        Write out a state table in javascript format.
        Parameters:
        out -
        name -
      • usage

        protected static void usage()
      • main

        public static void main​(java.lang.String[] args)
        Parameters:
        args -