jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Kuhn <har...@ontopia.net>
Subject Patch for MatchActionProcessor and character encodings
Date Mon, 24 Jun 2002 19:15:37 GMT
On Monday 24 June 2002 19:53, you wrote:
.....
> I think we need to keep
>   processMatches(InputStream, OutputStream);
> for backward compatibility in the short term, but maybe we should deprecate
> it?  If we don't want to deprecate it, then I favor adding
>   processMatches(InputStream, OutputStream, String encoding);
> I actually don't favor deprecating the InputStream/OutputStream method
> because it's a convenience.  In either case, we should add:
>   processMatches(Reader input, Writer output);
> processMatches(InputStream, OutputStream) can be implemented in terms
> of processMatches(InputStream, OutputStream, String) which can in turn
> be implemented by calling processMatches(Reader input, Writer output);

I added both methods as i could not see a reason not to. I also do not see a 
reason for deprecating the InputStream/OutputStream method because using the 
platform encoding is just fine most of the time, so i just added a line about 
the encoding  to the Javadoc. 

Harald



  /**
   * 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.
   * @param encoding The character encoding of the InputStreams source
   *           (see Suns JDK Javadoc for details on character encoding)
   * @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), 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
  {
    processMatches(new InputStreamReader(input), 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, OutputStream output)
       throws IOException
  {
    int patternCount, current;
    LineNumberReader reader = new LineNumberReader(input);
    PrintWriter writer    = new PrintWriter(output);
    MatchActionInfo info  = new MatchActionInfo();


--
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