Class PDAX2MDAG.GrepCallback

  • All Implemented Interfaces:
    StreamGobblerCallback
    Enclosing class:
    PDAX2MDAG

    private class PDAX2MDAG.GrepCallback
    extends java.lang.Object
    implements StreamGobblerCallback
    An inner class, that implements the StreamGobblerCallback to count the occurences of a word in a document.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int mCount
      The number of times the word appears.
      private java.lang.String mWord
      The word that is to be searched for.
      private int mWordLength
      The length of the word to be searched for.
    • Constructor Summary

      Constructors 
      Constructor Description
      GrepCallback​(java.lang.String word)
      Overloaded Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCount()
      Returns the number of words counted so far.
      void reset()
      Resets the internal counters.
      void work​(java.lang.String line)
      Callback whenever a line is read from the stream by the StreamGobbler.
      • Methods inherited from class java.lang.Object

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

      • mWord

        private java.lang.String mWord
        The word that is to be searched for.
      • mWordLength

        private int mWordLength
        The length of the word to be searched for.
      • mCount

        private int mCount
        The number of times the word appears.
    • Constructor Detail

      • GrepCallback

        public GrepCallback​(java.lang.String word)
        Overloaded Constructor.
        Parameters:
        word - the word to be searched for.
    • Method Detail

      • work

        public void work​(java.lang.String line)
        Callback whenever a line is read from the stream by the StreamGobbler. Counts the occurences of the word that are in the line, and increments to the global counter.
        Specified by:
        work in interface StreamGobblerCallback
        Parameters:
        line - the line that is read.
      • getCount

        public int getCount()
        Returns the number of words counted so far.
        Returns:
        the number of words
      • reset

        public void reset()
        Resets the internal counters.