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.structure;
34
35 import java.util.ArrayList;
36 import java.util.List;
37
38 /**
39 * This holds a collection of columns and their values along with the actual
40 * row number they appear in the flat file
41 *
42 * @author Paul Zepernick
43 */
44 public class Row {
45 /** List to hold all columns that exist in the row */
46 private List<String> cols = new ArrayList<>();
47
48 /** Row number in flat file */
49 private int rowNumber;
50
51 /** key to the MD for this row, null will indicate it is "detail" MD */
52 private String mdkey;
53
54 private boolean empty;
55
56 private String rawData;
57
58 /**
59 * Adds a column to a row
60 *
61 * @param colValue -
62 * String value to add to the row
63 */
64 public void addColumn(final String colValue) {
65 cols.add(colValue);
66 }
67
68 /**
69 * Appends the List of Strings to the existing columns in the row
70 *
71 * @param columns -
72 * List of Strings to append to the row
73 */
74 public void addColumn(final List<String> columns) {
75 cols.addAll(columns);
76 }
77
78 /**
79 * Returns the value of a column for a specified column name
80 *
81 * @param colPosition -
82 * int position of the column in the array
83 * @return String value of column
84 */
85 public String getValue(final int colPosition) {
86 return cols.get(colPosition);
87 }
88
89 /**
90 * Set the value of a column for a specified column name
91 *
92 * @param columnIndex -
93 * column number to change
94 * @param value -
95 * String column value
96 */
97 public void setValue(final int columnIndex, final String value) {
98 cols.set(columnIndex, value);
99 }
100
101 /**
102 * Returns the rowNumber.
103 *
104 * @return int
105 */
106 public int getRowNumber() {
107 return rowNumber;
108 }
109
110 /**
111 * Sets the rowNumber.
112 *
113 * @param rowNumber
114 * The rowNumber to set
115 */
116 public void setRowNumber(final int rowNumber) {
117 this.rowNumber = rowNumber;
118 }
119
120 /**
121 * Returns the cols for the row.
122 *
123 * @return Vector
124 */
125 public List<String> getCols() {
126 return cols;
127 }
128
129 /**
130 * Set the columns for the row.
131 *
132 * @param cols -
133 * Vector of Strings
134 */
135 public void setCols(final List<String> cols) {
136 this.cols = cols;
137 }
138
139 /**
140 * @return Returns the mdkey.
141 */
142 public String getMdkey() {
143 return mdkey;
144 }
145
146 /**
147 * @param mdkey
148 * The mdkey to set.
149 */
150 public void setMdkey(final String mdkey) {
151 this.mdkey = mdkey;
152 }
153
154 /**
155 * All columns in the row are empty
156 *
157 * @return the empty
158 */
159 public boolean isEmpty() {
160 return empty;
161 }
162
163 /**
164 * When true, all columns in the row are empty
165 *
166 * @param empty the empty to set
167 */
168 public void setEmpty(final boolean empty) {
169 this.empty = empty;
170 }
171
172 /**
173 * Raw data used to create the columns for the row
174 *
175 * @return the rawData
176 */
177 public String getRawData() {
178 return rawData;
179 }
180
181 /**
182 * Raw data used to create the columns for the row
183 *
184 * @param rawData the rawData to set
185 */
186 public void setRawData(final String rawData) {
187 this.rawData = rawData;
188 }
189 }