aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/ColumnBuilder.java31
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/DataType.java4
2 files changed, 31 insertions, 4 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/ColumnBuilder.java b/src/main/java/com/healthmarketscience/jackcess/ColumnBuilder.java
index bbfca27..f013e3b 100644
--- a/src/main/java/com/healthmarketscience/jackcess/ColumnBuilder.java
+++ b/src/main/java/com/healthmarketscience/jackcess/ColumnBuilder.java
@@ -130,6 +130,17 @@ public class ColumnBuilder {
}
/**
+ * Sets the precision for the new column to the max length for the type.
+ * Does nothing for types which do not have a precision.
+ */
+ public ColumnBuilder setMaxPrecision() {
+ if(_type.getHasScalePrecision()) {
+ setPrecision(_type.getMaxPrecision());
+ }
+ return this;
+ }
+
+ /**
* Sets the scale for the new column.
*/
public ColumnBuilder setScale(int newScale) {
@@ -142,6 +153,17 @@ public class ColumnBuilder {
}
/**
+ * Sets the scale for the new column to the max length for the type. Does
+ * nothing for types which do not have a scale.
+ */
+ public ColumnBuilder setMaxScale() {
+ if(_type.getHasScalePrecision()) {
+ setScale(_type.getMaxScale());
+ }
+ return this;
+ }
+
+ /**
* Sets the length (in bytes) for the new column.
*/
public ColumnBuilder setLength(int length) {
@@ -163,10 +185,15 @@ public class ColumnBuilder {
}
/**
- * Sets the length for the new column to the max length for the type.
+ * Sets the length for the new column to the max length for the type. Does
+ * nothing for types which are not variable length.
*/
public ColumnBuilder setMaxLength() {
- return setLength(_type.getMaxSize());
+ // length setting only makes sense for variable length columns
+ if(_type.isVariableLength()) {
+ setLength(_type.getMaxSize());
+ }
+ return this;
}
/**
diff --git a/src/main/java/com/healthmarketscience/jackcess/DataType.java b/src/main/java/com/healthmarketscience/jackcess/DataType.java
index ffd5bf4..ad6deaf 100644
--- a/src/main/java/com/healthmarketscience/jackcess/DataType.java
+++ b/src/main/java/com/healthmarketscience/jackcess/DataType.java
@@ -114,8 +114,8 @@ public enum DataType {
* null}. Equivalent to SQL {@link Types#VARCHAR}, {@link Types#CHAR}.
*/
TEXT((byte) 0x0A, Types.VARCHAR, null, true, false, 0,
- 50 * JetFormat.TEXT_FIELD_UNIT_SIZE,
- JetFormat.TEXT_FIELD_MAX_LENGTH, JetFormat.TEXT_FIELD_UNIT_SIZE),
+ JetFormat.TEXT_FIELD_MAX_LENGTH, JetFormat.TEXT_FIELD_MAX_LENGTH,
+ JetFormat.TEXT_FIELD_UNIT_SIZE),
/**
* Corresponds to a java {@code byte[]} of max length 16777215 bytes.
* Accepts a {@code byte[]}, or {@code null}. Equivalent to SQL