1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
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 | |
|
43 | |
public static final int |
44 | |
GENERIC_HINT = 1, |
45 | |
UPPER_AND_LOWER_HINT = 10, |
46 | |
FOUR_DIGITS_HINT = 11 |
47 | |
|
48 | |
; |
49 | |
|
50 | |
|
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 | |
|
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, |
66 | 41264 | SINLGE_MODE = 2 |
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 ; |
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 | |
} |