Skip to content

Commit

Permalink
closes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
printsev committed Apr 17, 2018
1 parent d38bef1 commit d921254
Show file tree
Hide file tree
Showing 13 changed files with 830 additions and 388 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/epam/parso/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Column {
/**
* The column format.
*/
private String format;
private ColumnFormat format;

/**
* The class of data stored in the cells of rows related to a column, can be Number.class or String.class.
Expand All @@ -64,7 +64,7 @@ public class Column {
* String.class.
* @param length the column length
*/
public Column(int id, String name, String label, String format, Class<?> type, int length) {
public Column(int id, String name, String label, ColumnFormat format, Class<?> type, int length) {
this.id = id;
this.name = name;
this.label = label;
Expand Down Expand Up @@ -96,7 +96,7 @@ public String getName() {
*
* @return the string that contains the column format.
*/
public String getFormat() {
public ColumnFormat getFormat() {
return format;
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public void setLabel(String label) {
* The function to set column format.
* @param format the column format.
*/
public void setFormat(String format) {
public void setFormat(ColumnFormat format) {
this.format = format;
}
}
106 changes: 106 additions & 0 deletions src/main/java/com/epam/parso/ColumnFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* *************************************************************************
* Copyright (C) 2015 EPAM
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *************************************************************************
*/

package com.epam.parso;

/**
* A class to store column format metadata.
*/
public class ColumnFormat {
/**
* The column format name.
*/
private String name;
/**
* The column format width.
*/
private int width;
/**
* The column format precision.
*/
private int precision;

/**
* The constructor that defines all parameters of the ColumnFormat class.
*
* @param name - column format name.
* @param width - olumn format width.
* @param precision - column format precision.
*/
public ColumnFormat(String name, int width, int precision) {
this.name = name;
this.width = width;
this.precision = precision;
}

/**
* The constructor that defines name of the ColumnFormat class.
*
* @param name - column format name.
*/
public ColumnFormat(String name) {
this.name = name;
}

/**
* The function to get {@link ColumnFormat#name}.
*
* @return the string that contains the column format name.
*/
public String getName() {
return name;
}

/**
* The function to get {@link ColumnFormat#width}.
*
* @return the number that contains the column format width.
*/
public int getWidth() {
return width;
}

/**
* The function to get {@link ColumnFormat#precision}.
*
* @return the number that contains the column format precision.
*/
public int getPrecision() {
return precision;
}

/**
* Returns true if there are no information about column format, otherwise false.
*
* @return true if column name is empty and width and precision are 0, otherwise false.
*/
public boolean isEmpty() {
return name.isEmpty() && width == 0 && precision == 0;
}

/**
* The function to ColumnFormat class string representation.
*
* @return string representation of the column format.
*/
@Override
public String toString() {
return isEmpty() ? "" : name + (width != 0 ? width : "") + "." + (precision != 0 ? precision : "");
}
}
Loading

0 comments on commit d921254

Please sign in to comment.