*
* @throw IllegalArgumentException if this column definition is invalid.
*/
- public void validate() {
+ public void validate(JetFormat format) {
+ if(_format != format) {
+ throw new IllegalArgumentException("format must be " + format +
+ " but is " + _format);
+ }
if(getType() == null) {
throw new IllegalArgumentException("must have type");
}
Set<String> colNames = new HashSet<String>();
// next, validate the column definitions
for(Column column : columns) {
- column.validate();
+ column.validate(_format);
if(!colNames.add(column.getName().toUpperCase())) {
throw new IllegalArgumentException("duplicate column name: " +
column.getName());
//These constants are populated by this class's constructor. They can't be
//populated by the subclass's constructor because they are final, and Java
//doesn't allow this; hence all the abstract defineXXX() methods.
+
+ /** the name of this format */
+ private final String _name;
/** Database page size in bytes */
public final int PAGE_SIZE;
}
}
- private JetFormat() {
+ private JetFormat(String name) {
+ _name = name;
PAGE_SIZE = definePageSize();
protected abstract int definePagesPerUsageMapPage();
protected abstract Charset defineCharset();
+
+ @Override
+ public String toString() {
+ return _name;
+ }
private static final class Jet4Format extends JetFormat {
+
+ private Jet4Format() {
+ super("VERSION_4");
+ }
protected int definePageSize() { return 4096; }