jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-oro/src/java/org/apache/oro/text MatchActionProcessor.java
Date Thu, 27 Jun 2002 22:23:51 GMT
dfs         2002/06/27 15:23:51

  Modified:    src/java/org/apache/oro/text MatchActionProcessor.java
  Log:
  Changed processMatches to take Reader and Writer arguments.  Reimplemented
  old method in terms of new method.  Added a version of old method that
  allows you to specify input encoding.  Changes suggested by Harald Kuhn.
  
  Revision  Changes    Path
  1.6       +73 -5     jakarta-oro/src/java/org/apache/oro/text/MatchActionProcessor.java
  
  Index: MatchActionProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/MatchActionProcessor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MatchActionProcessor.java	13 Jun 2001 01:45:09 -0000	1.5
  +++ MatchActionProcessor.java	27 Jun 2002 22:23:51 -0000	1.6
  @@ -281,7 +281,7 @@
      * This method reads the provided input one line at a time and for
      * every registered pattern that is contained in the line it executes
      * the associated MatchAction's processMatch() method.  If a field
  -   * separator has been defined with 
  +   * separator has been defined with
      * {@link #setFieldSeparator setFieldSeparator()}, the
      * fields member of the MatchActionInfo instance passed to the
      * processMatch() method is set to a Vector of Strings containing
  @@ -297,15 +297,83 @@
      * @see MatchActionInfo
      * @param input  The input stream from which to read lines.
      * @param output Where to send output.
  +   * @param encoding The character encoding of the InputStream source.
  +   *           If you also want to define an output character encoding,
  +   *           you should use {@link #processMatches(Reader, Writer)}
  +   *           and specify the encodings when creating the Reader and
  +   *           Writer sources and sinks.
  +   * @exception IOException  If an error occurs while reading input
  +   *            or writing output.
  +   */
  +  public void processMatches(InputStream input, OutputStream output,
  +			     String encoding)
  +    throws IOException
  +  {
  +    processMatches(new InputStreamReader(input, encoding),
  +		   new OutputStreamWriter(output));
  +  }
  +
  +
  +  /**
  +   * This method reads the provided input one line at a time using the
  +   * platform standart character encoding and for every registered
  +   * pattern that is contained in the line it executes the associated
  +   * MatchAction's processMatch() method.  If a field separator has been
  +   * defined with {@link #setFieldSeparator setFieldSeparator()}, the
  +   * fields member of the MatchActionInfo instance passed to the
  +   * processMatch() method is set to a Vector of Strings containing
  +   * the split fields of the line.  Otherwise the fields member is set
  +   * to null.  If no match was performed to invoke the action (i.e.,
  +   * a null pattern was registered), then the match member is set
  +   * to null.  Otherwise, the match member will contain the result of
  +   * the match.
  +   *
  +   * <p>
  +   * The input stream, having been exhausted, is closed right before the
  +   * method terminates and the output stream is flushed.
  +   * <p>
  +   *
  +   * @see MatchActionInfo
  +   * @param input  The input stream from which to read lines.
  +   * @param output Where to send output.
      * @exception IOException  If an error occurs while reading input
      *            or writing output.
      */
     public void processMatches(InputStream input, OutputStream output)
  -       throws IOException
  +    throws IOException
  +  {
  +    processMatches(new InputStreamReader(input),
  +		   new OutputStreamWriter(output));
  +  }
  +
  +  /**
  +   * This method reads the provided input one line at a time and for
  +   * every registered pattern that is contained in the line it executes
  +   * the associated MatchAction's processMatch() method.  If a field
  +   * separator has been defined with
  +   * {@link #setFieldSeparator setFieldSeparator()}, the
  +   * fields member of the MatchActionInfo instance passed to the
  +   * processMatch() method is set to a Vector of Strings containing
  +   * the split fields of the line.  Otherwise the fields member is set
  +   * to null.  If no match was performed to invoke the action (i.e.,
  +   * a null pattern was registered), then the match member is set
  +   * to null.  Otherwise, the match member will contain the result of
  +   * the match.
  +   * <p>
  +   * The input stream, having been exhausted, is closed right before the
  +   * method terminates and the output stream is flushed.
  +   * <p>
  +   * @see MatchActionInfo
  +   * @param input  The input stream from which to read lines.
  +   * @param output Where to send output.
  +   * @exception IOException  If an error occurs while reading input
  +   *            or writing output.
  +   */
  +  public void processMatches(Reader input, Writer output)
  +    throws IOException
     {
       int patternCount, current;
  -    LineNumberReader reader =
  -      new LineNumberReader(new InputStreamReader(input));
  +    LineNumberReader reader = new LineNumberReader(input);
       PrintWriter writer    = new PrintWriter(output);
       MatchActionInfo info  = new MatchActionInfo();
       Object obj;
  
  
  

--
To unsubscribe, e-mail:   <mailto:oro-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:oro-dev-help@jakarta.apache.org>


Mime
View raw message