Example #1
0
  /**
   * Provides locale with a given iso code. Null if undefined.
   *
   * @param isoCode iso code of locale to be retrieved
   * @return locale with corresponding iso code
   */
  public static Locale getLocale(String isoCode) {
    for (Locale locale : LOCALES) {
      if (locale.getIsoCode().equals(isoCode)) return locale;
    }

    return null;
  }
/**
 * @author David Schweinsberg
 * @version $Release$
 */
public class DOMExceptionImpl extends DOMException {

  public static final int SYNTAX_ERROR = 0;
  public static final int ARRAY_OUT_OF_BOUNDS = 1;
  public static final int READ_ONLY_STYLE_SHEET = 2;
  public static final int EXPECTING_UNKNOWN_RULE = 3;
  public static final int EXPECTING_STYLE_RULE = 4;
  public static final int EXPECTING_CHARSET_RULE = 5;
  public static final int EXPECTING_IMPORT_RULE = 6;
  public static final int EXPECTING_MEDIA_RULE = 7;
  public static final int EXPECTING_FONT_FACE_RULE = 8;
  public static final int EXPECTING_PAGE_RULE = 9;
  public static final int FLOAT_ERROR = 10;
  public static final int STRING_ERROR = 11;
  public static final int COUNTER_ERROR = 12;
  public static final int RECT_ERROR = 13;
  public static final int RGBCOLOR_ERROR = 14;
  public static final int CHARSET_NOT_FIRST = 15;
  public static final int CHARSET_NOT_UNIQUE = 16;
  public static final int IMPORT_NOT_FIRST = 17;
  public static final int NOT_FOUND = 18;
  public static final int NOT_IMPLEMENTED = 19;

  private static ResourceBundle _exceptionResource =
      ResourceBundle.getBundle("com.steadystate.css.parser.ExceptionResource", Locale.getDefault());

  public DOMExceptionImpl(short code, int messageKey) {
    super(code, _exceptionResource.getString(keyString(messageKey)));
  }

  public DOMExceptionImpl(int code, int messageKey) {
    super((short) code, _exceptionResource.getString(keyString(messageKey)));
  }

  public DOMExceptionImpl(short code, int messageKey, String info) {
    super(code, _exceptionResource.getString(keyString(messageKey)));
  }

  private static String keyString(int key) {
    return "s" + String.valueOf(key);
  }
}