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;
34
35 /**
36 * This class holds errors that occurred while parsing or processing a data file.
37 *
38 * @author Paul Zepernick
39 * @version 2.0
40 */
41 public class DataError {
42 private final String errorDesc;
43 private final int lineNo;
44 private final int errorLevel;
45 private final String rawData;
46 private final String lastColumnName;
47 private final String lastColumnValue;
48
49 /**
50 *
51 * @param errorDesc
52 * Text description of the error that occurred
53 * @param lineNo
54 * Line number in the data file the error occurred on
55 * @param errorLevel
56 * Level of the error (1=warning, 2=moderate, 3=severe)
57 */
58 public DataError(final String errorDesc, final int lineNo, final int errorLevel) {
59 this(errorDesc, lineNo, errorLevel, null, null, null);
60 }
61
62 /**
63 *
64 * @param errorDesc
65 * Text description of the error that occurred
66 * @param lineNo
67 * Line number in the data file the error occurred on
68 * @param errorLevel
69 * Level of the error (1=warning, 2=moderate, 3=severe)
70 * @param rawData
71 * String of data which the parse failed on
72 */
73 public DataError(final String errorDesc, final int lineNo, final int errorLevel, final String rawData) {
74 this(errorDesc, lineNo, errorLevel, rawData, null, null);
75 }
76
77 /**
78 *
79 * @param errorDesc
80 * Text description of the error that occurred
81 * @param lineNo
82 * Line number in the data file the error occurred on
83 * @param errorLevel
84 * Level of the error (1=warning, 2=moderate, 3=severe)
85 * @param rawData
86 * String of data which the parse failed on
87 */
88 public DataError(final String errorDesc, final int lineNo, final int errorLevel, final String rawData, final String lastColumnName,
89 final String lastColumnValue) {
90 this.errorDesc = errorDesc;
91 this.lineNo = lineNo;
92 this.errorLevel = errorLevel;
93 this.rawData = rawData;
94 this.lastColumnName = lastColumnName;
95 this.lastColumnValue = lastColumnValue;
96 }
97
98 /**
99 * Returns the errorDesc.
100 *
101 * @return String
102 */
103 public String getErrorDesc() {
104 return errorDesc;
105 }
106
107 /**
108 * Returns the errorLevel.
109 *
110 * @return int
111 */
112 public int getErrorLevel() {
113 return errorLevel;
114 }
115
116 /**
117 * Returns the lineNo.
118 *
119 * @return int
120 */
121 public int getLineNo() {
122 return lineNo;
123 }
124
125 @Override
126 public String toString() {
127 final StringBuilder buf = new StringBuilder();
128 buf.append("Line:").append(lineNo).append(" Level:").append(errorLevel).append(" Desc:").append(errorDesc)
129 .append(System.getProperty("line.separator"));
130 if (rawData != null) {
131 buf.append("RawData:").append(rawData).append(System.lineSeparator());
132 }
133 if (lastColumnName != null) {
134 buf.append("LastColName:").append(lastColumnName).append(" Value:").append(lastColumnValue).append(System.lineSeparator());
135 }
136 return buf.toString();
137 }
138
139 public String getLastColumnName() {
140 return lastColumnName;
141 }
142
143 public String getLastColumnValue() {
144 return lastColumnValue;
145 }
146
147 /**
148 * Option must be set on parser, otherwise this is
149 * null by default
150 *
151 * @return the rawData
152 */
153 public String getRawData() {
154 return rawData;
155 }
156 }