1 23 24 29 30 package com.sun.jdo.api.persistence.model.util; 31 32 import java.util.ResourceBundle ; 33 34 import com.sun.jdo.api.persistence.model.ModelException; 35 import com.sun.jdo.spi.persistence.utility.I18NHelper; 36 import com.sun.jdo.spi.persistence.utility.StringHelper; 37 38 43 public class ModelValidationException extends ModelException 44 { 45 46 public static final int ERROR = 0; 47 48 49 public static final int WARNING = 1; 50 51 52 private static final ResourceBundle _messages = I18NHelper.loadBundle( 53 "com.sun.jdo.api.persistence.model.Bundle", ModelValidationException.class.getClassLoader()); 55 56 58 private int _type; 59 60 63 private Object _offendingObject; 64 65 67 protected static final ResourceBundle getMessages () 68 { 69 return _messages; 70 } 71 72 77 public ModelValidationException () 78 { 79 } 80 81 87 public ModelValidationException (String msg) 88 { 89 super(msg); 90 } 91 92 98 public ModelValidationException (Object offendingObject) 99 { 100 super(); 101 _offendingObject = offendingObject; 102 } 103 104 111 public ModelValidationException (Object offendingObject, String msg) 112 { 113 this(ERROR, offendingObject, msg); 114 } 115 116 123 public ModelValidationException (int errorType, Object offendingObject, 124 String msg) 125 { 126 super(msg); 127 _type = errorType; 128 _offendingObject = offendingObject; 129 } 130 131 135 public Object getOffendingObject () { return _offendingObject; } 136 137 140 public int getType () { return _type; } 141 142 149 public String getMessage () 150 { 151 String message = super.getMessage(); 152 153 if ((WARNING == getType()) && !StringHelper.isEmpty(message)) 154 { 155 message = I18NHelper.getMessage(getMessages(), 156 "util.validation.warning") + message; } 158 159 return message; 160 } 161 } 162 | Popular Tags |