/*
Copyright (c) 2011 James Ahlborn
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.healthmarketscience.jackcess.complex;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
/**
* Value which is returned for a complex column. This value corresponds to a
* foreign key in a secondary table which contains the actual complex data for
* this row (which could be 0 or more complex values for a given row). This
* class contains various convenience methods for interacting with the actual
* complex values.
*
* This class will cache the associated complex values returned from one of
* the lookup methods. The various modification methods will clear this cache
* automatically. The {@link #reset} method may be called manually to clear
* this internal cache.
*
* @author James Ahlborn
*/
public class ComplexValueForeignKey extends Number
{
private static final long serialVersionUID = 20110805L;
private transient final Column _column;
private final int _value;
private transient List extends ComplexValue> _values;
public ComplexValueForeignKey(Column column, int value) {
_column = column;
_value = value;
}
public int get() {
return _value;
}
public Column getColumn() {
return _column;
}
@Override
public byte byteValue() {
return (byte)get();
}
@Override
public short shortValue() {
return (short)get();
}
@Override
public int intValue() {
return get();
}
@Override
public long longValue() {
return get();
}
@Override
public float floatValue() {
return get();
}
@Override
public double doubleValue() {
return get();
}
public ComplexDataType getComplexType() {
return getComplexInfo().getType();
}
protected ComplexColumnInfo extends ComplexValue> getComplexInfo() {
return _column.getComplexInfo();
}
protected VersionHistoryColumnInfo getVersionInfo() {
return (VersionHistoryColumnInfo)getComplexInfo();
}
protected AttachmentColumnInfo getAttachmentInfo() {
return (AttachmentColumnInfo)getComplexInfo();
}
protected MultiValueColumnInfo getMultiValueInfo() {
return (MultiValueColumnInfo)getComplexInfo();
}
protected UnsupportedColumnInfo getUnsupportedInfo() {
return (UnsupportedColumnInfo)getComplexInfo();
}
public int countValues()
throws IOException
{
return getComplexInfo().countValues(get());
}
public List