Coverage Report - net.sf.jabref.wizard.integrity.IntegrityMessage
 
Classes in this File Line Coverage Branch Coverage Complexity
IntegrityMessage
17%
5/28
0%
0/6
1.3
 
 1  
 /*
 2  
 Copyright (C) 2004 R. Nagel
 3  
 
 4  
 All programs in this directory and
 5  
 subdirectories are published under the GNU General Public License as
 6  
 described below.
 7  
 
 8  
 This program is free software; you can redistribute it and/or modify
 9  
 it under the terms of the GNU General Public License as published by
 10  
 the Free Software Foundation; either version 2 of the License, or (at
 11  
 your option) any later version.
 12  
 
 13  
 This program is distributed in the hope that it will be useful, but
 14  
 WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16  
 General Public License for more details.
 17  
 
 18  
 You should have received a copy of the GNU General Public License
 19  
 along with this program; if not, write to the Free Software
 20  
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 21  
 USA
 22  
 
 23  
 Further information about the GNU GPL is available at:
 24  
 http://www.gnu.org/copyleft/gpl.ja.html
 25  
 
 26  
 */
 27  
 
 28  
 
 29  
 // created by : r.nagel 09.12.2004
 30  
 //
 31  
 // function : a class for wrapping a IntegrityCheck message
 32  
 //
 33  
 // modified :
 34  
 
 35  
 package net.sf.jabref.wizard.integrity ;
 36  
 
 37  
 import net.sf.jabref.BibtexEntry;
 38  
 import net.sf.jabref.Globals;
 39  
 
 40  
 public class IntegrityMessage implements Cloneable
 41  
 {
 42  
   // Hints and Infos < 1000 :-)
 43  
   public static final int
 44  
       GENERIC_HINT             = 1,
 45  
       UPPER_AND_LOWER_HINT     = 10,
 46  
       FOUR_DIGITS_HINT         = 11
 47  
 
 48  
       ;
 49  
 
 50  
   // > 1000 Warnings
 51  
   public static final int
 52  
       GENERIC_WARNING                = 1001,
 53  
       NAME_START_WARNING             = 1010,
 54  
       NAME_END_WARNING               = 1011,
 55  
       NAME_SEMANTIC_WARNING          = 1012
 56  
       ;
 57  
 
 58  
   // > 2000 Failure Messages
 59  
   public static final int
 60  
       UNKNONW_FAILURE                    = 2001,
 61  
       UNEXPECTED_CLOSING_BRACE_FAILURE   = 2010
 62  
       ;
 63  
 
 64  
   public static int
 65  41264
       FULL_MODE    = 1,  // print with Bibtex Entry
 66  41264
       SINLGE_MODE  = 2   // print only Message
 67  
       ;
 68  
 
 69  41264
   private static int printMode = SINLGE_MODE ;
 70  
 
 71  
   private int type ;
 72  
   private BibtexEntry entry ;
 73  
   private String fieldName ;
 74  
   private Object additionalInfo ;
 75  
   private String msg ;
 76  
   private boolean fixed ; // the user has changed sometings on BibtexEntry
 77  
 
 78  
   public final synchronized static void setPrintMode(int newMode)
 79  
   {
 80  41314
     printMode = newMode ;
 81  41314
   }
 82  
 
 83  
 
 84  
   public IntegrityMessage(int pType, BibtexEntry pEntry, String pFieldName, Object pAdditionalInfo)
 85  0
   {
 86  0
     this.type = pType;
 87  0
     this.entry = pEntry;
 88  0
     this.fieldName = pFieldName;
 89  0
     this.additionalInfo = pAdditionalInfo;
 90  0
     fixed = false ;
 91  
 
 92  0
     msg = getMessage() ;
 93  0
   }
 94  
 
 95  
   public String getMessage()
 96  
   {
 97  0
     String back = Globals.getIntegrityMessage("ITEXT_"+type) ;
 98  0
     if ((back != null) && (fieldName != null))
 99  
     {
 100  0
       back = back.replaceAll( "\\$FIELD", fieldName ) ;
 101  
     }
 102  0
     return back ;
 103  
   }
 104  
 
 105  
   public String toString()
 106  
   {
 107  0
     String back = msg ;
 108  0
     if (printMode == FULL_MODE)
 109  
     {
 110  0
       back = "[" + entry.getCiteKey() + "] " + msg ;
 111  
     }
 112  0
     return back ;
 113  
   }
 114  
 
 115  
   public int getType()
 116  
   {
 117  0
     return type;
 118  
   }
 119  
 
 120  
   public BibtexEntry getEntry()
 121  
   {
 122  0
     return entry;
 123  
   }
 124  
 
 125  
   public String getFieldName()
 126  
   {
 127  0
     return fieldName;
 128  
   }
 129  
 
 130  
   public Object getAdditionalInfo()
 131  
   {
 132  0
     return additionalInfo;
 133  
   }
 134  
 
 135  
   public boolean getFixed()
 136  
   {
 137  0
     return fixed;
 138  
   }
 139  
 
 140  
   public void setFixed(boolean pFixed)
 141  
   {
 142  0
     this.fixed = pFixed;
 143  0
   }
 144  
 }