1 19 20 package org.apache.cayenne.map; 21 22 27 public class DeleteRule { 28 public static final int NO_ACTION = 0; 29 private static final String NO_ACTION_NAME = "No Action"; 30 31 36 public static final int NULLIFY = 1; 37 private static final String NULLIFY_NAME = "Nullify"; 38 39 41 public static final int CASCADE = 2; 42 private static final String CASCADE_NAME = "Cascade"; 43 44 47 public static final int DENY = 3; 48 private static final String DENY_NAME = "Deny"; 49 50 55 public static String deleteRuleName(int deleteRule) { 56 switch (deleteRule) { 57 case DeleteRule.NULLIFY : 58 return NULLIFY_NAME; 59 case DeleteRule.CASCADE : 60 return CASCADE_NAME; 61 case DeleteRule.DENY : 62 return DENY_NAME; 63 default : 64 return NO_ACTION_NAME; 65 } 66 } 67 68 72 public static int deleteRuleForName(String name) { 73 if (DENY_NAME.equals(name)) { 74 return DENY; 75 } else if (CASCADE_NAME.equals(name)) { 76 return CASCADE; 77 } else if (NULLIFY_NAME.equals(name)) { 78 return NULLIFY; 79 } 80 return NO_ACTION; 81 } 82 83 } 84 | Popular Tags |