1 30 31 32 package org.hsqldb; 33 34 import org.hsqldb.HsqlNameManager.HsqlName; 35 import org.hsqldb.lib.HashMappedList; 36 import org.hsqldb.persist.Logger; 37 38 45 public class SequenceManager { 46 47 HashMappedList sequenceMap; 48 49 SequenceManager() { 50 sequenceMap = new HashMappedList(); 51 } 52 53 59 void dropSequence(String name) throws HsqlException { 60 61 boolean found = sequenceMap.containsKey(name); 62 63 Trace.check(found, Trace.SEQUENCE_NOT_FOUND, name); 64 sequenceMap.remove(name); 65 } 66 67 public NumberSequence getSequence(String name) { 68 return (NumberSequence) sequenceMap.get(name); 69 } 70 71 NumberSequence createSequence(HsqlName hsqlname, long start, 72 long increment, 73 int type) throws HsqlException { 74 75 Trace.check(!sequenceMap.containsKey(hsqlname.name), 76 Trace.SEQUENCE_ALREADY_EXISTS); 77 78 NumberSequence sequence = new NumberSequence(hsqlname, start, 79 increment, type); 80 81 sequenceMap.put(hsqlname.name, sequence); 82 83 return sequence; 84 } 85 86 String logSequences(Session c, Logger logger) throws HsqlException { 87 88 for (int i = 0; i < sequenceMap.size(); i++) { 89 NumberSequence seq = (NumberSequence) sequenceMap.get(i); 90 91 if (seq.wasUsed()) { 92 logger.writeSequenceStatement(c, seq); 93 seq.resetWasUsed(); 94 } 95 } 96 97 return null; 98 } 99 } 100 | Popular Tags |