001 package com.mockrunner.mock.jdbc; 002 003 import java.sql.SQLException; 004 import java.sql.Savepoint; 005 006 /** 007 * Mock implementation of <code>Savepoint</code>. 008 */ 009 public class MockSavepoint implements Savepoint 010 { 011 private static int idCount = 0; 012 013 private String name; 014 private int id; 015 private int number; 016 private boolean released; 017 private boolean rolledback; 018 019 public MockSavepoint(int number) 020 { 021 this("", number); 022 } 023 024 public MockSavepoint(String name, int number) 025 { 026 this.name = name; 027 this.id = idCount++; 028 this.number = number; 029 released = false; 030 rolledback = false; 031 } 032 033 public int getSavepointId() throws SQLException 034 { 035 return id; 036 } 037 038 public String getSavepointName() throws SQLException 039 { 040 return name; 041 } 042 043 public int getNumber() 044 { 045 return number; 046 } 047 048 public boolean isReleased() 049 { 050 return released; 051 } 052 053 /** 054 * @deprecated use {@link #isRolledBack} 055 */ 056 public boolean isRollbacked() 057 { 058 return isRolledBack(); 059 } 060 061 public boolean isRolledBack() 062 { 063 return rolledback; 064 } 065 066 public void setReleased(boolean released) 067 { 068 this.released = released; 069 } 070 071 /** 072 * @deprecated use {@link #setRolledBack} 073 */ 074 public void setRollbacked(boolean rollbacked) 075 { 076 setRolledBack(rollbacked); 077 } 078 079 public void setRolledBack(boolean rollbacked) 080 { 081 this.rolledback = rollbacked; 082 } 083 }