1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2007 Oracle. All rights reserved. 5 * 6 * $Id: ForeignKeyDeleteAction.java,v 12.1 2008/01/28 15:38:32 bschmeck Exp $ 7 */ 8 9package com.sleepycat.db; 10 11import com.sleepycat.db.internal.DbConstants; 12 13public class ForeignKeyDeleteAction { 14 private String name; 15 private int id; 16 17 private ForeignKeyDeleteAction(String name, int id) { 18 this.name = name; 19 this.id = id; 20 } 21 22 public String toString() { 23 return "ForeignKeyDeleteAction." + name; 24 } 25 26 /* package */ 27 int getId() { 28 return id; 29 } 30 31 static ForeignKeyDeleteAction fromInt(int type) { 32 switch(type) { 33 case DbConstants.DB_FOREIGN_ABORT: 34 return ABORT; 35 case DbConstants.DB_FOREIGN_CASCADE: 36 return CASCADE; 37 case DbConstants.DB_FOREIGN_NULLIFY: 38 return NULLIFY; 39 default: 40 throw new IllegalArgumentException("Unknown action type: " + type); 41 } 42 } 43 44 public static ForeignKeyDeleteAction ABORT = 45 new ForeignKeyDeleteAction("ABORT", DbConstants.DB_FOREIGN_ABORT); 46 public static ForeignKeyDeleteAction CASCADE = 47 new ForeignKeyDeleteAction("CASCADE", DbConstants.DB_FOREIGN_CASCADE); 48 public static ForeignKeyDeleteAction NULLIFY = 49 new ForeignKeyDeleteAction("NULLIFY", DbConstants.DB_FOREIGN_NULLIFY); 50} 51