com.healthmarketscience.jackcess.impl.complex.UnsupportedColumnInfoImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackcess Show documentation
Show all versions of jackcess Show documentation
A pure Java library for reading from and writing to MS Access databases.
/*
Copyright (c) 2011 James Ahlborn
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.healthmarketscience.jackcess.impl.complex;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.complex.ComplexDataType;
import com.healthmarketscience.jackcess.complex.ComplexValue;
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
import com.healthmarketscience.jackcess.complex.UnsupportedColumnInfo;
import com.healthmarketscience.jackcess.complex.UnsupportedValue;
/**
* Complex column info for an unsupported complex type.
*
* @author James Ahlborn
*/
public class UnsupportedColumnInfoImpl
extends ComplexColumnInfoImpl
implements UnsupportedColumnInfo
{
public UnsupportedColumnInfoImpl(Column column, int complexId,
Table typeObjTable, Table flatTable)
throws IOException
{
super(column, complexId, typeObjTable, flatTable);
}
public List getValueColumns() {
return getTypeColumns();
}
@Override
public ComplexDataType getType()
{
return ComplexDataType.UNSUPPORTED;
}
@Override
protected UnsupportedValueImpl toValue(
ComplexValueForeignKey complexValueFk,
Row rawValue)
{
ComplexValue.Id id = getValueId(rawValue);
Map values = new LinkedHashMap();
for(Column col : getValueColumns()) {
col.setRowValue(values, col.getRowValue(rawValue));
}
return new UnsupportedValueImpl(id, complexValueFk, values);
}
@Override
protected Object[] asRow(Object[] row, UnsupportedValue value)
throws IOException
{
super.asRow(row, value);
Map values = value.getValues();
for(Column col : getValueColumns()) {
col.setRowValue(row, col.getRowValue(values));
}
return row;
}
public static UnsupportedValue newValue(Map values) {
return newValue(INVALID_FK, values);
}
public static UnsupportedValue newValue(
ComplexValueForeignKey complexValueFk, Map values) {
return new UnsupportedValueImpl(INVALID_ID, complexValueFk,
new LinkedHashMap(values));
}
private static class UnsupportedValueImpl extends ComplexValueImpl
implements UnsupportedValue
{
private Map _values;
private UnsupportedValueImpl(Id id, ComplexValueForeignKey complexValueFk,
Map values)
{
super(id, complexValueFk);
_values = values;
}
public Map getValues() {
return _values;
}
public Object get(String columnName) {
return getValues().get(columnName);
}
public void set(String columnName, Object value) {
getValues().put(columnName, value);
}
public void update() throws IOException {
getComplexValueForeignKey().updateUnsupportedValue(this);
}
public void delete() throws IOException {
getComplexValueForeignKey().deleteUnsupportedValue(this);
}
@Override
public String toString()
{
return "UnsupportedValue(" + getComplexValueForeignKey() + "," + getId() +
") " + getValues();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy