//______________________________________________________________________________
//   |       |
//   | knipp |           Knipp Medien und Kommunikation GmbH
//    -------
//
//
//     Knipp RRI Toolkit
//
//
//     Copyright (C) 2005 by Knipp Medien und Kommunikation GmbH
//
//     This library is free software; you can redistribute it and/or
//     modify it under the terms of the GNU Lesser General Public License 
//     as published by the Free Software Foundation; either version 2.1 
//     of the License, or any later version.
// 
//     This library is distributed in the hope that it will be useful, 
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
//     GNU Lesser General Public License for more details.
//
//     You should have received a copy of the GNU Lesser General
//     Public License along with this library; if not, write to the 
//     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
//     Boston, MA 02111-1307 USA 
//
//
//     initial author:    Klaus Malorny
//
//     version:           1.3 (15112), 2011/05/27 16:00:14
//                        $Revision: 14936 $ 
//                        $Date: 2010-11-05 15:57:40 +0100 (Fri, 05 Nov 2010) $
//                        $Author: Klaus.Malorny $
//

package de.knipp.rritoolkit.response;



/**
 *  class that splits the DENIC error codes into the respective fields
 *
 *  @version  $Revision: 14936 $
 *  @author   Klaus Malorny
 */

public class ErrorCode
{
  /** the complete code */
  
  private String code;
  

  /** the class */
  
  private String errorClass;
  
  
  /** the interface access method */
  
  private String interfaceAccess;
  
  
  /** the interface application */
  
  private String interfaceApplication;
  
  
  /** the component code */
  
  private String component;
  
  
  /** the error code */
  
  private String errorCode;
  
  
  
  // the known constants
  
  /** error class: info, success */
  
  public static final String ECLASS_INFO_SUCCESS = "1";
  
  
  /** error class: info, failed */
  
  public static final String ECLASS_INFO_FAILED = "2";
  
  
  /** error class: warning, temporary */
  
  public static final String ECLASS_WARNING_TEMPORARY = "3";
  
  
  /** error class: warning, permanent */
  
  public static final String ECLASS_WARNING_PERMANENT = "4";
  
  
  /** error class: error, temporary */
  
  public static final String ECLASS_ERROR_TEMPORARY = "5";
  
  
  /** error class: error, permanent */
  
  public static final String ECLASS_ERROR_PERMANENT = "6";
  
  
  /** error class: fatal error, temporary */
  
  public static final String ECLASS_FATAL_ERROR_TEMPORARY = "7";
  
  
  /** error class: fatal error, permanent */
  
  public static final String ECLASS_FATAL_ERROR_PERMANENT = "8";
  
  
  
  /** interface access: RRI */
  
  public static final String IACCESS_RRI = "3";


  /** interface access: interface independent */

  public static final String IACCESS_INDEPENDENT = "6";

  
  
  /** interface application: independent */
  
  public static final String IAPP_INDEPENDENT = "000";
  
  
  /** interface application: login */
  
  public static final String IAPP_LOGIN = "100";
  
  
  /** interface application: contact (general) */
  
  public static final String IAPP_CONTACT = "200";
  

  /** interface application: contact create */
  
  public static final String IAPP_CONTACT_CREATE = "210";
  
  
  /** interface application: contact update */
  
  public static final String IAPP_CONTACT_UPDATE = "220";
  
  
  /** interface application: domain (general) */
  
  public static final String IAPP_DOMAIN = "300";
  
  
  /** interface application: domain create */
  
  public static final String IAPP_DOMAIN_CREATE = "310";
  
  
  /** interface application: domain update */
  
  public static final String IAPP_DOMAIN_UPDATE = "320";
  
  
  /** interface application: domain change holder */
  
  public static final String IAPP_DOMAIN_CHANGE_HOLDER = "330";


  /** interface application: expire (DE domain) */

  public static final String IAPP_EXPIRE_DE = "348";
  
  
  /** interface application: domain delete */
  
  public static final String IAPP_DOMAIN_DELETE = "350";
  
  
  /** interface application: domain transit */
  
  public static final String IAPP_DOMAIN_TRANSIT = "360";
  
  
  /** interface application: domain change provider */
  
  public static final String IAPP_DOMAIN_CHANGE_PROV = "370";
  
  
  /** interface application: domain transfer acknowledge */
  
  public static final String IAPP_DOMAIN_ACK = "375";
  
  
  /** interface application: domain transfer negative acknowledge */
  
  public static final String IAPP_DOMAIN_NACK = "376";


  /** interface application: authinfo 1 create */

  public static final String IAPP_AUTHINFO1_CREATE = "391";


  /** interface application: authinfo 1 delete */

  public static final String IAPP_AUTHINFO1_DELETE = "392";


  /** interface application: authinfo 2 create */

  public static final String IAPP_AUTHINFO2_CREATE = "393";


  /** interface application: authinfo expire */

  public static final String IAPP_AUTHINFO_EXPIRE = "394";
  
  
  /** interface application: check */
  
  public static final String IAPP_CHECK = "400";
  
  
  /** interface application: info */
  
  public static final String IAPP_INFO = "450";
  
  
  /** interface application: queue (general) */
  
  public static final String IAPP_QUEUE = "600";
  
  
  /** interface application: queue read */
  
  public static final String IAPP_QUEUE_READ = "610";
  
  
  /** interface application: queue delete */
  
  public static final String IAPP_QUEUE_DELETE = "650";


  /** interface application: description migration */

  public static final String IAPP_MIGRATE_DESCR = "900";
   

  /** component: independent */
  
  public static final String COMP_INDEPENDENT = "00";
  
  
  /** component: authorization */
  
  public static final String COMP_AUTHORIZATION = "02";
  
  
  /** component: keyword */
  
  public static final String COMP_KEYWORD = "04";
  
  
  /** component: value */
  
  public static final String COMP_VALUE = "06";
  
  
  /** component: program logic */
  
  public static final String COMP_PROGRAM_LOGIC = "08";
  
  
  /** component: name server check */
  
  public static final String COMP_NS_CHECK = "10";
  
  
  
  
  
  
  /**
   *  constructor
   *
   *  @param theCode              the eleven digit code
   */
  
  public ErrorCode (String theCode)
  {
    if (theCode.length () != 11) 
      throw new IllegalArgumentException ("invalid length of code");
    
    code = theCode;
    errorClass = code.substring (0, 1);
    interfaceAccess = code.substring (1, 2);
    interfaceApplication = code.substring (2, 5);
    component = code.substring (5, 7);
    errorCode = code.substring (7, 11);
  }
  
  
  
  
  /**
   *  return a string representation of the error code
   *
   *  @return                  the error code
   */
  
  @Override
  public String toString ()
  {
    return code;
  }
  
  
  //--- access methods ---------------------------------------------------------
  
  /**
   *  return the complete code
   *
   *  @return                    the code
   */
  
  public String getCode ()
  {
    return code;
  }
  
  
  /**
   *  return the error class
   *
   *  @return                    the error class
   */
  
  public String getErrorClass ()
  {
    return errorClass;
  }
  
  
  /**
   *  return the interface access method
   *
   *  @return                    the access method
   */
  
  public String getInterfaceAccess ()
  {
    return interfaceAccess;
  }
  
  
  
  /**
   *  return the interface application
   *
   *  @return                    the interface application
   */
  
  public String getInterfaceApplication ()
  {
    return interfaceApplication;
  }
  
  
  /**
   *  return the component
   *
   *  @return                     the component
   */
  
  public String getComponent ()
  {
    return component;
  }

  
  
  /**
   *  return the actual error code
   *
   *  @return                      the error code
   */
  
  public String getErrorCode ()
  {
    return errorCode;
  }
  
  
  

  
}

