nl.toolforge.karma.core
Class ErrorCode

java.lang.Object
  extended bynl.toolforge.karma.core.ErrorCode

public final class ErrorCode
extends java.lang.Object

Class representing a Karma errorcode. These errorcodes are localized to support different languages. Errorcodes are defined in ranges. Exceptions that are supported by Karma, define these ranges.

Version:
$Id: ErrorCode.java,v 1.17 2004/11/10 22:06:33 asmedes Exp $
Author:
D.A. Smedes

Constructor Summary
ErrorCode(java.lang.String errorCode)
          Creates an error code.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.String getErrorCodeString()
          Gets this instance' error code.
 java.lang.String getErrorMessage()
          Gets the error message for the current locale.
 java.lang.String getErrorMessage(java.util.Locale locale)
          Gets a localized error message for the ErrorCode instance.
 int hashCode()
           
 void setMessageArguments(java.lang.Object[] messageArguments)
          Assigns message arguments to this error code as per the MessageFormat definition.
 void setMessageBundle(java.util.ResourceBundle messageBundle)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ErrorCode

public ErrorCode(java.lang.String errorCode)
Creates an error code. Error codes must comply to the following pattern : [A-Z]{3}-\d{5}. Examples are: MAN-00001, CMD-10020.

Parameters:
errorCode -
Method Detail

setMessageBundle

public void setMessageBundle(java.util.ResourceBundle messageBundle)

setMessageArguments

public final void setMessageArguments(java.lang.Object[] messageArguments)
Assigns message arguments to this error code as per the MessageFormat definition.

Parameters:
messageArguments - An Object array (currently only String instances are supported).

getErrorMessage

public java.lang.String getErrorMessage(java.util.Locale locale)

Gets a localized error message for the ErrorCode instance. Error messages are defined in a error-messages-<locale>.properties (e.g. error-messages-NL.properties). A message text is identified by a key message. concatenated with getErrorCodeString().

When no resource bundle can be found for locale, the default locale Locale.ENGLISH is used.

Parameters:
locale - A locale object (e.g. representing the current locale of the user environment).
Returns:
A localized error message or getErrorCodeString() when no message was found for this errorcode or the resourcebundle could not be found for locale.

getErrorMessage

public java.lang.String getErrorMessage()
Gets the error message for the current locale.

Returns:
The error message for the error code.

getErrorCodeString

public java.lang.String getErrorCodeString()
Gets this instance' error code.

Returns:
This instance' error code.

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

toString

public java.lang.String toString()


Copyright © 2002-2004 Toolforge. All Rights Reserved.