1 21 package oracle.toplink.essentials.sequencing; 23 24 import java.util.Vector ; 25 import oracle.toplink.essentials.internal.sessions.AbstractSession; 26 import oracle.toplink.essentials.internal.databaseaccess.Accessor; 27 28 33 public class DefaultSequence extends Sequence { 34 protected Sequence defaultSequence; 35 36 public DefaultSequence() { 37 super(); 38 } 39 40 public DefaultSequence(String name) { 43 super(name, 0); 44 } 45 46 public DefaultSequence(String name, int size) { 47 super(name, size); 48 } 49 50 public DefaultSequence(String name, int size, int initialValue) { 51 super(name, size, initialValue); 52 } 53 54 public Sequence getDefaultSequence() { 55 return getDatasourcePlatform().getDefaultSequence(); 56 } 57 58 public boolean hasPreallocationSize() { 59 return size != 0; 60 } 61 62 public int getPreallocationSize() { 63 if ((size != 0) || (getDefaultSequence() == null)) { 64 return size; 65 } else { 66 return getDefaultSequence().getPreallocationSize(); 67 } 68 } 69 70 public int getInitialValue() { 71 if ((initialValue != 0) || (getDefaultSequence() == null)) { 72 return initialValue; 73 } else { 74 return getDefaultSequence().getInitialValue(); 75 } 76 } 77 78 public boolean equals(Object obj) { 79 if (obj instanceof DefaultSequence) { 80 return equalNameAndSize(this, (DefaultSequence)obj); 81 } else { 82 return false; 83 } 84 } 85 86 94 public boolean shouldAcquireValueAfterInsert() { 95 return getDefaultSequence().shouldAcquireValueAfterInsert(); 96 } 97 98 105 public boolean shouldUseTransaction() { 106 return getDefaultSequence().shouldUseTransaction(); 107 } 108 109 117 public boolean shouldOverrideExistingValue(String seqName, Object existingValue) { 118 return getDefaultSequence().shouldOverrideExistingValue(seqName, existingValue); 119 } 120 121 134 public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName) { 135 return getDefaultSequence().getGeneratedValue(accessor, writeSession, seqName); 136 } 137 138 152 public Vector getGeneratedVector(Accessor accessor, AbstractSession writeSession, String name, int size) { 153 return getDefaultSequence().getGeneratedVector(accessor, writeSession, name, size); 154 } 155 156 162 protected void onConnect() { 163 } 165 166 171 public void onDisconnect() { 172 } 174 } 175 | Popular Tags |