1 19 20 package org.netbeans.api.xml.cookies; 21 22 import org.openide.util.Lookup; 23 import org.openide.util.lookup.Lookups; 24 25 32 public final class CookieMessage { 33 34 private final Lookup details; 36 37 private final String message; 39 40 private final int level; 42 43 46 public static final int INFORMATIONAL_LEVEL = 0; 47 48 51 public static final int WARNING_LEVEL = 1; 52 53 56 public static final int ERROR_LEVEL = 2; 57 58 61 public static final int FATAL_ERROR_LEVEL = 3; 62 63 67 public CookieMessage(String message) { 68 this( message, INFORMATIONAL_LEVEL, null); 69 } 70 71 76 public CookieMessage(String message, int level) { 77 this( message, level, null); 78 } 79 80 85 public CookieMessage(String message, Object detail) { 86 this( message, INFORMATIONAL_LEVEL, detail); 87 } 88 89 95 public CookieMessage(String message, int level, Object detail) { 96 this(message, level, Lookups.singleton(detail)); 97 } 98 99 105 public CookieMessage(String message, int level, Lookup details) { 106 if (message == null) throw new NullPointerException (); 107 if (level < INFORMATIONAL_LEVEL || level > FATAL_ERROR_LEVEL) 108 throw new IllegalArgumentException (); 109 110 this.message = message; 111 this.level = level; 112 this.details = details == null ? Lookup.EMPTY : details; 113 } 114 115 116 119 public String getMessage() { 120 return message; 121 } 122 123 126 public final int getLevel() { 127 return level; 128 } 129 130 135 public Object getDetail(Class klass) { 136 return details.lookup(klass); 137 } 138 139 143 public Lookup getDetails() { 144 return details; 145 } 146 } 147 | Popular Tags |