corpus-services  1.0
Publisher.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package de.uni_hamburg.corpora.publication;
7 
12 import java.io.IOException;
13 import java.net.URISyntaxException;
14 import java.security.NoSuchAlgorithmException;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import javax.xml.parsers.ParserConfigurationException;
18 import javax.xml.transform.TransformerException;
19 import javax.xml.xpath.XPathExpressionException;
20 import org.exmaralda.partitureditor.fsm.FSMException;
21 import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
22 import org.jdom.JDOMException;
23 import org.xml.sax.SAXException;
24 
29 public abstract class Publisher implements CorpusFunction {
30 
31  CorpusData cd;
32  Report report;
33  Collection<Class<? extends CorpusData>> IsUsableFor = new ArrayList<Class<? extends CorpusData>>();
34  final String function;
35  Boolean canfix = false;
36 
37  public Publisher(){
38  function = this.getClass().getSimpleName();
39  }
40 
41  public Report execute(Corpus c) {
42  report = new Report();
43  try {
44 
45  report = function(c);
46  } catch (JexmaraldaException je) {
47  report.addException(je, function, cd, "Unknown parsing error");
48  } catch (JDOMException jdome) {
49  report.addException(jdome, function, cd, "Unknown parsing error");
50  } catch (SAXException saxe) {
51  report.addException(saxe, function, cd, "Unknown parsing error");
52  } catch (IOException ioe) {
53  report.addException(ioe, function, cd, "File reading error");
54  } catch (FSMException ex) {
55  report.addException(ex, function, cd, "File reading error");
56  } catch (URISyntaxException ex) {
57  report.addException(ex, function, cd, "File reading erro");
58  } catch (ParserConfigurationException ex) {
59  report.addException(ex, function, cd, "File reading error");
60  } catch (TransformerException ex) {
61  report.addException(ex, function, cd, "File reading error");
62  } catch (XPathExpressionException ex) {
63  report.addException(ex, function, cd, "File reading error");
64  } catch (ClassNotFoundException ex) {
65  report.addException(ex, function, cd, "File reading error");
66  } catch (NoSuchAlgorithmException ex) {
67  report.addException(ex, function, cd, "File reading error");
68  }
69  return report;
70  }
71 
72  public Report execute(CorpusData cd) {
73  report = new Report();
74  try {
75  report = function(cd);
76  } catch (JexmaraldaException je) {
77  report.addException(je, function, cd, "Unknown parsing error");
78  } catch (JDOMException jdome) {
79  report.addException(jdome, function, cd, "Unknown parsing error");
80  } catch (SAXException saxe) {
81  report.addException(saxe, function, cd, "Unknown parsing error");
82  } catch (IOException ioe) {
83  report.addException(ioe, function, cd, "File reading error");
84  } catch (FSMException ex) {
85  report.addException(ex, function, cd, "File reading error");
86  } catch (URISyntaxException ex) {
87  report.addException(ex, function, cd, "File reading erro");
88  } catch (ParserConfigurationException ex) {
89  report.addException(ex, function, cd, "File reading error");
90  } catch (TransformerException ex) {
91  report.addException(ex, function, cd, "File reading error");
92  } catch (XPathExpressionException ex) {
93  report.addException(ex, function, cd, "File reading error");
94  } catch (ClassNotFoundException ex) {
95  report.addException(ex, function, cd, "File reading error");
96  } catch (NoSuchAlgorithmException ex) {
97  report.addException(ex, function, cd, "File reading error");
98  }
99  return report;
100  }
101 
102  //no fix boolean needed
103  public Report execute(CorpusData cd, boolean fix) {
104  return execute(cd);
105  }
106 
107  //no fix boolean needed
108  public Report execute(Corpus c, boolean fix) {
109  return execute(c);
110  }
111 
112  //to be implemented in class
113  public abstract Report function(CorpusData cd) throws NoSuchAlgorithmException, ClassNotFoundException, FSMException, URISyntaxException, SAXException, IOException, ParserConfigurationException, JexmaraldaException, TransformerException, XPathExpressionException, JDOMException;
114 
115 
116  //to be implemented in class
117  public abstract Report function(Corpus c) throws NoSuchAlgorithmException, ClassNotFoundException, FSMException, URISyntaxException, SAXException, IOException, ParserConfigurationException, JexmaraldaException, TransformerException, XPathExpressionException, JDOMException;
118 
119 
120  public abstract Collection<Class<? extends CorpusData>> getIsUsableFor();
121 
122  public void setIsUsableFor(Collection<Class<? extends CorpusData>> cdc) {
123  for (Class<? extends CorpusData> cl : cdc) {
124  IsUsableFor.add(cl);
125  }
126  }
127 
128  public String getFunction() {
129  return function;
130  }
131 
132  public Boolean getCanFix() {
133  return canfix;
134  }
135 
136 }
Report execute(Corpus c, boolean fix)
Definition: Publisher.java:108
void setIsUsableFor(Collection< Class<?extends CorpusData >> cdc)
Definition: Publisher.java:122
void addException(Throwable e, String description)
Definition: Report.java:287
Report execute(CorpusData cd, boolean fix)
Definition: Publisher.java:103
abstract Collection< Class<?extends CorpusData > > getIsUsableFor()