1 21 22 package org.apache.derby.iapi.services.io; 23 24 import org.apache.derby.iapi.services.io.ArrayInputStream; 25 26 import org.apache.derby.iapi.services.io.Formatable; 27 import org.apache.derby.iapi.services.io.FormatIdUtil; 28 import org.apache.derby.iapi.services.io.StoredFormatIds; 29 30 import java.io.ObjectOutput ; 31 import java.io.ObjectInput ; 32 import java.io.IOException ; 33 34 37 public class FormatableIntHolder implements Formatable 38 { 39 52 53 private int theInt; 55 56 59 public FormatableIntHolder() 60 { 61 } 62 63 68 public FormatableIntHolder(int theInt) 69 { 70 this.theInt = theInt; 71 } 72 73 78 public void setInt(int theInt) 79 { 80 this.theInt = theInt; 81 } 82 83 88 public int getInt() 89 { 90 return theInt; 91 } 92 93 101 public static FormatableIntHolder[] getFormatableIntHolders(int[] theInts) 102 { 103 if (theInts == null) 104 { 105 return null; 106 } 107 108 FormatableIntHolder[] fihArray = new FormatableIntHolder[theInts.length]; 109 110 for (int index = 0; index < theInts.length; index++) 111 { 112 fihArray[index] = new FormatableIntHolder(theInts[index]); 113 } 114 return fihArray; 115 } 116 117 129 public void writeExternal(ObjectOutput out) throws IOException 130 { 131 out.writeInt(theInt); 132 } 133 134 141 public void readExternal(ObjectInput in) 142 throws IOException 143 { 144 theInt = in.readInt(); 145 } 146 public void readExternal(ArrayInputStream in) 147 throws IOException 148 { 149 theInt = in.readInt(); 150 } 151 152 157 public int getTypeFormatId() { return StoredFormatIds.FORMATABLE_INT_HOLDER_V01_ID; } 158 } 159 | Popular Tags |