1 21 22 package org.apache.derby.impl.store.access; 23 24 import org.apache.derby.iapi.reference.SQLState; 25 import org.apache.derby.iapi.reference.Property; 26 import org.apache.derby.iapi.reference.ClassName; 27 import org.apache.derby.iapi.services.io.FormatIdUtil; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 import org.apache.derby.iapi.services.io.Formatable; 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 32 import org.apache.derby.iapi.store.access.TransactionController; 33 import org.apache.derby.iapi.services.property.PropertyUtil; 34 import org.apache.derby.catalog.UUID; 35 import java.io.IOException ; 36 import java.io.ObjectInput ; 37 import java.io.ObjectOutput ; 38 import java.io.StreamCorruptedException ; 39 import java.util.Enumeration ; 40 import java.util.Properties ; 41 42 public class PC_XenaVersion implements Formatable 43 { 44 private static final int XENA_MAJOR_VERSION = 1; 45 private static final int XENA_MINOR_VERSION_0 = 0; 46 47 private int minorVersion = XENA_MINOR_VERSION_0; 52 53 54 private boolean isUpgradeNeeded(PC_XenaVersion fromVersion) 55 { 56 return 57 fromVersion == null || 58 getMajorVersionNumber() != fromVersion.getMajorVersionNumber(); 59 } 60 61 public void upgradeIfNeeded(TransactionController tc, 62 PropertyConglomerate pc, 63 Properties serviceProperties) 64 throws StandardException 65 { 66 PC_XenaVersion dbVersion = 67 (PC_XenaVersion)pc.getProperty(tc,DataDictionary.PROPERTY_CONGLOMERATE_VERSION); 68 if (isUpgradeNeeded(dbVersion)) 69 { 70 throw StandardException.newException(SQLState.UPGRADE_UNSUPPORTED, dbVersion, this); 71 } 72 } 73 74 public int getMajorVersionNumber() {return XENA_MAJOR_VERSION;} 75 public int getMinorVersionNumber() {return minorVersion;} 76 77 public void writeExternal(ObjectOutput out) throws IOException 78 { 79 out.writeInt(getMajorVersionNumber()); 80 out.writeInt(getMinorVersionNumber()); 81 } 82 83 public void readExternal(ObjectInput in) throws IOException 84 { 85 int majorVersion = in.readInt(); 86 minorVersion = in.readInt(); 87 } 88 89 public int getTypeFormatId() {return StoredFormatIds.PC_XENA_VERSION_ID;} 90 91 public String toString() {return getMajorVersionNumber()+"."+getMinorVersionNumber();} 92 } 93 | Popular Tags |