diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/DataFormat.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/DataFormat.java index df2a36e4..f4f9714e 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/DataFormat.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/DataFormat.java @@ -9,7 +9,7 @@ package org.datagear.analysis.support; import java.io.Serializable; -import org.datagear.util.DateFormat; +import org.datagear.util.DateNumberFormat; /** * 数据格式。 @@ -17,66 +17,12 @@ import org.datagear.util.DateFormat; * @author datagear@163.com * */ -public class DataFormat extends DateFormat implements Serializable +public class DataFormat extends DateNumberFormat implements Serializable { private static final long serialVersionUID = 1L; - /** - * 默认数值格式:#.########## - */ - public static final String DEFAULT_NUMBER_FORMAT = "#.##########"; - - /** 数值格式 */ - private String numberFormat = DEFAULT_NUMBER_FORMAT; - public DataFormat() { super(); } - - public String getNumberFormat() - { - return numberFormat; - } - - public void setNumberFormat(String numberFormat) - { - this.numberFormat = numberFormat; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((numberFormat == null) ? 0 : numberFormat.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - DataFormat other = (DataFormat) obj; - if (numberFormat == null) - { - if (other.numberFormat != null) - return false; - } - else if (!numberFormat.equals(other.numberFormat)) - return false; - return true; - } - - @Override - public String toString() - { - return getClass().getSimpleName() + " [dateFormat=" + getDateFormat() + ", timeFormat=" + getTimeFormat() - + ", timestampFormat=" + getTimestampFormat() + ", numberFormat=" + numberFormat + "]"; - } } diff --git a/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DataFormat.java b/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DataFormat.java index 62106943..aa0dc9b8 100644 --- a/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DataFormat.java +++ b/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DataFormat.java @@ -10,7 +10,7 @@ package org.datagear.dataexchange; import java.io.Serializable; import java.util.Locale; -import org.datagear.util.DateFormat; +import org.datagear.util.DateNumberFormat; /** * 数据格式。 @@ -18,12 +18,10 @@ import org.datagear.util.DateFormat; * @author datagear@163.com * */ -public class DataFormat extends DateFormat implements Serializable +public class DataFormat extends DateNumberFormat implements Serializable { private static final long serialVersionUID = 1L; - public static final String DEFAULT_NUMBER_FORMAT = "#.######"; - public static final String BINARY_FORMAT_HEX = "Hex"; public static final String BINARY_FORMAT_BASE64 = "Base64"; @@ -33,9 +31,6 @@ public class DataFormat extends DateFormat implements Serializable /** 地区 */ private Locale locale = Locale.getDefault(); - /** 数值格式 */ - private String numberFormat = DEFAULT_NUMBER_FORMAT; - /** 二进制格式 */ private String binaryFormat = BINARY_FORMAT_HEX; @@ -52,7 +47,7 @@ public class DataFormat extends DateFormat implements Serializable setDateFormat(dateFormat); setTimeFormat(timeFormat); setTimestampFormat(timestampFormat); - this.numberFormat = numberFormat; + setNumberFormat(numberFormat); this.binaryFormat = binaryFormat; } @@ -66,16 +61,6 @@ public class DataFormat extends DateFormat implements Serializable this.locale = locale; } - public String getNumberFormat() - { - return numberFormat; - } - - public void setNumberFormat(String numberFormat) - { - this.numberFormat = numberFormat; - } - public String getBinaryFormat() { return binaryFormat; @@ -90,7 +75,8 @@ public class DataFormat extends DateFormat implements Serializable public String toString() { return getClass().getSimpleName() + " [dateFormat=" + getDateFormat() + ", timeFormat=" + getTimeFormat() - + ", timestampFormat=" + getTimestampFormat() + ", numberFormat=" + numberFormat + ", binaryFormat=" + + ", timestampFormat=" + getTimestampFormat() + ", numberFormat=" + getNumberFormat() + + ", binaryFormat=" + binaryFormat + "]"; } } diff --git a/datagear-util/src/main/java/org/datagear/util/DateNumberFormat.java b/datagear-util/src/main/java/org/datagear/util/DateNumberFormat.java new file mode 100644 index 00000000..e7de45a5 --- /dev/null +++ b/datagear-util/src/main/java/org/datagear/util/DateNumberFormat.java @@ -0,0 +1,78 @@ +/* + * Copyright 2018 datagear.tech + * + * Licensed under the LGPLv3 license: + * http://www.gnu.org/licenses/lgpl-3.0.html + */ + +package org.datagear.util; + +/** + * 日期、时间格式。 + * + * @author datagear@163.com + * + */ +public class DateNumberFormat extends DateFormat +{ + private static final long serialVersionUID = 1L; + + /** + * 默认数值格式:#.########## + */ + public static final String DEFAULT_NUMBER_FORMAT = "#.##########"; + + /** 数值格式 */ + private String numberFormat = DEFAULT_NUMBER_FORMAT; + + public DateNumberFormat() + { + super(); + } + + public String getNumberFormat() + { + return numberFormat; + } + + public void setNumberFormat(String numberFormat) + { + this.numberFormat = numberFormat; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((numberFormat == null) ? 0 : numberFormat.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + DateNumberFormat other = (DateNumberFormat) obj; + if (numberFormat == null) + { + if (other.numberFormat != null) + return false; + } + else if (!numberFormat.equals(other.numberFormat)) + return false; + return true; + } + + @Override + public String toString() + { + return getClass().getSimpleName() + " [dateFormat=" + getDateFormat() + ", timeFormat=" + getTimeFormat() + + ", timestampFormat=" + getTimestampFormat() + ", numberFormat=" + numberFormat + "]"; + } +}