/** * @see java.io.Externalizable#writeExternal * @exception IOException Thrown on write error */ public void writeExternal(ObjectOutput out) throws IOException { FormatableHashtable fh = new FormatableHashtable(); fh.putBoolean("isUnique", isUnique); fh.putInt("keyLength", baseColumnPositions.length); for (int i = 0; i < baseColumnPositions.length; i++) { fh.putInt("bcp" + i, baseColumnPositions[i]); fh.putBoolean("isAsc" + i, isAscending[i]); } fh.putInt("orderedColumns", numberOfOrderedColumns); fh.put("indexType", indexType); // write the new attribut older versions will simply ignore it fh.putBoolean("isUniqueWithDuplicateNulls", isUniqueWithDuplicateNulls); out.writeObject(fh); }
/** * @see java.io.Externalizable#readExternal * @exception IOException Thrown on read error */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { FormatableHashtable fh = (FormatableHashtable) in.readObject(); isUnique = fh.getBoolean("isUnique"); int bcpLength = fh.getInt("keyLength"); baseColumnPositions = new int[bcpLength]; isAscending = new boolean[bcpLength]; for (int i = 0; i < bcpLength; i++) { baseColumnPositions[i] = fh.getInt("bcp" + i); isAscending[i] = fh.getBoolean("isAsc" + i); } numberOfOrderedColumns = fh.getInt("orderedColumns"); indexType = (String) fh.get("indexType"); // isUniqueWithDuplicateNulls attribute won't be present if the index // was created in older versions if (fh.containsKey("isUniqueWithDuplicateNulls")) isUniqueWithDuplicateNulls = fh.getBoolean("isUniqueWithDuplicateNulls"); else isUniqueWithDuplicateNulls = false; }