diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-12-31 21:17:29 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-12-31 21:17:29 +0000 |
commit | 86ae9b01032bee4c2a47bb5428e9777efbc22c71 (patch) | |
tree | d2294b2d41ce7a2735ebf2cc8f31b2b3cc4ac636 /src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java | |
parent | 55531bcd0502dde1fea00957a1b4ec3f32b1e7f8 (diff) | |
parent | c25109f67386c6d5b5c7875cd6f82d9191b2751c (diff) | |
download | jackcess-86ae9b01032bee4c2a47bb5428e9777efbc22c71.tar.gz jackcess-86ae9b01032bee4c2a47bb5428e9777efbc22c71.zip |
merge trunk changes through r1258
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jdk8@1259 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 4172874..212b912 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -186,6 +186,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte /** auto numbers must be > 0 */ static final int INVALID_AUTO_NUMBER = 0; + static final int INVALID_LENGTH = -1; + /** owning table */ private final TableImpl _table; @@ -219,6 +221,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte private ColumnValidator _validator = SimpleColumnValidator.INSTANCE; /** default value generator */ private ColDefaultValueEvalContext _defValue; + /** length of the column in units, lazily computed */ + private int _lengthInUnits = INVALID_LENGTH; /** * @usage _advanced_method_ @@ -469,8 +473,15 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte } @Override - public short getLengthInUnits() { - return (short)getType().toUnitSize(getLength()); + public final short getLengthInUnits() { + if(_lengthInUnits == INVALID_LENGTH) { + _lengthInUnits = calcLengthInUnits(); + } + return (short)_lengthInUnits; + } + + protected int calcLengthInUnits() { + return getType().toUnitSize(getLength(), getFormat()); } @Override |