Author: mostarda
Date: Sun Feb 5 13:58:33 2012
New Revision: 1240736
URL: http://svn.apache.org/viewvc?rev=1240736&view=rev
Log:
Renamed ErrorReporter to IssueReport, to be compliant with the naming convention
used within the code base. Renamed refereces to error to issue to improve code
readability and standardize the code base glossary.
This commit is related to issue #ANY23-45
Added:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java
(contents, props changed)
- copied, changed from r1240568,
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ErrorReporter.java
Removed:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ErrorReporter.java
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/Any23.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/ExtractionReport.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResult.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResultImpl.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtraction.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtractionReport.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/LicenseExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/MicroformatExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TitleExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/XFNExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/microdata/MicrodataExtractor.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
incubator/any23/trunk/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/ExtractionResultImplTest.java
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/ExtractionExceptionTest.java
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java
Modified: incubator/any23/trunk/core/src/main/java/org/apache/any23/Any23.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/Any23.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/main/java/org/apache/any23/Any23.java
(original)
+++ incubator/any23/trunk/core/src/main/java/org/apache/any23/Any23.java Sun
Feb 5 13:58:33 2012
@@ -310,7 +310,7 @@ public class Any23 {
ex.getParserEncoding(),
ex.getDetectedMIMEType(),
sder.getValidationReport(),
- sder.getExtractorToErrors()
+ sder.getExtractorToIssues()
);
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/ExtractionReport.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/ExtractionReport.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/ExtractionReport.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/ExtractionReport.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.Extractor;
import org.apache.any23.validator.ValidationReport;
@@ -45,14 +45,14 @@ public class ExtractionReport {
private final ValidationReport validationReport;
- private final Map<String,Collection<ErrorReporter.Error>> extractorErrors;
+ private final Map<String,Collection<IssueReport.Issue>> extractorIssues;
public ExtractionReport(
final List<Extractor> matchingExtractors,
String encoding,
String detectedMimeType,
ValidationReport validationReport,
- Map<String,Collection<ErrorReporter.Error>> extractorErrors
+ Map<String,Collection<IssueReport.Issue>> extractorIssues
) {
if(matchingExtractors == null) throw new NullPointerException("list of
matching extractors cannot be null.");
if(encoding == null) throw new NullPointerException("encoding cannot
be null.");
@@ -63,7 +63,7 @@ public class ExtractionReport {
this.encoding = encoding;
this.detectedMimeType = detectedMimeType;
this.validationReport = validationReport;
- this.extractorErrors =
Collections.unmodifiableMap(extractorErrors);
+ this.extractorIssues =
Collections.unmodifiableMap(extractorIssues);
}
/**
@@ -104,13 +104,13 @@ public class ExtractionReport {
/**
* @param extractorName name of the extractor.
- * @return the (unmodifiable) map of errors per extractor.
+ * @return the (unmodifiable) map of issues per extractor.
*/
- public Collection<ErrorReporter.Error> getExtractorErrors(String
extractorName) {
- final Collection<ErrorReporter.Error> errors =
extractorErrors.get(extractorName);
+ public Collection<IssueReport.Issue> getExtractorIssues(String
extractorName) {
+ final Collection<IssueReport.Issue> errors =
extractorIssues.get(extractorName);
return errors == null
?
- Collections.<ErrorReporter.Error>emptyList()
+ Collections.<IssueReport.Issue>emptyList()
:
Collections.unmodifiableCollection(errors);
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResult.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResult.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResult.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResult.java
Sun Feb 5 13:58:33 2012
@@ -24,7 +24,7 @@ import org.openrdf.model.Value;
/**
* Interface defining the methods that a representation of an extraction
result must have.
*/
-public interface ExtractionResult extends ErrorReporter {
+public interface ExtractionResult extends IssueReport {
/**
* Writes a triple.
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResultImpl.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResultImpl.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResultImpl.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ExtractionResultImpl.java
Sun Feb 5 13:58:33 2012
@@ -70,7 +70,7 @@ public class ExtractionResultImpl implem
private boolean isInitialized = false;
- private List<Error> errors;
+ private List<Issue> issues;
private List<ResourceRoot> resourceRoots;
@@ -97,31 +97,31 @@ public class ExtractionResultImpl implem
knownContextIDs.add( context.getUniqueID() );
}
- public boolean hasErrors() {
- return errors != null;
+ public boolean hasIssues() {
+ return issues != null;
}
- public int getErrorsCount() {
- return errors == null ? 0 : errors.size();
+ public int getIssuesCount() {
+ return issues == null ? 0 : issues.size();
}
- public void printErrorsReport(PrintStream ps) {
- ps.print(String.format("Context: %s [errors: %d] {\n", context,
getErrorsCount()));
- if (errors != null) {
- for (Error error : errors) {
- ps.print(error.toString());
+ public void printReport(PrintStream ps) {
+ ps.print(String.format("Context: %s [errors: %d] {\n", context,
getIssuesCount()));
+ if (issues != null) {
+ for (Issue issue : issues) {
+ ps.print(issue.toString());
ps.print("\n");
}
}
// Printing sub results.
for (ExtractionResult er : subResults) {
- er.printErrorsReport(ps);
+ er.printReport(ps);
}
ps.print("}\n");
}
- public Collection<Error> getErrors() {
- return errors == null ? Collections.<Error>emptyList() :
Collections.unmodifiableList(errors);
+ public Collection<Issue> getIssues() {
+ return issues == null ? Collections.<Issue>emptyList() :
Collections.unmodifiableList(issues);
}
public ExtractionResult openSubResult(ExtractionContext context) {
@@ -175,11 +175,11 @@ public class ExtractionResultImpl implem
}
}
- public void notifyError(ErrorLevel level, String msg, int row, int col) {
- if(errors == null) {
- errors = new ArrayList<Error>();
+ public void notifyIssue(IssueLevel level, String msg, int row, int col) {
+ if(issues == null) {
+ issues = new ArrayList<Issue>();
}
- errors.add( new Error(level, msg, row, col) );
+ issues.add(new Issue(level, msg, row, col));
}
public void close() {
@@ -274,11 +274,11 @@ public class ExtractionResultImpl implem
final StringBuilder sb = new StringBuilder();
sb.append(context.toString());
sb.append('\n');
- if (errors != null) {
+ if (issues != null) {
sb.append("Errors {\n");
- for (Error error : errors) {
+ for (Issue issue : issues) {
sb.append('\t');
- sb.append(error.toString());
+ sb.append(issue.toString());
sb.append('\n');
}
}
Copied:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java
(from r1240568,
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ErrorReporter.java)
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java?p2=incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java&p1=incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ErrorReporter.java&r1=1240568&r2=1240736&rev=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/ErrorReporter.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java
Sun Feb 5 13:58:33 2012
@@ -21,63 +21,62 @@ import java.io.PrintStream;
import java.util.Collection;
/**
- * This interface models an error reporter.
+ * This interface models an issue reporter.
*
* @author Michele Mostarda ([email protected])
*/
-// TODO: rename ErrorReporter in IssueReporter ( most of reported errors are
not blocking ).
-public interface ErrorReporter {
+public interface IssueReport {
/**
- * Notifies an error occurred while performing an extraction on an input
stream.
+ * Notifies an issue occurred while performing an extraction on an input
stream.
*
- * @param level error level.
- * @param msg error message.
- * @param row error row.
- * @param col error column.
+ * @param level issue level.
+ * @param msg issue message.
+ * @param row issue row.
+ * @param col issue column.
*/
- void notifyError(ErrorLevel level, String msg, int row, int col);
+ void notifyIssue(IssueLevel level, String msg, int row, int col);
/**
- * Prints out an errors report.
+ * Prints out the content of the report.
*
* @param ps
*/
- void printErrorsReport(PrintStream ps);
+ void printReport(PrintStream ps);
/**
- * Returns all the collected errors.
+ * Returns all the collected issues.
*
- * @return a collection of {@link ErrorReporter.Error}s.
+ * @return a collection of {@link
org.apache.any23.extractor.IssueReport.Issue}s.
*/
- Collection<Error> getErrors();
+ Collection<Issue> getIssues();
/**
- * Possible error levels.
+ * Possible issue levels.
*/
- enum ErrorLevel {
- WARN,
- ERROR,
- FATAL
+ enum IssueLevel {
+ Warning,
+ Error,
+ Fatal
}
/**
- * This class defines a generic error traced by this extraction result.
+ * This class defines a generic issue traced by this extraction result.
*/
- public class Error {
+ public class Issue {
- private ErrorLevel level;
- private String message;
- private int row, col;
+ private IssueLevel level;
+ private String message;
+ private int row, col;
- Error(ErrorLevel l, String msg, int r, int c) {
+ Issue(IssueLevel l, String msg, int r, int c) {
level = l;
message = msg;
row = r;
col = c;
}
- public ErrorLevel getLevel() {
+ public IssueLevel getLevel() {
return level;
}
Propchange:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/IssueReport.java
------------------------------------------------------------------------------
svn:keywords = Date Rev Author Id
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtraction.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtraction.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtraction.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtraction.java
Sun Feb 5 13:58:33 2012
@@ -251,8 +251,8 @@ public class SingleDocumentExtraction {
// Create the document context.
final List<ResourceRoot> resourceRoots = new ArrayList<ResourceRoot>();
final List<PropertyPath> propertyPaths = new ArrayList<PropertyPath>();
- final Map<String,Collection<ErrorReporter.Error>> extractorToErrors =
- new HashMap<String,Collection<ErrorReporter.Error>>();
+ final Map<String,Collection<IssueReport.Issue>> extractorToIssues =
+ new HashMap<String,Collection<IssueReport.Issue>>();
try {
final String documentLanguage =
extractDocumentLanguage(extractionParameters);
for (ExtractorFactory<?> factory : matchingExtractors) {
@@ -264,7 +264,7 @@ public class SingleDocumentExtraction {
);
resourceRoots.addAll( er.resourceRoots );
propertyPaths.addAll( er.propertyPaths );
- extractorToErrors.put(factory.getExtractorName(), er.errors);
+ extractorToIssues.put(factory.getExtractorName(), er.issues);
}
} catch(ValidatorException ve) {
throw new ExtractionException("An error occurred during the
validation phase.", ve);
@@ -307,7 +307,7 @@ public class SingleDocumentExtraction {
documentReport == null
?
EmptyValidationReport.getInstance() :
documentReport.getReport(),
- extractorToErrors
+ extractorToIssues
);
}
@@ -485,7 +485,7 @@ public class SingleDocumentExtraction {
}
return
new SingleExtractionReport(
- extractionResult.getErrors(),
+ extractionResult.getIssues(),
new ArrayList<ResourceRoot>(
extractionResult.getResourceRoots() ),
new ArrayList<PropertyPath>(
extractionResult.getPropertyPaths() )
);
@@ -496,9 +496,9 @@ public class SingleDocumentExtraction {
throw ex;
} finally {
// Logging result error report.
- if( log.isDebugEnabled() && extractionResult.hasErrors() ) {
+ if(log.isDebugEnabled() && extractionResult.hasIssues() ) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- extractionResult.printErrorsReport( new PrintStream(baos) );
+ extractionResult.printReport(new PrintStream(baos));
log.debug(baos.toString());
}
extractionResult.close();
@@ -860,16 +860,16 @@ public class SingleDocumentExtraction {
* Entity detection report.
*/
private class SingleExtractionReport {
- private final Collection<ErrorReporter.Error> errors;
- private final List<ResourceRoot> resourceRoots;
- private final List<PropertyPath> propertyPaths;
+ private final Collection<IssueReport.Issue> issues;
+ private final List<ResourceRoot> resourceRoots;
+ private final List<PropertyPath> propertyPaths;
public SingleExtractionReport(
- Collection<ErrorReporter.Error> errors,
+ Collection<IssueReport.Issue> issues,
List<ResourceRoot> resourceRoots,
List<PropertyPath> propertyPaths
) {
- this.errors = errors;
+ this.issues = issues;
this.resourceRoots = resourceRoots;
this.propertyPaths = propertyPaths;
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtractionReport.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtractionReport.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtractionReport.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/SingleDocumentExtractionReport.java
Sun Feb 5 13:58:33 2012
@@ -32,24 +32,24 @@ public class SingleDocumentExtractionRep
private final ValidationReport validationReport;
- private final Map<String, Collection<ErrorReporter.Error>>
extractorToErrors;
+ private final Map<String, Collection<IssueReport.Issue>> extractorToIssues;
public SingleDocumentExtractionReport(
ValidationReport validationReport,
- Map<String, Collection<ErrorReporter.Error>> extractorToErrors
+ Map<String, Collection<IssueReport.Issue>> extractorToIssues
) {
if(validationReport == null) throw new
NullPointerException("validation report cannot be null.");
- if(extractorToErrors == null) throw new
NullPointerException("extractor errors map cannot be null.");
+ if(extractorToIssues == null) throw new
NullPointerException("extractor issues map cannot be null.");
this.validationReport = validationReport;
- this.extractorToErrors = extractorToErrors;
+ this.extractorToIssues = extractorToIssues;
}
public ValidationReport getValidationReport() {
return validationReport;
}
- public Map<String, Collection<ErrorReporter.Error>> getExtractorToErrors()
{
- return extractorToErrors;
+ public Map<String, Collection<IssueReport.Issue>> getExtractorToIssues() {
+ return extractorToIssues;
}
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/LicenseExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/LicenseExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/LicenseExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/LicenseExtractor.java
Sun Feb 5 13:58:33 2012
@@ -23,6 +23,7 @@ import org.apache.any23.extractor.Extrac
import org.apache.any23.extractor.ExtractionResult;
import org.apache.any23.extractor.ExtractorDescription;
import org.apache.any23.extractor.ExtractorFactory;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.SimpleExtractorFactory;
import org.apache.any23.rdf.PopularPrefixes;
import org.apache.any23.vocab.XHTML;
@@ -66,8 +67,8 @@ public class LicenseExtractor implements
for (Node node : DomUtils.findAll(in, "//A[@rel='license']/@href")) {
String link = node.getNodeValue();
if ("".equals(link)) {
- out.notifyError(
- ExtractionResult.ErrorLevel.WARN,
+ out.notifyIssue(
+ IssueReport.IssueLevel.Warning,
String.format(
"Invalid license link detected within document
%s.",
documentURI.toString()
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/MicroformatExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/MicroformatExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/MicroformatExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/MicroformatExtractor.java
Sun Feb 5 13:58:33 2012
@@ -22,6 +22,7 @@ import org.apache.any23.extractor.Extrac
import org.apache.any23.extractor.ExtractionParameters;
import org.apache.any23.extractor.ExtractionResult;
import org.apache.any23.extractor.ExtractorDescription;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.TagSoupExtractionResult;
import org.apache.any23.extractor.html.annotations.Includes;
import org.apache.any23.rdf.Any23ValueFactoryWrapper;
@@ -94,11 +95,11 @@ public abstract class MicroformatExtract
this.context = extractionContext;
this.documentURI = extractionContext.getDocumentURI();
this.out = out;
- valueFactory.setErrorReporter(out);
+ valueFactory.setIssueReport(out);
try {
extract();
} finally {
- valueFactory.setErrorReporter(null);
+ valueFactory.setIssueReport(null);
}
}
@@ -158,11 +159,11 @@ public abstract class MicroformatExtract
) {
final String literalStr = literal.stringValue();
if( containsScriptBlock(literalStr) ) {
- out.notifyError(
- ExtractionResult.ErrorLevel.WARN,
+ out.notifyIssue(
+ IssueReport.IssueLevel.Warning,
String.format("Detected script in literal: [%s]",
literalStr)
- ,-1
- ,-1
+ , -1
+ , -1
);
return false;
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TitleExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TitleExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TitleExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TitleExtractor.java
Sun Feb 5 13:58:33 2012
@@ -71,7 +71,7 @@ public class TitleExtractor implements T
out.writeTriple(extractionContext.getDocumentURI(),
vDCTERMS.title, valueFactory.createLiteral(title));
}
} finally {
- valueFactory.setErrorReporter(null);
+ valueFactory.setIssueReport(null);
}
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/TurtleHTMLExtractor.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.html;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionContext;
import org.apache.any23.extractor.ExtractionException;
import org.apache.any23.extractor.ExtractionParameters;
@@ -118,16 +118,16 @@ public class TurtleHTMLExtractor impleme
try {
turtleParser.parse( new StringReader(n.getTextContent()),
graphName );
} catch (RDFParseException rdfpe) {
- er.notifyError(
- ErrorReporter.ErrorLevel.ERROR,
+ er.notifyIssue(
+ IssueReport.IssueLevel.Error,
String.format(
"An error occurred while parsing turtle content
within script node: %s",
- Arrays.toString( DomUtils.getXPathListForNode(n) )
+ Arrays.toString(DomUtils.getXPathListForNode(n))
),
rdfpe.getLineNumber(), rdfpe.getColumnNumber()
);
} catch (Exception e) {
- er.notifyError(ErrorReporter.ErrorLevel.ERROR, "An error occurred
while processing RDF data.", -1 , -1);
+ er.notifyIssue(IssueReport.IssueLevel.Error, "An error occurred
while processing RDF data.", -1, -1);
}
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/XFNExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/XFNExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/XFNExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/html/XFNExtractor.java
Sun Feb 5 13:58:33 2012
@@ -75,7 +75,7 @@ public class XFNExtractor implements Tag
Document in,
ExtractionResult out
) throws IOException, ExtractionException {
- factoryWrapper.setErrorReporter(out);
+ factoryWrapper.setIssueReport(out);
try {
document = new HTMLDocument(in);
this.out = out;
@@ -90,7 +90,7 @@ public class XFNExtractor implements Tag
out.writeTriple(subject, RDF.TYPE, vFOAF.Person);
out.writeTriple(subject, vXFN.mePage, documentURI);
} finally {
- factoryWrapper.setErrorReporter(null);
+ factoryWrapper.setIssueReport(null);
}
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/microdata/MicrodataExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/microdata/MicrodataExtractor.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/microdata/MicrodataExtractor.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/microdata/MicrodataExtractor.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.microdata;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionContext;
import org.apache.any23.extractor.ExtractionException;
import org.apache.any23.extractor.ExtractionParameters;
@@ -561,10 +561,10 @@ public class MicrodataExtractor implemen
private void notifyError(MicrodataParserException[] errors,
ExtractionResult out) {
for(MicrodataParserException mpe : errors) {
- out.notifyError(
- ErrorReporter.ErrorLevel.ERROR,
+ out.notifyIssue(
+ IssueReport.IssueLevel.Error,
mpe.toJSON(),
- mpe.getErrorLocationBeginRow() ,
+ mpe.getErrorLocationBeginRow(),
mpe.getErrorLocationBeginCol()
);
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdf/RDFParserFactory.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.rdf;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionContext;
import org.apache.any23.extractor.ExtractionResult;
import org.apache.any23.io.nquads.NQuadsParser;
@@ -198,15 +198,15 @@ public class RDFParserFactory {
*/
private class InternalParseErrorListener implements ParseErrorListener {
- private final ErrorReporter extractionResult;
+ private final IssueReport extractionResult;
- public InternalParseErrorListener(ErrorReporter er) {
+ public InternalParseErrorListener(IssueReport er) {
extractionResult = er;
}
public void warning(String msg, int lineNo, int colNo) {
try {
- extractionResult.notifyError(ExtractionResult.ErrorLevel.WARN,
msg, lineNo, colNo);
+ extractionResult.notifyIssue(IssueReport.IssueLevel.Warning,
msg, lineNo, colNo);
} catch (Exception e) {
notifyExceptionInNotification(e);
}
@@ -214,7 +214,7 @@ public class RDFParserFactory {
public void error(String msg, int lineNo, int colNo) {
try {
-
extractionResult.notifyError(ExtractionResult.ErrorLevel.ERROR, msg, lineNo,
colNo);
+ extractionResult.notifyIssue(IssueReport.IssueLevel.Error,
msg, lineNo, colNo);
} catch (Exception e) {
notifyExceptionInNotification(e);
}
@@ -222,7 +222,7 @@ public class RDFParserFactory {
public void fatalError(String msg, int lineNo, int colNo) {
try {
-
extractionResult.notifyError(ExtractionResult.ErrorLevel.FATAL, msg, lineNo,
colNo);
+ extractionResult.notifyIssue(IssueReport.IssueLevel.Fatal,
msg, lineNo, colNo);
} catch (Exception e) {
notifyExceptionInNotification(e);
}
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.rdfa;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionResult;
import org.apache.any23.extractor.html.DomUtils;
import org.apache.any23.rdf.RDFUtils;
@@ -93,7 +93,7 @@ public class RDFa11Parser {
public static final String XMLNS_DEFAULT = "http://www.w3.org/1999/xhtml";
- private ErrorReporter errorReporter;
+ private IssueReport issueReport;
private URL documentBase;
@@ -205,7 +205,7 @@ public class RDFa11Parser {
public void processDocument(URL documentURL, Document document,
ExtractionResult extractionResult)
throws RDFa11ParserException {
try {
- this.errorReporter = extractionResult;
+ this.issueReport = extractionResult;
// Check RDFa1.0[4.1.3] : default XMLNS declaration.
if( ! isXMLNSDeclared(document)) {
@@ -241,7 +241,7 @@ public class RDFa11Parser {
* Resets the parser to the original state.
*/
public void reset() {
- errorReporter = null;
+ issueReport = null;
documentBase = null;
uriMappingStack.clear();
listOfIncompleteTriples.clear();
@@ -459,8 +459,8 @@ public class RDFa11Parser {
DomUtils.getXPathForNode(n), msg
);
final int[] errorLocation = DomUtils.getNodeLocation(n);
- this.errorReporter.notifyError(
- ErrorReporter.ErrorLevel.WARN,
+ this.issueReport.notifyIssue(
+ IssueReport.IssueLevel.Warning,
errorMsg,
errorLocation == null ? -1 : errorLocation[0],
errorLocation == null ? -1 : errorLocation[1]
Modified:
incubator/any23/trunk/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
(original)
+++
incubator/any23/trunk/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.rdf;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.openrdf.model.BNode;
import org.openrdf.model.Literal;
import org.openrdf.model.Resource;
@@ -41,7 +41,7 @@ public class Any23ValueFactoryWrapper im
private final ValueFactory wrappedFactory;
- private ErrorReporter errorReporter;
+ private IssueReport issueReport;
private String defaultLiteralLanguage;
@@ -54,18 +54,18 @@ public class Any23ValueFactoryWrapper im
*/
public Any23ValueFactoryWrapper(
final ValueFactory factory,
- ErrorReporter er,
+ IssueReport er,
String defaultLitLanguage
) {
if(factory == null) {
throw new NullPointerException("factory cannot be null.");
}
wrappedFactory = factory;
- errorReporter = er;
+ issueReport = er;
defaultLiteralLanguage = defaultLitLanguage;
}
- public Any23ValueFactoryWrapper(final ValueFactory vFactory, ErrorReporter
er) {
+ public Any23ValueFactoryWrapper(final ValueFactory vFactory, IssueReport
er) {
this(vFactory, er, null);
}
@@ -73,12 +73,12 @@ public class Any23ValueFactoryWrapper im
this(vFactory, null, null);
}
- public ErrorReporter getErrorReporter() {
- return errorReporter;
+ public IssueReport getIssueReport() {
+ return issueReport;
}
- public void setErrorReporter(ErrorReporter er) {
- errorReporter = er;
+ public void setIssueReport(IssueReport er) {
+ issueReport = er;
}
public String getDefaultLiteralLanguage() {
@@ -227,10 +227,10 @@ public class Any23ValueFactoryWrapper im
* @param e error to be reported.
*/
private void reportError(Exception e) {
- if(errorReporter == null) {
+ if(issueReport == null) {
logger.warn(e.getMessage());
} else {
- errorReporter.notifyError(ErrorReporter.ErrorLevel.WARN,
e.getMessage(), -1 , -1);
+ issueReport.notifyIssue(IssueReport.IssueLevel.Warning,
e.getMessage(), -1, -1);
}
}
Modified:
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/ExtractionResultImplTest.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/ExtractionResultImplTest.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/ExtractionResultImplTest.java
(original)
+++
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/ExtractionResultImplTest.java
Sun Feb 5 13:58:33 2012
@@ -79,23 +79,23 @@ public class ExtractionResultImplTest {
}
private void notifyErrors(ExtractionResult er) {
- er.notifyError(ExtractionResult.ErrorLevel.ERROR, "Error message" ,
1, 2);
- er.notifyError(ExtractionResult.ErrorLevel.WARN, "Warning message",
3, 4);
- er.notifyError(ExtractionResult.ErrorLevel.FATAL, "Fatal message" ,
5, 6);
+ er.notifyIssue(IssueReport.IssueLevel.Error , "Error message" , 1,
2);
+ er.notifyIssue(IssueReport.IssueLevel.Warning, "Warning message", 3,
4);
+ er.notifyIssue(IssueReport.IssueLevel.Fatal , "Fatal message" , 5,
6);
}
private void assertContent(ExtractionResult er) {
- Assert.assertEquals("Unexpected errors list size." , 3,
er.getErrors().size() );
- assertOutputString(er, "ERROR");
- assertOutputString(er, "WARN");
- assertOutputString(er, "FATAL");
+ Assert.assertEquals("Unexpected errors list size." , 3,
er.getIssues().size() );
+ assertOutputString(er, IssueReport.IssueLevel.Error.toString());
+ assertOutputString(er, IssueReport.IssueLevel.Warning.toString());
+ assertOutputString(er, IssueReport.IssueLevel.Fatal.toString());
assertOutputString(er, "errors: 3");
}
private void assertOutputString(ExtractionResult er, String s) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
- er.printErrorsReport(ps);
+ er.printReport(ps);
ps.flush();
Assert.assertTrue( String.format("Cannot find string '%s' in output
stream.", s), baos.toString().contains(s) );
}
Modified:
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
(original)
+++
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/AbstractExtractorTestCase.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.html;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionException;
import org.apache.any23.extractor.ExtractorFactory;
import org.apache.any23.extractor.SingleDocumentExtraction;
@@ -125,31 +125,31 @@ public abstract class AbstractExtractorT
}
/**
- * Returns the list of errors raised by a given extractor.
+ * Returns the list of issues raised by a given extractor.
*
* @param extractorName name of the extractor.
- * @return collection of errors.
+ * @return collection of issues.
*/
- protected Collection<ErrorReporter.Error> getErrors(String extractorName) {
+ protected Collection<IssueReport.Issue> getIssues(String extractorName) {
for(
- Map.Entry<String, Collection<ErrorReporter.Error>> errorEntry
+ Map.Entry<String, Collection<IssueReport.Issue>> issueEntry
:
- report.getExtractorToErrors().entrySet()
+ report.getExtractorToIssues().entrySet()
) {
- if(errorEntry.getKey().equals(extractorName)) {
- return errorEntry.getValue();
+ if(issueEntry.getKey().equals(extractorName)) {
+ return issueEntry.getValue();
}
}
return Collections.emptyList();
}
/**
- * Returns the list of errors raised by the extractor under testing.
+ * Returns the list of issues raised by the extractor under testing.
*
- * @return collection of errors.
+ * @return collection of issues.
*/
- protected Collection<ErrorReporter.Error> getErrors() {
- return getErrors( getExtractorFactory().getExtractorName() );
+ protected Collection<IssueReport.Issue> getIssues() {
+ return getIssues(getExtractorFactory().getExtractorName());
}
/**
@@ -304,10 +304,10 @@ public abstract class AbstractExtractorT
}
/**
- * Asserts that the extraction generated no errors.
+ * Asserts that the extraction generated no issues.
*/
protected void assertNoIssues() {
- for( Map.Entry<String, Collection<ErrorReporter.Error>> entry :
report.getExtractorToErrors().entrySet() ) {
+ for( Map.Entry<String, Collection<IssueReport.Issue>> entry :
report.getExtractorToIssues().entrySet() ) {
if(entry.getValue().size() > 0) {
Assert.fail("Unexpected issue for extractor " + entry.getKey()
+ " : " + entry.getValue());
}
@@ -315,22 +315,22 @@ public abstract class AbstractExtractorT
}
/**
- * Asserts that an error has been produced by the processed {@link
org.apache.any23.extractor.Extractor}.
+ * Asserts that an issue has been produced by the processed {@link
org.apache.any23.extractor.Extractor}.
*
- * @param level expected error level
- * @param errorRegex regex matching the expected human readable error
message.
+ * @param level expected issue level
+ * @param issueRegex regex matching the expected human readable issue
message.
*/
- protected void assertError(ErrorReporter.ErrorLevel level, String
errorRegex) {
- final Collection<ErrorReporter.Error> errors = getErrors(
getExtractorFactory().getExtractorName() );
+ protected void assertIssue(IssueReport.IssueLevel level, String
issueRegex) {
+ final Collection<IssueReport.Issue> issues =
getIssues(getExtractorFactory().getExtractorName());
boolean found = false;
- for(ErrorReporter.Error error : errors) {
- if(error.getLevel() == level &&
error.getMessage().matches(errorRegex)) {
+ for(IssueReport.Issue issue : issues) {
+ if(issue.getLevel() == level &&
issue.getMessage().matches(issueRegex)) {
found = true;
break;
}
}
Assert.assertTrue(
- String.format("Cannot find error with level %s matching
expression '%s'", level, errorRegex),
+ String.format("Cannot find issue with level %s matching
expression '%s'", level, issueRegex),
found
);
}
Modified:
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java
(original)
+++
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.html;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractorFactory;
import org.apache.any23.rdf.RDFUtils;
import org.apache.any23.vocab.SINDICE;
@@ -74,11 +74,11 @@ public class LicenseExtractorTest extend
assertNotContains(baseURI, vXHTML.license, "");
assertContains(baseURI, vXHTML.license, apache);
- final Collection<ErrorReporter.Error> errors = getErrors();
+ final Collection<IssueReport.Issue> errors = getIssues();
Assert.assertEquals(1, errors.size());
- ErrorReporter.Error error = errors.iterator().next();
+ IssueReport.Issue error = errors.iterator().next();
Assert.assertTrue(error.getMessage().contains("Invalid license link
detected"));
- Assert.assertEquals(ErrorReporter.ErrorLevel.WARN, error.getLevel());
+ Assert.assertEquals(IssueReport.IssueLevel.Warning, error.getLevel());
}
@Test
Modified:
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/ExtractionExceptionTest.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/ExtractionExceptionTest.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/ExtractionExceptionTest.java
(original)
+++
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/ExtractionExceptionTest.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.rdfa;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionContext;
import org.apache.any23.extractor.ExtractionException;
import org.apache.any23.extractor.ExtractionResult;
@@ -58,9 +58,9 @@ public class ExtractionExceptionTest {
new URIImpl("http://fake.document.uri")
);
final ExtractionResult er = new
ExtractionResultImpl(extractionContext, extractor, th);
- er.notifyError(ErrorReporter.ErrorLevel.FATAL, "Fake fatal error.", 1,
2);
- er.notifyError(ErrorReporter.ErrorLevel.ERROR, "Fake error." , 3,
4);
- er.notifyError(ErrorReporter.ErrorLevel.WARN , "Fake warning." , 5,
6);
+ er.notifyIssue(IssueReport.IssueLevel.Fatal , "Fake fatal error.", 1,
2);
+ er.notifyIssue(IssueReport.IssueLevel.Error , "Fake error." , 3,
4);
+ er.notifyIssue(IssueReport.IssueLevel.Warning, "Fake warning." , 5,
6);
ExtractionException ee = new ExtractionException("Fake message.", new
RuntimeException("Fake cause"), er);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified:
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java
URL:
http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java?rev=1240736&r1=1240735&r2=1240736&view=diff
==============================================================================
---
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java
(original)
+++
incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java
Sun Feb 5 13:58:33 2012
@@ -17,7 +17,7 @@
package org.apache.any23.extractor.rdfa;
-import org.apache.any23.extractor.ErrorReporter;
+import org.apache.any23.extractor.IssueReport;
import org.apache.any23.extractor.ExtractionException;
import org.apache.any23.extractor.ExtractorFactory;
import org.apache.any23.rdf.RDFUtils;
@@ -153,7 +153,7 @@ public class RDFa11ExtractorTest extends
@Test
public void testTolerantParsing() {
assertExtract("html/rdfa/oreilly-invalid-datatype.html", false);
- assertError(ErrorReporter.ErrorLevel.WARN, ".*Cannot map prefix
\'mailto\'.*");
+ assertIssue(IssueReport.IssueLevel.Warning, ".*Cannot map prefix
\'mailto\'.*");
}
/**