View Javadoc
1   /*
2    * ObjectLab, http://www.objectlab.co.uk/open is supporting FlatPack.
3    *
4    * Based in London, we are world leaders in the design and development
5    * of bespoke applications for the securities financing markets.
6    *
7    * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8    *           ___  _     _           _   _          _
9    *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
10   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
11   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
12   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13   *                   |__/
14   *
15   *                     www.ObjectLab.co.uk
16   *
17   * $Id: ColorProvider.java 74 2006-10-24 22:19:05Z benoitx $
18   *
19   * Copyright 2006 the original author or authors.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22   * use this file except in compliance with the License. You may obtain a copy of
23   * the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations under
31   * the License.
32   */
33  package net.sf.flatpack.brparse;
34  
35  import net.sf.flatpack.AbstractParser;
36  import net.sf.flatpack.DefaultDataSet;
37  import net.sf.flatpack.Parser;
38  import net.sf.flatpack.ordering.OrderBy;
39  import net.sf.flatpack.structure.Row;
40  import net.sf.flatpack.util.FPException;
41  import net.sf.flatpack.xml.MetaData;
42  
43  /**
44   *
45   *
46   * @author Paul Zepernick
47   */
48  public class BuffReaderDataSet extends DefaultDataSet {
49      private final InterfaceBuffReaderParse brParser;
50      private int index = 0;
51  
52      /**
53       *
54       * @param columnMD2
55       * @param brParser
56       */
57      public BuffReaderDataSet(final MetaData columnMD2, final InterfaceBuffReaderParse brParser) {
58          super(columnMD2, (Parser) brParser);
59          // register the parser with the dataset so we can fetch rows from
60          // the bufferedreader as needed
61          this.brParser = brParser;
62      }
63  
64      @Override
65      public boolean next() {
66          if (brParser == null) {
67              // this should not happen, throw exception
68              throw new FPException("No parser available to fetch row");
69          }
70  
71          if (getMetaData() == null) {
72              setMetaData(((AbstractParser) brParser).getPzMetaData());
73          }
74  
75          clearRows();
76          final Row r = brParser.buildRow(this);
77          if (r != null) {
78              addRow(r);
79              index++;
80          }
81  
82          return super.next();
83      }
84  
85      /**
86       * Not Supported!
87       * @return boolean
88       */
89      @Override
90      public boolean previous() {
91          throw new UnsupportedOperationException("previous() is Not Implemented");
92      }
93  
94      /**
95       * Not Supported!
96       * @param ob - OrderBy object
97       * @see net.sf.flatpack.ordering.OrderBy
98       * @see net.sf.flatpack.ordering.OrderColumn
99       */
100     @Override
101     public void orderRows(final OrderBy ob) {
102         throw new UnsupportedOperationException("orderRows() is Not Implemented");
103     }
104 
105     /**
106      * Not Supported!
107      * @param localPointer - int
108      * @exception UnsupportedOperationException unsupported
109      */
110     @Override
111     public void absolute(final int localPointer) {
112         throw new UnsupportedOperationException("absolute() is Not Implemented");
113     }
114 
115     /**
116      *Not Supported!
117      */
118     @Override
119     public void remove() {
120         throw new UnsupportedOperationException("remove() is Not Implemented");
121     }
122 
123     /**
124      * @return int
125      */
126     @Override
127     public int getIndex() {
128         return index;
129     }
130 
131     /**
132      * Not Supported!
133      */
134     @Override
135     public void goBottom() {
136         throw new UnsupportedOperationException("goBottom() is Not Implemented");
137     }
138 
139     /**
140      * Not Supported!
141      */
142     @Override
143     public void goTop() {
144         throw new UnsupportedOperationException("goTop() is Not Implemented");
145     }
146 
147     /**
148      * Not Supported!
149      */
150     @Override
151     public void setValue(final String column, final String value) {
152         throw new UnsupportedOperationException("setValue() is Not Implemented");
153     }
154 
155     /**
156      * Not Supported!
157      */
158     @Override
159     public int getRowCount() {
160         throw new UnsupportedOperationException("getRowCount() is Not Implemented");
161     }
162 }