* @author Tim McCune
* @usage _intermediate_class_
*/
-public class ColumnImpl implements Column, Comparable<ColumnImpl> {
+public class ColumnImpl implements Column, Comparable<ColumnImpl>, ZoneContext
+{
protected static final Log LOG = LogFactory.getLog(ColumnImpl.class);
// base does nothing
}
+ @Override
public TableImpl getTable() {
return _table;
}
+ @Override
public DatabaseImpl getDatabase() {
return getTable().getDatabase();
}
return getDatabase().getPageChannel();
}
+ @Override
public String getName() {
return _name;
}
+ @Override
public boolean isVariableLength() {
return _variableLength;
}
+ @Override
public boolean isAutoNumber() {
return _autoNumber;
}
return _columnNumber;
}
+ @Override
public int getColumnIndex() {
return _columnIndex;
}
return _displayIndex;
}
+ @Override
public DataType getType() {
return _type;
}
+ @Override
public int getSQLType() throws SQLException {
return _type.getSQLType();
}
+ @Override
public boolean isCompressedUnicode() {
return false;
}
+ @Override
public byte getPrecision() {
return (byte)getType().getDefaultPrecision();
}
+ @Override
public byte getScale() {
return (byte)getType().getDefaultScale();
}
return 0;
}
+ @Override
public short getLength() {
return _columnLength;
}
+ @Override
public short getLengthInUnits() {
return (short)getType().toUnitSize(getLength());
}
+ @Override
public boolean isCalculated() {
return _calculated;
}
return getDatabase().getCharset();
}
- protected TimeZone getTimeZone() {
+ @Override
+ public TimeZone getTimeZone() {
return getDatabase().getTimeZone();
}
- protected ZoneId getZoneId() {
+ @Override
+ public ZoneId getZoneId() {
return getDatabase().getZoneId();
}
return getDatabase().getDateTimeFactory();
}
+ @Override
public boolean isAppendOnly() {
return (getVersionHistoryColumn() != null);
}
+ @Override
public ColumnImpl getVersionHistoryColumn() {
return null;
}
throw new UnsupportedOperationException();
}
+ @Override
public boolean isHyperlink() {
return false;
}
+ @Override
public ComplexColumnInfo<? extends ComplexValue> getComplexInfo() {
return null;
}
reloadPropertiesValidators();
}
+ @Override
public ColumnValidator getColumnValidator() {
// unwrap any "internal" validator
return ((_validator instanceof InternalColumnValidator) ?
((InternalColumnValidator)_validator).getExternal() : _validator);
}
+ @Override
public void setColumnValidator(ColumnValidator newValidator) {
if(isAutoNumber()) {
return _autoNumberGenerator;
}
+ @Override
public PropertyMap getProperties() throws IOException {
if(_props == null) {
_props = getTable().getPropertyMaps().get(getName());
return _props;
}
+ @Override
public Object setRowValue(Object[] rowArray, Object value) {
rowArray[_columnIndex] = value;
return value;
}
+ @Override
public Object setRowValue(Map<String,Object> rowMap, Object value) {
rowMap.put(_name, value);
return value;
}
+ @Override
public Object getRowValue(Object[] rowArray) {
return rowArray[_columnIndex];
}
+ @Override
public Object getRowValue(Map<String,?> rowMap) {
return rowMap.get(_name);
}
throws InvalidValueException
{
try {
- return toDateDouble(value, getTimeZone(), getZoneId());
+ return toDateDouble(value, this);
} catch(IllegalArgumentException iae) {
throw new InvalidValueException(withErrorContext(iae.getMessage()), iae);
}
}
- /**
- * Returns an access date double converted from a java Date/Calendar/Number
- * time value.
- * @usage _advanced_method_
- */
- private static double toDateDouble(Object value, DatabaseImpl db)
- {
- return toDateDouble(value, db.getTimeZone(), db.getZoneId());
- }
-
/**
* Returns an access date double converted from a java
* Date/Calendar/Number/Temporal time value.
* @usage _advanced_method_
*/
- private static double toDateDouble(Object value, TimeZone tz, ZoneId zoneId)
+ private static double toDateDouble(Object value, ZoneContext zc)
{
if(value instanceof TemporalAccessor) {
- return toDateDouble(
- toLocalDateTime((TemporalAccessor)value, tz, zoneId));
+ return toDateDouble(toLocalDateTime((TemporalAccessor)value, zc));
}
// seems access stores dates in the local timezone. guess you just
// hope you read it in the same timezone in which it was written!
long time = toDateLong(value);
- time += getToLocalTimeZoneOffset(time, tz);
+ time += getToLocalTimeZoneOffset(time, zc.getTimeZone());
return toLocalDateDouble(time);
}
private static LocalDateTime toLocalDateTime(
- TemporalAccessor value, TimeZone tz, ZoneId zoneId) {
+ TemporalAccessor value, ZoneContext zc) {
// handle some common Temporal types
if(value instanceof LocalDateTime) {
if(value instanceof ZonedDateTime) {
// if the temporal value has a timezone, convert it to this db's timezone
return ((ZonedDateTime)value).withZoneSameInstant(
- getZoneId(tz, zoneId)).toLocalDateTime();
+ zc.getZoneId()).toLocalDateTime();
}
if(value instanceof Instant) {
- return LocalDateTime.ofInstant((Instant)value, getZoneId(tz, zoneId));
+ return LocalDateTime.ofInstant((Instant)value, zc.getZoneId());
}
if(value instanceof LocalDate) {
return ((LocalDate)value).atTime(BASE_LT);
if(zone != null) {
// the Temporal has a zone, see if it is the right zone. if not,
// adjust it
- zoneId = getZoneId(tz, zoneId);
+ ZoneId zoneId = zc.getZoneId();
if(!zoneId.equals(zone)) {
return ZonedDateTime.of(ld, lt, zone).withZoneSameInstant(zoneId)
.toLocalDateTime();
}
}
- private static ZoneId getZoneId(TimeZone tz, ZoneId zoneId) {
- return ((zoneId != null) ? zoneId : tz.toZoneId());
- }
-
static double toLocalDateDouble(long time) {
time += MILLIS_BETWEEN_EPOCH_AND_1900;
* Orders Columns by column number.
* @usage _general_method_
*/
+ @Override
public int compareTo(ColumnImpl other) {
if (_columnNumber > other.getColumnNumber()) {
return 1;
@Override
public Object toInternalValue(DatabaseImpl db, Object value) {
if(value instanceof TemporalAccessor) {
- return toLocalDateTime((TemporalAccessor)value, null, db.getZoneId());
+ return toLocalDateTime((TemporalAccessor)value, db);
}
Instant inst = Instant.ofEpochMilli(toDateLong(value));
return LocalDateTime.ofInstant(inst, db.getZoneId());