Source for org.jfree.formula.LibFormulaErrorValue

   1: /**
   2:  * =========================================
   3:  * LibFormula : a free Java formula library
   4:  * =========================================
   5:  *
   6:  * Project Info:  http://reporting.pentaho.org/libformula/
   7:  *
   8:  * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors.
   9:  *
  10:  * This library is free software; you can redistribute it and/or modify it under the terms
  11:  * of the GNU Lesser General Public License as published by the Free Software Foundation;
  12:  * either version 2.1 of the License, or (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15:  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16:  * See the GNU Lesser General Public License for more details.
  17:  *
  18:  * You should have received a copy of the GNU Lesser General Public License along with this
  19:  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20:  * Boston, MA 02111-1307, USA.
  21:  *
  22:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  23:  * in the United States and other countries.]
  24:  *
  25:  *
  26:  * ------------
  27:  * $Id: LibFormulaErrorValue.java 3521 2007-10-16 10:55:14Z tmorgner $
  28:  * ------------
  29:  * (C) Copyright 2006-2007, by Pentaho Corporation.
  30:  */
  31: package org.jfree.formula;
  32: 
  33: import java.util.Locale;
  34: 
  35: /**
  36:  * Creation-Date: 31.10.2006, 13:07:37
  37:  *
  38:  * @author Thomas Morgner
  39:  */
  40: public class LibFormulaErrorValue implements ErrorValue
  41: {
  42:   public static final int ERROR_REFERENCE_NOT_RESOLVABLE = 499;
  43: 
  44:   /** A parse error */
  45:   public static final int ERROR_INVALID_CHARACTER = 501;
  46:   /** Function name is invalid error code */
  47:   public static final int ERROR_INVALID_FUNCTION = 505;
  48:   /** Function name is invalid error */
  49:   public static final LibFormulaErrorValue ERROR_INVALID_FUNCTION_VALUE = new LibFormulaErrorValue(ERROR_INVALID_FUNCTION);
  50:   /** Parameter types are invalid error code */
  51:   public static final int ERROR_INVALID_ARGUMENT = 502;
  52:   /** Parameter types are invalid error */
  53:   public static final LibFormulaErrorValue ERROR_INVALID_ARGUMENT_VALUE = new LibFormulaErrorValue(ERROR_INVALID_ARGUMENT);
  54:   /** Parameter types are invalid error code */
  55:   public static final int ERROR_INVALID_AUTO_ARGUMENT = 666;
  56:   /** Parameter types are invalid error */
  57:   public static final LibFormulaErrorValue ERROR_INVALID_AUTO_ARGUMENT_VALUE = new LibFormulaErrorValue(ERROR_INVALID_AUTO_ARGUMENT);
  58:   
  59:   public static final int ERROR_ILLEGAL_ARRAY = 667;
  60:   
  61:   public static final LibFormulaErrorValue ERROR_ILLEGAL_ARRAY_VALUE = new LibFormulaErrorValue(ERROR_ILLEGAL_ARRAY);
  62:   /** Number arithmetic error code */
  63:   public static final int ERROR_ARITHMETIC = 503;
  64:   /** Number arithmetic error */
  65:   public static final LibFormulaErrorValue ERROR_ARITHMETIC_VALUE = new LibFormulaErrorValue(ERROR_ARITHMETIC);
  66:   /** Invalid number of arguments error code*/
  67:   public static final int ERROR_ARGUMENTS = 1;
  68:   /** Invalid number of arguments error */
  69:   public static final LibFormulaErrorValue ERROR_ARGUMENTS_VALUE = new LibFormulaErrorValue(ERROR_ARGUMENTS);
  70:   /** Occurence not found error code */
  71:   public static final int ERROR_NOT_FOUND = 504;
  72:   /** Occurence not found error */
  73:   public static final LibFormulaErrorValue ERROR_NOT_FOUND_VALUE = new LibFormulaErrorValue(ERROR_NOT_FOUND);
  74:   /** NA error code*/
  75:   public static final int ERROR_NA = 522;
  76:   /** NA error*/
  77:   public static final LibFormulaErrorValue ERROR_NA_VALUE = new LibFormulaErrorValue(ERROR_NA);
  78:   /** Unexpected error code */
  79:   public static final int ERROR_UNEXPECTED = 0;
  80:   /** Unexpected error */
  81:   public static final LibFormulaErrorValue ERROR_UNEXPECTED_VALUE = new LibFormulaErrorValue(ERROR_UNEXPECTED);
  82: 
  83:   private int errorCode;
  84: 
  85:   public LibFormulaErrorValue(final int errorCode)
  86:   {
  87:     this.errorCode = errorCode;
  88:   }
  89: 
  90:   public String getNamespace()
  91:   {
  92:     return "http://jfreereport.sourceforge.net/libformula";
  93:   }
  94: 
  95:   public int getErrorCode()
  96:   {
  97:     return errorCode;
  98:   }
  99: 
 100:   public String getErrorMessage(final Locale locale)
 101:   {
 102:     return "TODO";
 103:   }
 104: 
 105:   public boolean equals(final Object obj)
 106:   {
 107:     if(obj instanceof LibFormulaErrorValue)
 108:     {
 109:       final LibFormulaErrorValue error = (LibFormulaErrorValue)obj;
 110:       return this.errorCode == error.getErrorCode();
 111:     }
 112: 
 113:     return false;
 114:   }
 115: 
 116:   public String toString()
 117:   {
 118:     return "LibFormulaErrorValue{" +
 119:         "errorCode=" + errorCode +
 120:         '}';
 121:   }
 122: }