You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/10/06 20:01:40 UTC
svn commit: r1707110 -
/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Author: tilman
Date: Tue Oct 6 18:01:40 2015
New Revision: 1707110
URL: http://svn.apache.org/viewvc?rev=1707110&view=rev
Log:
PDFBOX-2852: improve javadoc; rename parameter; simplify code
Modified:
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1707110&r1=1707109&r2=1707110&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java Tue Oct 6 18:01:40 2015
@@ -96,6 +96,12 @@ public class PreflightParser extends PDF
protected PreflightContext ctx;
+ /**
+ * Constructor.
+ *
+ * @param file
+ * @throws IOException if there is a reading error.
+ */
public PreflightParser(File file) throws IOException
{
// TODO move file handling outside of the parser
@@ -104,18 +110,31 @@ public class PreflightParser extends PDF
this.originalDocument = new FileDataSource(file);
}
+ /**
+ * Constructor.
+ *
+ * @param filename
+ * @throws IOException if there is a reading error.
+ */
public PreflightParser(String filename) throws IOException
{
// TODO move file handling outside of the parser
this(new File(filename));
}
- public PreflightParser(DataSource input) throws IOException
+ /**
+ * Constructor. This one is slower than the file and the filename constructors, because
+ * a temporary file will be created.
+ *
+ * @param dataSource the datasource
+ * @throws IOException if there is a reading error.
+ */
+ public PreflightParser(DataSource dataSource) throws IOException
{
// TODO move file handling outside of the parser
- super(new RandomAccessBufferedFileInputStream(input.getInputStream()));
+ super(new RandomAccessBufferedFileInputStream(dataSource.getInputStream()));
this.setLenient(false);
- this.originalDocument = input;
+ this.originalDocument = dataSource;
}
/**
@@ -126,8 +145,7 @@ public class PreflightParser extends PDF
protected static ValidationResult createUnknownErrorResult()
{
ValidationError error = new ValidationError(PreflightConstants.ERROR_UNKOWN_ERROR);
- ValidationResult result = new ValidationResult(error);
- return result;
+ return new ValidationResult(error);
}
/**
@@ -841,7 +859,7 @@ public class PreflightParser extends PDF
|| (buf.length - tmpOffset == 2 && (buf[tmpOffset] != 13 || buf[tmpOffset + 1] != 10))
|| (buf.length - tmpOffset == 1 && (buf[tmpOffset] != 13 && buf[tmpOffset] != 10)))
{
- long position = 0;
+ long position;
try
{
position = source.getPosition();