1 21 22 package org.apache.derby.catalog.types; 23 24 25 import org.apache.derby.iapi.services.io.Formatable; 26 import org.apache.derby.iapi.services.io.StoredFormatIds; 27 import org.apache.derby.catalog.ReferencedColumns; 28 29 import java.io.ObjectInput ; 30 import java.io.ObjectOutput ; 31 import java.io.IOException ; 32 33 public class ReferencedColumnsDescriptorImpl 34 implements ReferencedColumns, Formatable 35 { 36 49 50 private int[] referencedColumns; 51 52 57 58 public ReferencedColumnsDescriptorImpl( int[] referencedColumns) 59 { 60 this.referencedColumns = referencedColumns; 61 } 62 63 64 public ReferencedColumnsDescriptorImpl() 65 { 66 } 67 70 public int[] getReferencedColumnPositions() 71 { 72 return referencedColumns; 73 } 74 75 76 77 82 public void readExternal(ObjectInput in) throws IOException 83 { 84 int rcLength = in.readInt(); 85 referencedColumns = new int[rcLength]; 86 for (int i = 0; i < rcLength; i++) 87 { 88 referencedColumns[i] = in.readInt(); 89 } 90 } 91 92 97 public void writeExternal(ObjectOutput out) throws IOException 98 { 99 out.writeInt(referencedColumns.length); 100 for (int i = 0; i < referencedColumns.length; i++) 101 { 102 out.writeInt(referencedColumns[i]); 103 } 104 } 105 106 107 public int getTypeFormatId() 108 { 109 return StoredFormatIds.REFERENCED_COLUMNS_DESCRIPTOR_IMPL_V01_ID; 110 } 111 112 115 public String toString() 116 { 117 StringBuffer sb = new StringBuffer (60); 118 119 sb.append('('); 120 for (int index = 0; index < referencedColumns.length; index++) 121 { 122 if (index > 0) 123 sb.append(','); 124 sb.append(String.valueOf(referencedColumns[index])); 125 126 } 127 sb.append(')'); 128 return sb.toString(); 129 } 130 } 131 | Popular Tags |