Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/bdgp/apps/dagedit/dataadapter/CompoundGOFlatFileParseException.java


1   package org.bdgp.apps.dagedit.dataadapter;
2   
3   import java.util.Vector;
4   
5   public class CompoundGOFlatFileParseException extends GOFlatFileParseException {
6       protected final static int MAX_ERRORS = 100;
7       Vector exceptions = new Vector();
8       protected boolean empty;
9       protected boolean hideDownstream;
10      protected String message;
11  
12      public CompoundGOFlatFileParseException(boolean hideDownstream) {
13    super("compound exception");
14    this.hideDownstream = hideDownstream;
15    empty = true;
16      }
17  
18      public CompoundGOFlatFileParseException() {
19    this(false);
20      }    
21  
22      public boolean isEmpty() {
23    return empty;
24      }
25  
26      public boolean isFull() {
27    return exceptions.size() >= MAX_ERRORS;
28      }
29  
30      public void addException(GOFlatFileParseException e) throws GOFlatFileParseException {
31    if (empty) {
32        lineNumber = e.getLineNumber();
33        colNumber = e.getColNumber();
34        line = e.getLine();
35        message = e.getMessage();
36        empty = false;
37    }
38    boolean ignoreException = false;
39    if (exceptions.size() > 0) {
40        GOFlatFileParseException last = (GOFlatFileParseException)
41      exceptions.elementAt(exceptions.size() - 1);
42        if (last.getLineNumber() == e.getLineNumber() &&
43      hideDownstream)
44      ignoreException = true;
45    }
46    if (!ignoreException)
47        exceptions.addElement(e);
48    if (isFull())
49        throw this;
50      }
51  
52      public String getMessage() {
53    return message;
54      }
55  
56      public String toString() {
57    StringBuffer out = new StringBuffer();
58    for(int i=0; i < exceptions.size(); i++) {
59        out.append(exceptions.elementAt(i).toString() + "\n\n");
60    }
61    out.append(exceptions.size()+" errors");
62    if (isFull())
63        out.append("\n(note: there may be more errors; only "+
64             MAX_ERRORS+" errors are reported at a time)");
65    return out.toString();
66      }
67  }