Skip to content

Commit d921254

Browse files
committed
closes #22
1 parent d38bef1 commit d921254

13 files changed

+830
-388
lines changed

src/main/java/com/epam/parso/Column.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Column {
4141
/**
4242
* The column format.
4343
*/
44-
private String format;
44+
private ColumnFormat format;
4545

4646
/**
4747
* The class of data stored in the cells of rows related to a column, can be Number.class or String.class.
@@ -64,7 +64,7 @@ public class Column {
6464
* String.class.
6565
* @param length the column length
6666
*/
67-
public Column(int id, String name, String label, String format, Class<?> type, int length) {
67+
public Column(int id, String name, String label, ColumnFormat format, Class<?> type, int length) {
6868
this.id = id;
6969
this.name = name;
7070
this.label = label;
@@ -96,7 +96,7 @@ public String getName() {
9696
*
9797
* @return the string that contains the column format.
9898
*/
99-
public String getFormat() {
99+
public ColumnFormat getFormat() {
100100
return format;
101101
}
102102

@@ -147,7 +147,7 @@ public void setLabel(String label) {
147147
* The function to set column format.
148148
* @param format the column format.
149149
*/
150-
public void setFormat(String format) {
150+
public void setFormat(ColumnFormat format) {
151151
this.format = format;
152152
}
153153
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* *************************************************************************
3+
* Copyright (C) 2015 EPAM
4+
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* *************************************************************************
18+
*/
19+
20+
package com.epam.parso;
21+
22+
/**
23+
* A class to store column format metadata.
24+
*/
25+
public class ColumnFormat {
26+
/**
27+
* The column format name.
28+
*/
29+
private String name;
30+
/**
31+
* The column format width.
32+
*/
33+
private int width;
34+
/**
35+
* The column format precision.
36+
*/
37+
private int precision;
38+
39+
/**
40+
* The constructor that defines all parameters of the ColumnFormat class.
41+
*
42+
* @param name - column format name.
43+
* @param width - olumn format width.
44+
* @param precision - column format precision.
45+
*/
46+
public ColumnFormat(String name, int width, int precision) {
47+
this.name = name;
48+
this.width = width;
49+
this.precision = precision;
50+
}
51+
52+
/**
53+
* The constructor that defines name of the ColumnFormat class.
54+
*
55+
* @param name - column format name.
56+
*/
57+
public ColumnFormat(String name) {
58+
this.name = name;
59+
}
60+
61+
/**
62+
* The function to get {@link ColumnFormat#name}.
63+
*
64+
* @return the string that contains the column format name.
65+
*/
66+
public String getName() {
67+
return name;
68+
}
69+
70+
/**
71+
* The function to get {@link ColumnFormat#width}.
72+
*
73+
* @return the number that contains the column format width.
74+
*/
75+
public int getWidth() {
76+
return width;
77+
}
78+
79+
/**
80+
* The function to get {@link ColumnFormat#precision}.
81+
*
82+
* @return the number that contains the column format precision.
83+
*/
84+
public int getPrecision() {
85+
return precision;
86+
}
87+
88+
/**
89+
* Returns true if there are no information about column format, otherwise false.
90+
*
91+
* @return true if column name is empty and width and precision are 0, otherwise false.
92+
*/
93+
public boolean isEmpty() {
94+
return name.isEmpty() && width == 0 && precision == 0;
95+
}
96+
97+
/**
98+
* The function to ColumnFormat class string representation.
99+
*
100+
* @return string representation of the column format.
101+
*/
102+
@Override
103+
public String toString() {
104+
return isEmpty() ? "" : name + (width != 0 ? width : "") + "." + (precision != 0 ? precision : "");
105+
}
106+
}

0 commit comments

Comments
 (0)