View Javadoc

1   package org.apache.turbine.util;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.Reader;
20  
21  import java.util.List;
22  
23  /***
24   * TSVParser is used to parse a stream with tab-separated values and
25   * generate ParameterParser objects which can be used to
26   * extract the values in the desired type.
27   *
28   * <p>The class extends the abstract class DataStreamParser and implements
29   * initTokenizer with suitable values for TSV files to provide this
30   * functionality.
31   *
32   * <p>The class (indirectly through DataStreamParser) implements the
33   * java.util.Iterator interface for convenience.
34   * This allows simple use in a Velocity template for example:
35   *
36   * <pre>
37   * #foreach ($row in $tsvfile)
38   *   Name: $row.Name
39   *   Description: $row.Description
40   * #end
41   * </pre>
42   *
43   * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
44   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
45   * @version $Id: TSVParser.java 264148 2005-08-29 14:21:04Z henning $
46   * @deprecated Use org.apache.turbine.util.parser.TSVParser instead.
47   */
48  public class TSVParser
49          extends org.apache.turbine.util.parser.TSVParser
50  {
51      /***
52       * Create a new TSVParser instance. Requires a Reader to read the
53       * tab-separated values from. The column headers must be set
54       * independently either explicitly, or by reading the first line
55       * of the TSV values.
56       *
57       * @param in the input reader.
58       */
59      public TSVParser(Reader in)
60      {
61          super(in, null, null);
62      }
63  
64      /***
65       * Create a new TSVParser instance. Requires a Reader to read the
66       * tab-separated values from, and a list of column names.
67       *
68       * @param in the input reader.
69       * @param columnNames a list of column names.
70       */
71      public TSVParser(Reader in, List columnNames)
72      {
73          super(in, columnNames, null);
74      }
75  
76      /***
77       * Create a new TSVParser instance. Requires a Reader to read the
78       * tab-separated values from, a list of column names and a
79       * character encoding.
80       *
81       * @param in the input reader.
82       * @param columnNames a list of column names.
83       * @param characterEncoding the character encoding of the input.
84       */
85      public TSVParser(Reader in, List columnNames, String characterEncoding)
86      {
87          super(in, columnNames, characterEncoding);
88      }
89  }