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 2020/12/23 10:45:51 UTC
svn commit: r1884743 [2/2] - in /pdfbox/trunk:
debugger/src/main/java/org/apache/pdfbox/debugger/
debugger/src/main/java/org/apache/pdfbox/debugger/treestatus/
debugger/src/main/java/org/apache/pdfbox/debugger/ui/
debugger/src/main/java/org/apache/pdfb...
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java Wed Dec 23 10:45:50 2020
@@ -33,7 +33,7 @@ import org.apache.pdfbox.pdmodel.graphic
public final class PDPattern extends PDSpecialColorSpace
{
/** A pattern which leaves no marks on the page. */
- private static PDColor EMPTY_PATTERN = new PDColor(new float[] { }, null);
+ private static final PDColor EMPTY_PATTERN = new PDColor(new float[] { }, null);
private final PDResources resources;
private PDColorSpace underlyingColorSpace;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java Wed Dec 23 10:45:50 2020
@@ -53,7 +53,7 @@ public final class LosslessFactory
/**
* Internal, only for benchmark purpose
*/
- static boolean usePredictorEncoder = true;
+ static final boolean usePredictorEncoder = true;
private LosslessFactory()
{
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java Wed Dec 23 10:45:50 2020
@@ -492,7 +492,7 @@ final class PNGConverter
private static class MultipleInputStream extends InputStream
{
- List<InputStream> inputStreams = new ArrayList<>();
+ final List<InputStream> inputStreams = new ArrayList<>();
int currentStreamIdx;
InputStream currentStream;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java Wed Dec 23 10:45:50 2020
@@ -28,7 +28,7 @@ import java.util.List;
abstract class Patch
{
protected Point2D[][] controlPoints;
- protected float[][] cornerColor;
+ protected final float[][] cornerColor;
/*
level = {levelU, levelV}, levelU defines the patch's u direction edges should be
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDAction.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDAction.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDAction.java Wed Dec 23 10:45:50 2020
@@ -42,7 +42,7 @@ public abstract class PDAction implement
/**
* The action dictionary.
*/
- protected COSDictionary action;
+ protected final COSDictionary action;
/**
* Default constructor.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDWindowsLaunchParams.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDWindowsLaunchParams.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDWindowsLaunchParams.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDWindowsLaunchParams.java Wed Dec 23 10:45:50 2020
@@ -40,7 +40,7 @@ public class PDWindowsLaunchParams imple
/**
* The params dictionary.
*/
- protected COSDictionary params;
+ protected final COSDictionary params;
/**
* Default constructor.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDAbstractAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDAbstractAppearanceHandler.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDAbstractAppearanceHandler.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDAbstractAppearanceHandler.java Wed Dec 23 10:45:50 2020
@@ -47,7 +47,7 @@ import org.apache.pdfbox.pdmodel.interac
public abstract class PDAbstractAppearanceHandler implements PDAppearanceHandler
{
private final PDAnnotation annotation;
- protected PDDocument document;
+ protected final PDDocument document;
/**
* Line ending styles where the line has to be drawn shorter (minus line width).
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/layout/PlainTextFormatter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/layout/PlainTextFormatter.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/layout/PlainTextFormatter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/layout/PlainTextFormatter.java Wed Dec 23 10:45:50 2020
@@ -84,7 +84,7 @@ public class PlainTextFormatter
{
// required parameters
- private PDAppearanceContentStream contents;
+ private final PDAppearanceContentStream contents;
// optional parameters
private AppearanceStyle appearanceStyle;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java Wed Dec 23 10:45:50 2020
@@ -33,7 +33,7 @@ import org.apache.pdfbox.pdmodel.common.
*/
public class PDPropBuild implements COSObjectable
{
- private COSDictionary dictionary;
+ private final COSDictionary dictionary;
/**
* Default constructor.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java Wed Dec 23 10:45:50 2020
@@ -34,7 +34,7 @@ public abstract class PDPageDestination
/**
* Storage for the page destination.
*/
- protected COSArray array;
+ protected final COSArray array;
/**
* Constructor to create empty page destination.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PlainTextFormatter.java Wed Dec 23 10:45:50 2020
@@ -84,7 +84,7 @@ class PlainTextFormatter
{
// required parameters
- private PDAppearanceContentStream contents;
+ private final PDAppearanceContentStream contents;
// optional parameters
private AppearanceStyle appearanceStyle;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/measurement/PDNumberFormatDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/measurement/PDNumberFormatDictionary.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/measurement/PDNumberFormatDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/measurement/PDNumberFormatDictionary.java Wed Dec 23 10:45:50 2020
@@ -1,323 +1,323 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.pdmodel.interactive.measurement;
-
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.common.COSObjectable;
-
-/**
- * This class represents a number format dictionary.
- *
- */
-public class PDNumberFormatDictionary implements COSObjectable
-{
-
- /**
- * The type of the dictionary.
- */
- public static final String TYPE = "NumberFormat";
-
- /**
- * Constant indicating that the label specified by U is a suffix to the value.
- */
- public static final String LABEL_SUFFIX_TO_VALUE = "S";
- /**
- * Constant indicating that the label specified by U is a postfix to the value.
- */
- public static final String LABEL_PREFIX_TO_VALUE = "P";
-
- /**
- * Constant for showing a fractional value as decimal to the precision specified by the D entry.
- */
- public static final String FRACTIONAL_DISPLAY_DECIMAL = "D";
- /**
- * Constant for showing a fractional value as a fraction with denominator specified by the D entry.
- */
- public static final String FRACTIONAL_DISPLAY_FRACTION = "F";
- /**
- * Constant for showing a fractional value without fractional part; round to the nearest whole unit.
- */
- public static final String FRACTIONAL_DISPLAY_ROUND = "R";
- /**
- * Constant for showing a fractional value without fractional part; truncate to achieve whole units.
- */
- public static final String FRACTIONAL_DISPLAY_TRUNCATE = "T";
-
- private COSDictionary numberFormatDictionary;
-
- /**
- * Constructor.
- */
- public PDNumberFormatDictionary()
- {
- this.numberFormatDictionary = new COSDictionary();
- this.numberFormatDictionary.setName(COSName.TYPE, TYPE);
- }
-
- /**
- * Constructor.
- *
- * @param dictionary the corresponding dictionary
- */
- public PDNumberFormatDictionary(COSDictionary dictionary)
- {
- this.numberFormatDictionary = dictionary;
- }
-
- /**
- * This will return the dictionary.
- *
- * @return the number format dictionary
- */
- @Override
- public COSDictionary getCOSObject()
- {
- return this.numberFormatDictionary;
- }
-
- /**
- * This will return the type of the number format dictionary.
- * It must be "NumberFormat"
- *
- * @return the type
- */
- public String getType()
- {
- return TYPE;
- }
-
- /**
- * This will return the label for the units.
- *
- * @return the label for the units
- */
- public String getUnits()
- {
- return this.getCOSObject().getString("U");
- }
-
- /**
- * This will set the label for the units.
- *
- * @param units the label for the units
- */
- public void setUnits(String units)
- {
- this.getCOSObject().setString("U", units);
- }
-
- /**
- * This will return the conversion factor.
- *
- * @return the conversion factor
- */
- public float getConversionFactor()
- {
- return this.getCOSObject().getFloat("C");
- }
-
- /**
- * This will set the conversion factor.
- *
- * @param conversionFactor the conversion factor
- */
- public void setConversionFactor(float conversionFactor)
- {
- this.getCOSObject().setFloat("C", conversionFactor);
- }
-
- /**
- * This will return the value for the manner to display a fractional value.
- *
- * @return the manner to display a fractional value
- */
- public String getFractionalDisplay()
- {
- return this.getCOSObject().getString("F", FRACTIONAL_DISPLAY_DECIMAL);
- }
-
- /**
- * This will set the value for the manner to display a fractional value.
- * Allowed values are "D", "F", "R" and "T"
- * @param fractionalDisplay the manner to display a fractional value
- */
- public void setFractionalDisplay(String fractionalDisplay)
- {
- if ((fractionalDisplay == null)
- || FRACTIONAL_DISPLAY_DECIMAL.equals(fractionalDisplay)
- || FRACTIONAL_DISPLAY_FRACTION.equals(fractionalDisplay)
- || FRACTIONAL_DISPLAY_ROUND.equals(fractionalDisplay)
- || FRACTIONAL_DISPLAY_TRUNCATE.equals(fractionalDisplay))
- {
- this.getCOSObject().setString("F", fractionalDisplay);
- }
- else
- {
- throw new IllegalArgumentException("Value must be \"D\", \"F\", \"R\", or \"T\", (or null).");
- }
- }
-
- /**
- * This will return the precision or denominator of a fractional amount.
- *
- * @return the precision or denominator
- */
- public int getDenominator()
- {
- return this.getCOSObject().getInt("D");
- }
-
- /**
- * This will set the precision or denominator of a fractional amount.
- *
- * @param denominator the precision or denominator
- */
- public void setDenominator(int denominator)
- {
- this.getCOSObject().setInt("D", denominator);
- }
-
- /**
- * This will return the value indication if the denominator of the fractional value is reduced/truncated .
- *
- * @return fd
- */
- public boolean isFD()
- {
- return this.getCOSObject().getBoolean("FD", false);
- }
-
- /**
- * This will set the value indication if the denominator of the fractional value is reduced/truncated .
- * The denominator may not be reduced/truncated if true
- * @param fd fd
- */
- public void setFD(boolean fd)
- {
- this.getCOSObject().setBoolean("FD", fd);
- }
-
- /**
- * This will return the text to be used between orders of thousands in display of numerical values.
- *
- * @return thousands separator
- */
- public String getThousandsSeparator()
- {
- return this.getCOSObject().getString("RT", ",");
- }
-
- /**
- * This will set the text to be used between orders of thousands in display of numerical values.
- *
- * @param thousandsSeparator thousands separator
- */
- public void setThousandsSeparator(String thousandsSeparator)
- {
- this.getCOSObject().setString("RT", thousandsSeparator);
- }
-
- /**
- * This will return the text to be used as the decimal point in displaying numerical values.
- *
- * @return decimal separator
- */
- public String getDecimalSeparator()
- {
- return this.getCOSObject().getString("RD", ".");
- }
-
- /**
- * This will set the text to be used as the decimal point in displaying numerical values.
- *
- * @param decimalSeparator decimal separator
- */
- public void setDecimalSeparator(String decimalSeparator)
- {
- this.getCOSObject().setString("RD", decimalSeparator);
- }
-
- /**
- * This will return the text to be concatenated to the left of the label specified by U.
- * @return label prefix
- */
- public String getLabelPrefixString()
- {
- return this.getCOSObject().getString("PS", " ");
- }
-
- /**
- * This will set the text to be concatenated to the left of the label specified by U.
- * @param labelPrefixString label prefix
- */
- public void setLabelPrefixString(String labelPrefixString)
- {
- this.getCOSObject().setString("PS", labelPrefixString);
- }
-
- /**
- * This will return the text to be concatenated after the label specified by U.
- *
- * @return label suffix
- */
- public String getLabelSuffixString()
- {
- return this.getCOSObject().getString("SS", " ");
- }
-
- /**
- * This will set the text to be concatenated after the label specified by U.
- *
- * @param labelSuffixString label suffix
- */
- public void setLabelSuffixString(String labelSuffixString)
- {
- this.getCOSObject().setString("SS", labelSuffixString);
- }
-
- /**
- * This will return a value indicating the ordering of the label specified by U to the calculated unit value.
- *
- * @return label position
- */
- public String getLabelPositionToValue()
- {
- return this.getCOSObject().getString("O", LABEL_SUFFIX_TO_VALUE);
- }
-
- /**
- * This will set the value indicating the ordering of the label specified by U to the calculated unit value.
- * Possible values are "S" and "P"
- *
- * @param labelPositionToValue label position
- */
- public void setLabelPositionToValue(String labelPositionToValue)
- {
- if ((labelPositionToValue == null)
- || LABEL_PREFIX_TO_VALUE.equals(labelPositionToValue)
- || LABEL_SUFFIX_TO_VALUE.equals(labelPositionToValue))
- {
- this.getCOSObject().setString("O", labelPositionToValue);
- }
- else
- {
- throw new IllegalArgumentException("Value must be \"S\", or \"P\" (or null).");
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.measurement;
+
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.common.COSObjectable;
+
+/**
+ * This class represents a number format dictionary.
+ *
+ */
+public class PDNumberFormatDictionary implements COSObjectable
+{
+
+ /**
+ * The type of the dictionary.
+ */
+ public static final String TYPE = "NumberFormat";
+
+ /**
+ * Constant indicating that the label specified by U is a suffix to the value.
+ */
+ public static final String LABEL_SUFFIX_TO_VALUE = "S";
+ /**
+ * Constant indicating that the label specified by U is a postfix to the value.
+ */
+ public static final String LABEL_PREFIX_TO_VALUE = "P";
+
+ /**
+ * Constant for showing a fractional value as decimal to the precision specified by the D entry.
+ */
+ public static final String FRACTIONAL_DISPLAY_DECIMAL = "D";
+ /**
+ * Constant for showing a fractional value as a fraction with denominator specified by the D entry.
+ */
+ public static final String FRACTIONAL_DISPLAY_FRACTION = "F";
+ /**
+ * Constant for showing a fractional value without fractional part; round to the nearest whole unit.
+ */
+ public static final String FRACTIONAL_DISPLAY_ROUND = "R";
+ /**
+ * Constant for showing a fractional value without fractional part; truncate to achieve whole units.
+ */
+ public static final String FRACTIONAL_DISPLAY_TRUNCATE = "T";
+
+ private final COSDictionary numberFormatDictionary;
+
+ /**
+ * Constructor.
+ */
+ public PDNumberFormatDictionary()
+ {
+ this.numberFormatDictionary = new COSDictionary();
+ this.numberFormatDictionary.setName(COSName.TYPE, TYPE);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param dictionary the corresponding dictionary
+ */
+ public PDNumberFormatDictionary(COSDictionary dictionary)
+ {
+ this.numberFormatDictionary = dictionary;
+ }
+
+ /**
+ * This will return the dictionary.
+ *
+ * @return the number format dictionary
+ */
+ @Override
+ public COSDictionary getCOSObject()
+ {
+ return this.numberFormatDictionary;
+ }
+
+ /**
+ * This will return the type of the number format dictionary.
+ * It must be "NumberFormat"
+ *
+ * @return the type
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /**
+ * This will return the label for the units.
+ *
+ * @return the label for the units
+ */
+ public String getUnits()
+ {
+ return this.getCOSObject().getString("U");
+ }
+
+ /**
+ * This will set the label for the units.
+ *
+ * @param units the label for the units
+ */
+ public void setUnits(String units)
+ {
+ this.getCOSObject().setString("U", units);
+ }
+
+ /**
+ * This will return the conversion factor.
+ *
+ * @return the conversion factor
+ */
+ public float getConversionFactor()
+ {
+ return this.getCOSObject().getFloat("C");
+ }
+
+ /**
+ * This will set the conversion factor.
+ *
+ * @param conversionFactor the conversion factor
+ */
+ public void setConversionFactor(float conversionFactor)
+ {
+ this.getCOSObject().setFloat("C", conversionFactor);
+ }
+
+ /**
+ * This will return the value for the manner to display a fractional value.
+ *
+ * @return the manner to display a fractional value
+ */
+ public String getFractionalDisplay()
+ {
+ return this.getCOSObject().getString("F", FRACTIONAL_DISPLAY_DECIMAL);
+ }
+
+ /**
+ * This will set the value for the manner to display a fractional value.
+ * Allowed values are "D", "F", "R" and "T"
+ * @param fractionalDisplay the manner to display a fractional value
+ */
+ public void setFractionalDisplay(String fractionalDisplay)
+ {
+ if ((fractionalDisplay == null)
+ || FRACTIONAL_DISPLAY_DECIMAL.equals(fractionalDisplay)
+ || FRACTIONAL_DISPLAY_FRACTION.equals(fractionalDisplay)
+ || FRACTIONAL_DISPLAY_ROUND.equals(fractionalDisplay)
+ || FRACTIONAL_DISPLAY_TRUNCATE.equals(fractionalDisplay))
+ {
+ this.getCOSObject().setString("F", fractionalDisplay);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Value must be \"D\", \"F\", \"R\", or \"T\", (or null).");
+ }
+ }
+
+ /**
+ * This will return the precision or denominator of a fractional amount.
+ *
+ * @return the precision or denominator
+ */
+ public int getDenominator()
+ {
+ return this.getCOSObject().getInt("D");
+ }
+
+ /**
+ * This will set the precision or denominator of a fractional amount.
+ *
+ * @param denominator the precision or denominator
+ */
+ public void setDenominator(int denominator)
+ {
+ this.getCOSObject().setInt("D", denominator);
+ }
+
+ /**
+ * This will return the value indication if the denominator of the fractional value is reduced/truncated .
+ *
+ * @return fd
+ */
+ public boolean isFD()
+ {
+ return this.getCOSObject().getBoolean("FD", false);
+ }
+
+ /**
+ * This will set the value indication if the denominator of the fractional value is reduced/truncated .
+ * The denominator may not be reduced/truncated if true
+ * @param fd fd
+ */
+ public void setFD(boolean fd)
+ {
+ this.getCOSObject().setBoolean("FD", fd);
+ }
+
+ /**
+ * This will return the text to be used between orders of thousands in display of numerical values.
+ *
+ * @return thousands separator
+ */
+ public String getThousandsSeparator()
+ {
+ return this.getCOSObject().getString("RT", ",");
+ }
+
+ /**
+ * This will set the text to be used between orders of thousands in display of numerical values.
+ *
+ * @param thousandsSeparator thousands separator
+ */
+ public void setThousandsSeparator(String thousandsSeparator)
+ {
+ this.getCOSObject().setString("RT", thousandsSeparator);
+ }
+
+ /**
+ * This will return the text to be used as the decimal point in displaying numerical values.
+ *
+ * @return decimal separator
+ */
+ public String getDecimalSeparator()
+ {
+ return this.getCOSObject().getString("RD", ".");
+ }
+
+ /**
+ * This will set the text to be used as the decimal point in displaying numerical values.
+ *
+ * @param decimalSeparator decimal separator
+ */
+ public void setDecimalSeparator(String decimalSeparator)
+ {
+ this.getCOSObject().setString("RD", decimalSeparator);
+ }
+
+ /**
+ * This will return the text to be concatenated to the left of the label specified by U.
+ * @return label prefix
+ */
+ public String getLabelPrefixString()
+ {
+ return this.getCOSObject().getString("PS", " ");
+ }
+
+ /**
+ * This will set the text to be concatenated to the left of the label specified by U.
+ * @param labelPrefixString label prefix
+ */
+ public void setLabelPrefixString(String labelPrefixString)
+ {
+ this.getCOSObject().setString("PS", labelPrefixString);
+ }
+
+ /**
+ * This will return the text to be concatenated after the label specified by U.
+ *
+ * @return label suffix
+ */
+ public String getLabelSuffixString()
+ {
+ return this.getCOSObject().getString("SS", " ");
+ }
+
+ /**
+ * This will set the text to be concatenated after the label specified by U.
+ *
+ * @param labelSuffixString label suffix
+ */
+ public void setLabelSuffixString(String labelSuffixString)
+ {
+ this.getCOSObject().setString("SS", labelSuffixString);
+ }
+
+ /**
+ * This will return a value indicating the ordering of the label specified by U to the calculated unit value.
+ *
+ * @return label position
+ */
+ public String getLabelPositionToValue()
+ {
+ return this.getCOSObject().getString("O", LABEL_SUFFIX_TO_VALUE);
+ }
+
+ /**
+ * This will set the value indicating the ordering of the label specified by U to the calculated unit value.
+ * Possible values are "S" and "P"
+ *
+ * @param labelPositionToValue label position
+ */
+ public void setLabelPositionToValue(String labelPositionToValue)
+ {
+ if ((labelPositionToValue == null)
+ || LABEL_PREFIX_TO_VALUE.equals(labelPositionToValue)
+ || LABEL_SUFFIX_TO_VALUE.equals(labelPositionToValue))
+ {
+ this.getCOSObject().setString("O", labelPositionToValue);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Value must be \"S\", or \"P\" (or null).");
+ }
+ }
+
+}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDThread.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDThread.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDThread.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/pagenavigation/PDThread.java Wed Dec 23 10:45:50 2020
@@ -30,7 +30,7 @@ public class PDThread implements COSObje
{
- private COSDictionary thread;
+ private final COSDictionary thread;
/**
* Constructor that is used for a preexisting dictionary.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java Wed Dec 23 10:45:50 2020
@@ -164,7 +164,7 @@ public class PDFTextStripper extends Leg
*/
protected ArrayList<List<TextPosition>> charactersByArticle = new ArrayList<>();
- private Map<String, TreeMap<Float, TreeSet<Float>>> characterListMapping = new HashMap<>();
+ private final Map<String, TreeMap<Float, TreeSet<Float>>> characterListMapping = new HashMap<>();
protected PDDocument document;
protected Writer output;
@@ -1971,7 +1971,7 @@ public class PDFTextStripper extends Leg
*/
private static final class LineItem
{
- public static LineItem WORD_SEPARATOR = new LineItem();
+ public static final LineItem WORD_SEPARATOR = new LineItem();
public static LineItem getWordSeparator()
{
@@ -2009,8 +2009,8 @@ public class PDFTextStripper extends Leg
*/
private static final class WordWithTextPositions
{
- String text;
- List<TextPosition> textPositions;
+ final String text;
+ final List<TextPosition> textPositions;
WordWithTextPositions(String word, List<TextPosition> positions)
{
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/PDFDocEncodingTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/PDFDocEncodingTest.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/PDFDocEncodingTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/PDFDocEncodingTest.java Wed Dec 23 10:45:50 2020
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
class PDFDocEncodingTest
{
- static List<String> deviations = new ArrayList<>();
+ static final List<String> deviations = new ArrayList<>();
static
{
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java Wed Dec 23 10:45:50 2020
@@ -223,8 +223,8 @@ class TestCOSFloat extends TestCOSNumber
class AcceptTester extends BaseTester
{
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- COSWriter visitor = new COSWriter(outStream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final COSWriter visitor = new COSWriter(outStream);
@Override
void runTest(float num)
@@ -254,7 +254,7 @@ class TestCOSFloat extends TestCOSNumber
class WritePDFTester extends BaseTester
{
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
WritePDFTester()
{
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java Wed Dec 23 10:45:50 2020
@@ -750,7 +750,7 @@ class PDFMergerUtilityTest
private class ElementCounter
{
int cnt = 0;
- Set<COSBase> set = new HashSet<>();
+ final Set<COSBase> set = new HashSet<>();
void walk(COSBase base)
{
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSDocumentCompressionTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSDocumentCompressionTest.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSDocumentCompressionTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfwriter/COSDocumentCompressionTest.java Wed Dec 23 10:45:50 2020
@@ -46,8 +46,8 @@ import java.util.Map;
class COSDocumentCompressionTest
{
- static File inDir = new File("src/test/resources/input/compression/");
- static File outDir = new File("target/test-output/compression/");
+ static final File inDir = new File("src/test/resources/input/compression/");
+ static final File outDir = new File("target/test-output/compression/");
public COSDocumentCompressionTest()
{
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestPDFToImage.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestPDFToImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestPDFToImage.java Wed Dec 23 10:45:50 2020
@@ -65,7 +65,7 @@ public class TestPDFToImage
static String inDir = "src/test/resources/input/rendering";
static String outDir = "target/test-output/rendering/";
- String filename;
+ final String filename;
/**
* Test class constructor.
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightDocument.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightDocument.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightDocument.java Wed Dec 23 10:45:50 2020
@@ -33,9 +33,9 @@ import org.apache.pdfbox.preflight.utils
public class PreflightDocument extends PDDocument
{
- private ValidationResult result = new ValidationResult(true);
+ private final ValidationResult result = new ValidationResult(true);
- private PreflightConfiguration config;
+ private final PreflightConfiguration config;
private PreflightContext context;
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java Wed Dec 23 10:45:50 2020
@@ -38,7 +38,7 @@ public abstract class AnnotationValidato
{
protected ActionManagerFactory actionFact = null;
- protected Map<String, Class<? extends AnnotationValidator>> validatorClasses = new HashMap<>();
+ protected final Map<String, Class<? extends AnnotationValidator>> validatorClasses = new HashMap<>();
public AnnotationValidatorFactory()
{
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/FontValidator.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/FontValidator.java Wed Dec 23 10:45:50 2020
@@ -29,8 +29,8 @@ import org.apache.pdfbox.preflight.font.
public abstract class FontValidator<T extends FontContainer>
{
- protected T fontContainer;
- protected PreflightContext context;
+ protected final T fontContainer;
+ protected final PreflightContext context;
protected FontDescriptorHelper<T> descriptorHelper;
public FontValidator(PreflightContext context, COSDictionary dict, T fContainer)
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/SimpleFontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/SimpleFontValidator.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/SimpleFontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/SimpleFontValidator.java Wed Dec 23 10:45:50 2020
@@ -33,8 +33,8 @@ import org.apache.pdfbox.preflight.font.
public abstract class SimpleFontValidator<T extends FontContainer> extends FontValidator<T>
{
- protected PDFontLike font;
- protected COSDictionary fontDictionary;
+ protected final PDFontLike font;
+ protected final COSDictionary fontDictionary;
public SimpleFontValidator(PreflightContext context, PDFontLike font, COSDictionary fontDictionary, T fContainer)
{
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java Wed Dec 23 10:45:50 2020
@@ -55,7 +55,7 @@ import org.apache.pdfbox.preflight.font.
public class Type0FontValidator extends FontValidator<Type0Container>
{
- protected PDFont font;
+ protected final PDFont font;
public Type0FontValidator(PreflightContext context, PDFont font)
{
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java Wed Dec 23 10:45:50 2020
@@ -58,8 +58,8 @@ import org.apache.pdfbox.preflight.utils
public class Type3FontValidator extends FontValidator<Type3Container>
{
- protected PDType3Font font;
- protected COSDictionary fontDictionary;
+ protected final PDType3Font font;
+ protected final COSDictionary fontDictionary;
public Type3FontValidator(PreflightContext context, PDType3Font font)
{
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java Wed Dec 23 10:45:50 2020
@@ -39,7 +39,7 @@ public abstract class FontContainer<T ex
* List of validation errors that occur during the font validation. If the font is used by an object in the PDF, all
* these errors will be appended to the Error list of the PreflightContext.
*/
- protected List<ValidationError> errorBuffer = new ArrayList<>();
+ protected final List<ValidationError> errorBuffer = new ArrayList<>();
/**
* Boolean used to known if the font is embedded.
Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestInvalidFiles.java Wed Dec 23 10:45:50 2020
@@ -49,7 +49,7 @@ class TestInvalidFiles
private static final String ISARTOR_FILES = "invalid.files";
- protected static Log staticLogger = LogFactory.getLog("Test");
+ protected static final Log staticLogger = LogFactory.getLog("Test");
private static InvalidFileTester tester;
Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestIsartorValidation.java Wed Dec 23 10:45:50 2020
@@ -49,7 +49,7 @@ class TestIsartorValidation
private static final String ISARTOR_FILES = "isartor.files";
- protected static Log staticLogger = LogFactory.getLog("Test");
+ protected static final Log staticLogger = LogFactory.getLog("Test");
private static InvalidFileTester tester;
Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/integration/TestValidFiles.java Wed Dec 23 10:45:50 2020
@@ -54,7 +54,7 @@ class TestValidFiles
protected File path;
- protected static Log staticLogger = LogFactory.getLog("Test");
+ protected static final Log staticLogger = LogFactory.getLog("Test");
protected Log logger = null;
Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/parser/TestXmlResultParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/parser/TestXmlResultParser.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/parser/TestXmlResultParser.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/parser/TestXmlResultParser.java Wed Dec 23 10:45:50 2020
@@ -40,7 +40,7 @@ class TestXmlResultParser
public static final String ERROR_CODE = "000";
- protected XmlResultParser parser = new XmlResultParser();
+ protected final XmlResultParser parser = new XmlResultParser();
protected Document document;
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/XMPMetadata.java Wed Dec 23 10:45:50 2020
@@ -61,9 +61,9 @@ public class XMPMetadata
private String xpacketEndData = XmpConstants.DEFAULT_XPACKET_END;
- private List<XMPSchema> schemas;
+ private final List<XMPSchema> schemas;
- private TypeMapping typeMapping;
+ private final TypeMapping typeMapping;
/**
* Constructor of an empty default XMPMetaData.
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpParsingException.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpParsingException.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpParsingException.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpParsingException.java Wed Dec 23 10:45:50 2020
@@ -40,7 +40,7 @@ public class XmpParsingException extends
// prefix used
}
- private ErrorType errorType;
+ private final ErrorType errorType;
/**
* serial version uid
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java Wed Dec 23 10:45:50 2020
@@ -1,315 +1,315 @@
-/*****************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-package org.apache.xmpbox.xml;
-
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.xmpbox.XMPMetadata;
-import org.apache.xmpbox.XmpConstants;
-import org.apache.xmpbox.schema.XMPSchema;
-import org.apache.xmpbox.type.AbstractComplexProperty;
-import org.apache.xmpbox.type.AbstractField;
-import org.apache.xmpbox.type.AbstractSimpleProperty;
-import org.apache.xmpbox.type.AbstractStructuredType;
-import org.apache.xmpbox.type.ArrayProperty;
-import org.apache.xmpbox.type.Attribute;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-public class XmpSerializer
-{
-
- private final TransformerFactory transformerFactory;
- private final DocumentBuilder documentBuilder;
-
- private boolean parseTypeResourceForLi = true;
-
- /**
- * Default constructor.
- */
- @SuppressWarnings({ "squid:S2755" }) // self-created XML
- public XmpSerializer()
- {
- this(TransformerFactory.newInstance(), DocumentBuilderFactory.newInstance());
- }
-
- /**
- * Constructor to be used if other factories than the default ones are needed.
- *
- * @param transformerFactory transformer factory to be used
- * @param documentBuilderFactory document builder factory to be used
- */
- public XmpSerializer(TransformerFactory transformerFactory,
- DocumentBuilderFactory documentBuilderFactory)
- {
- this.transformerFactory = transformerFactory;
- // xml init
- try
- {
- documentBuilder = documentBuilderFactory.newDocumentBuilder();
- }
- catch (ParserConfigurationException e)
- {
- // never happens, because we don't call builderFactory#setAttribute
- throw new RuntimeException(e);
- }
- }
-
- public void serialize(XMPMetadata metadata, OutputStream os, boolean withXpacket) throws TransformerException
- {
- Document doc = documentBuilder.newDocument();
- // fill document
- Element rdf = createRdfElement(doc, metadata, withXpacket);
- for (XMPSchema schema : metadata.getAllSchemas())
- {
- rdf.appendChild(serializeSchema(doc, schema));
- }
- // save
- save(doc, os, "UTF-8");
- }
-
- protected Element serializeSchema(Document doc, XMPSchema schema)
- {
- // prepare schema
- Element selem = doc.createElementNS(XmpConstants.RDF_NAMESPACE, "rdf:Description");
- selem.setAttributeNS(XmpConstants.RDF_NAMESPACE, "rdf:about", schema.getAboutValue());
- selem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + schema.getPrefix(), schema.getNamespace());
- // the other attributes
- fillElementWithAttributes(selem, schema);
- // the content
- List<AbstractField> fields = schema.getAllProperties();
- serializeFields(doc, selem, fields,schema.getPrefix(), null, true);
- // return created schema
- return selem;
- }
-
- public void serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, String prefix, boolean wrapWithProperty)
- {
- for (AbstractField field : fields)
- {
-
- if (field instanceof AbstractSimpleProperty)
- {
- AbstractSimpleProperty simple = (AbstractSimpleProperty) field;
-
- String localPrefix;
-
- if (prefix != null && !prefix.isEmpty())
- {
- localPrefix = prefix;
- }
- else
- {
- localPrefix = simple.getPrefix();
- }
-
- Element esimple = doc.createElement(localPrefix + ":" + simple.getPropertyName());
- esimple.setTextContent(simple.getStringValue());
- List<Attribute> attributes = simple.getAllAttributes();
- for (Attribute attribute : attributes)
- {
- esimple.setAttributeNS(attribute.getNamespace(), attribute.getName(), attribute.getValue());
- }
- parent.appendChild(esimple);
- }
- else if (field instanceof ArrayProperty)
- {
- ArrayProperty array = (ArrayProperty) field;
- // property
- Element asimple = doc.createElement(array.getPrefix() + ":" + array.getPropertyName());
- parent.appendChild(asimple);
- // attributes
- fillElementWithAttributes(asimple, array);
- // the array definition
- Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + array.getArrayType());
- asimple.appendChild(econtainer);
- // for each element of the array
- List<AbstractField> innerFields = array.getAllProperties();
- serializeFields(doc, econtainer, innerFields,resourceNS, XmpConstants.DEFAULT_RDF_PREFIX, false);
- }
- else if (field instanceof AbstractStructuredType)
- {
- AbstractStructuredType structured = (AbstractStructuredType) field;
- List<AbstractField> innerFields = structured.getAllProperties();
- // property name attribute
- Element listParent = parent;
- if (wrapWithProperty)
- {
- Element nstructured = doc
- .createElement(resourceNS + ":" + structured.getPropertyName());
- parent.appendChild(nstructured);
- listParent = nstructured;
- }
-
- // element li
- Element estructured = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + XmpConstants.LIST_NAME);
- listParent.appendChild(estructured);
- if (parseTypeResourceForLi)
- {
- estructured.setAttribute("rdf:parseType", "Resource");
- // all properties
- serializeFields(doc, estructured, innerFields,resourceNS, null, true);
- }
- else
- {
- // element description
- Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + "Description");
- estructured.appendChild(econtainer);
- // all properties
- serializeFields(doc, econtainer, innerFields,resourceNS, null, true);
- }
- }
- else
- {
- // XXX finish serialization classes
- System.err.println(">> TODO >> " + field.getClass());
- }
- }
-
- }
-
- private void fillElementWithAttributes(Element target, AbstractComplexProperty property)
- {
- // normalize the attributes list
- List<Attribute> toSerialize = normalizeAttributes(property);
-
- toSerialize.forEach(attribute ->
- {
- if (XmpConstants.RDF_NAMESPACE.equals(attribute.getNamespace()))
- {
- target.setAttribute(XmpConstants.DEFAULT_RDF_PREFIX + ":" + attribute.getName(), attribute.getValue());
- }
- else
- {
- target.setAttribute(attribute.getName(), attribute.getValue());
- }
- });
-
- property.getAllNamespacesWithPrefix().forEach((key, value) ->
- target.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + value, key));
- }
-
- /** Normalize the list of attributes.
- *
- * Attributes which match a schema property are serialized as child elements
- * so only return the ones which do not match a schema property
- *
- * @param property the property that needs to be inspected
- * @return the list of attributed for serializing
- */
- private List<Attribute> normalizeAttributes(AbstractComplexProperty property)
- {
- List<Attribute> attributes = property.getAllAttributes();
-
-
- List<Attribute> toSerialize = new ArrayList<>();
- List<AbstractField> fields = property.getAllProperties();
-
- for (Attribute attribute : attributes)
- {
- boolean matchesField = false;
- for (AbstractField field : fields)
- {
- if (attribute.getName().compareTo(field.getPropertyName()) == 0)
- {
- matchesField = true;
- break;
- }
- }
- if (!matchesField)
- {
- toSerialize.add(attribute);
- }
- }
- return toSerialize;
-
- }
-
- protected Element createRdfElement(Document doc, XMPMetadata metadata, boolean withXpacket)
- {
- // starting xpacket
- if (withXpacket)
- {
- ProcessingInstruction beginXPacket = doc.createProcessingInstruction("xpacket",
- "begin=\"" + metadata.getXpacketBegin() + "\" id=\"" + metadata.getXpacketId() + "\"");
- doc.appendChild(beginXPacket);
- }
- // meta element
- Element xmpmeta = doc.createElementNS("adobe:ns:meta/", "x:xmpmeta");
- xmpmeta.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:x", "adobe:ns:meta/");
- doc.appendChild(xmpmeta);
- // ending xpacket
- if (withXpacket)
- {
- ProcessingInstruction endXPacket = doc.createProcessingInstruction("xpacket",
- "end=\"" + metadata.getEndXPacket() + "\"");
- doc.appendChild(endXPacket);
- }
- // rdf element
- Element rdf = doc.createElementNS(XmpConstants.RDF_NAMESPACE, "rdf:RDF");
- // rdf.setAttributeNS(XMPSchema.NS_NAMESPACE, qualifiedName, value)
- xmpmeta.appendChild(rdf);
- // return the rdf element where all will be put
- return rdf;
- }
-
- /**
- * Save the XML document to an output stream.
- *
- * @param doc The XML document to save.
- * @param outStream The stream to save the document to.
- * @param encoding The encoding to save the file as.
- *
- * @throws TransformerException If there is an error while saving the XML.
- */
- private void save(Node doc, OutputStream outStream, String encoding) throws TransformerException
- {
- Transformer transformer = transformerFactory.newTransformer();
- // human readable
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- // indent elements
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- // encoding
- transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- // initialize StreamResult with File object to save to file
- Result result = new StreamResult(outStream);
- DOMSource source = new DOMSource(doc);
- // save
- transformer.transform(source, result);
- }
-}
+/*****************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+package org.apache.xmpbox.xml;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.xmpbox.XMPMetadata;
+import org.apache.xmpbox.XmpConstants;
+import org.apache.xmpbox.schema.XMPSchema;
+import org.apache.xmpbox.type.AbstractComplexProperty;
+import org.apache.xmpbox.type.AbstractField;
+import org.apache.xmpbox.type.AbstractSimpleProperty;
+import org.apache.xmpbox.type.AbstractStructuredType;
+import org.apache.xmpbox.type.ArrayProperty;
+import org.apache.xmpbox.type.Attribute;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+
+public class XmpSerializer
+{
+
+ private final TransformerFactory transformerFactory;
+ private final DocumentBuilder documentBuilder;
+
+ private final boolean parseTypeResourceForLi = true;
+
+ /**
+ * Default constructor.
+ */
+ @SuppressWarnings({ "squid:S2755" }) // self-created XML
+ public XmpSerializer()
+ {
+ this(TransformerFactory.newInstance(), DocumentBuilderFactory.newInstance());
+ }
+
+ /**
+ * Constructor to be used if other factories than the default ones are needed.
+ *
+ * @param transformerFactory transformer factory to be used
+ * @param documentBuilderFactory document builder factory to be used
+ */
+ public XmpSerializer(TransformerFactory transformerFactory,
+ DocumentBuilderFactory documentBuilderFactory)
+ {
+ this.transformerFactory = transformerFactory;
+ // xml init
+ try
+ {
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ }
+ catch (ParserConfigurationException e)
+ {
+ // never happens, because we don't call builderFactory#setAttribute
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void serialize(XMPMetadata metadata, OutputStream os, boolean withXpacket) throws TransformerException
+ {
+ Document doc = documentBuilder.newDocument();
+ // fill document
+ Element rdf = createRdfElement(doc, metadata, withXpacket);
+ for (XMPSchema schema : metadata.getAllSchemas())
+ {
+ rdf.appendChild(serializeSchema(doc, schema));
+ }
+ // save
+ save(doc, os, "UTF-8");
+ }
+
+ protected Element serializeSchema(Document doc, XMPSchema schema)
+ {
+ // prepare schema
+ Element selem = doc.createElementNS(XmpConstants.RDF_NAMESPACE, "rdf:Description");
+ selem.setAttributeNS(XmpConstants.RDF_NAMESPACE, "rdf:about", schema.getAboutValue());
+ selem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + schema.getPrefix(), schema.getNamespace());
+ // the other attributes
+ fillElementWithAttributes(selem, schema);
+ // the content
+ List<AbstractField> fields = schema.getAllProperties();
+ serializeFields(doc, selem, fields,schema.getPrefix(), null, true);
+ // return created schema
+ return selem;
+ }
+
+ public void serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, String prefix, boolean wrapWithProperty)
+ {
+ for (AbstractField field : fields)
+ {
+
+ if (field instanceof AbstractSimpleProperty)
+ {
+ AbstractSimpleProperty simple = (AbstractSimpleProperty) field;
+
+ String localPrefix;
+
+ if (prefix != null && !prefix.isEmpty())
+ {
+ localPrefix = prefix;
+ }
+ else
+ {
+ localPrefix = simple.getPrefix();
+ }
+
+ Element esimple = doc.createElement(localPrefix + ":" + simple.getPropertyName());
+ esimple.setTextContent(simple.getStringValue());
+ List<Attribute> attributes = simple.getAllAttributes();
+ for (Attribute attribute : attributes)
+ {
+ esimple.setAttributeNS(attribute.getNamespace(), attribute.getName(), attribute.getValue());
+ }
+ parent.appendChild(esimple);
+ }
+ else if (field instanceof ArrayProperty)
+ {
+ ArrayProperty array = (ArrayProperty) field;
+ // property
+ Element asimple = doc.createElement(array.getPrefix() + ":" + array.getPropertyName());
+ parent.appendChild(asimple);
+ // attributes
+ fillElementWithAttributes(asimple, array);
+ // the array definition
+ Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + array.getArrayType());
+ asimple.appendChild(econtainer);
+ // for each element of the array
+ List<AbstractField> innerFields = array.getAllProperties();
+ serializeFields(doc, econtainer, innerFields,resourceNS, XmpConstants.DEFAULT_RDF_PREFIX, false);
+ }
+ else if (field instanceof AbstractStructuredType)
+ {
+ AbstractStructuredType structured = (AbstractStructuredType) field;
+ List<AbstractField> innerFields = structured.getAllProperties();
+ // property name attribute
+ Element listParent = parent;
+ if (wrapWithProperty)
+ {
+ Element nstructured = doc
+ .createElement(resourceNS + ":" + structured.getPropertyName());
+ parent.appendChild(nstructured);
+ listParent = nstructured;
+ }
+
+ // element li
+ Element estructured = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + XmpConstants.LIST_NAME);
+ listParent.appendChild(estructured);
+ if (parseTypeResourceForLi)
+ {
+ estructured.setAttribute("rdf:parseType", "Resource");
+ // all properties
+ serializeFields(doc, estructured, innerFields,resourceNS, null, true);
+ }
+ else
+ {
+ // element description
+ Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + "Description");
+ estructured.appendChild(econtainer);
+ // all properties
+ serializeFields(doc, econtainer, innerFields,resourceNS, null, true);
+ }
+ }
+ else
+ {
+ // XXX finish serialization classes
+ System.err.println(">> TODO >> " + field.getClass());
+ }
+ }
+
+ }
+
+ private void fillElementWithAttributes(Element target, AbstractComplexProperty property)
+ {
+ // normalize the attributes list
+ List<Attribute> toSerialize = normalizeAttributes(property);
+
+ toSerialize.forEach(attribute ->
+ {
+ if (XmpConstants.RDF_NAMESPACE.equals(attribute.getNamespace()))
+ {
+ target.setAttribute(XmpConstants.DEFAULT_RDF_PREFIX + ":" + attribute.getName(), attribute.getValue());
+ }
+ else
+ {
+ target.setAttribute(attribute.getName(), attribute.getValue());
+ }
+ });
+
+ property.getAllNamespacesWithPrefix().forEach((key, value) ->
+ target.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + value, key));
+ }
+
+ /** Normalize the list of attributes.
+ *
+ * Attributes which match a schema property are serialized as child elements
+ * so only return the ones which do not match a schema property
+ *
+ * @param property the property that needs to be inspected
+ * @return the list of attributed for serializing
+ */
+ private List<Attribute> normalizeAttributes(AbstractComplexProperty property)
+ {
+ List<Attribute> attributes = property.getAllAttributes();
+
+
+ List<Attribute> toSerialize = new ArrayList<>();
+ List<AbstractField> fields = property.getAllProperties();
+
+ for (Attribute attribute : attributes)
+ {
+ boolean matchesField = false;
+ for (AbstractField field : fields)
+ {
+ if (attribute.getName().compareTo(field.getPropertyName()) == 0)
+ {
+ matchesField = true;
+ break;
+ }
+ }
+ if (!matchesField)
+ {
+ toSerialize.add(attribute);
+ }
+ }
+ return toSerialize;
+
+ }
+
+ protected Element createRdfElement(Document doc, XMPMetadata metadata, boolean withXpacket)
+ {
+ // starting xpacket
+ if (withXpacket)
+ {
+ ProcessingInstruction beginXPacket = doc.createProcessingInstruction("xpacket",
+ "begin=\"" + metadata.getXpacketBegin() + "\" id=\"" + metadata.getXpacketId() + "\"");
+ doc.appendChild(beginXPacket);
+ }
+ // meta element
+ Element xmpmeta = doc.createElementNS("adobe:ns:meta/", "x:xmpmeta");
+ xmpmeta.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:x", "adobe:ns:meta/");
+ doc.appendChild(xmpmeta);
+ // ending xpacket
+ if (withXpacket)
+ {
+ ProcessingInstruction endXPacket = doc.createProcessingInstruction("xpacket",
+ "end=\"" + metadata.getEndXPacket() + "\"");
+ doc.appendChild(endXPacket);
+ }
+ // rdf element
+ Element rdf = doc.createElementNS(XmpConstants.RDF_NAMESPACE, "rdf:RDF");
+ // rdf.setAttributeNS(XMPSchema.NS_NAMESPACE, qualifiedName, value)
+ xmpmeta.appendChild(rdf);
+ // return the rdf element where all will be put
+ return rdf;
+ }
+
+ /**
+ * Save the XML document to an output stream.
+ *
+ * @param doc The XML document to save.
+ * @param outStream The stream to save the document to.
+ * @param encoding The encoding to save the file as.
+ *
+ * @throws TransformerException If there is an error while saving the XML.
+ */
+ private void save(Node doc, OutputStream outStream, String encoding) throws TransformerException
+ {
+ Transformer transformer = transformerFactory.newTransformer();
+ // human readable
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ // indent elements
+ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ // encoding
+ transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ // initialize StreamResult with File object to save to file
+ Result result = new StreamResult(outStream);
+ DOMSource source = new DOMSource(doc);
+ // save
+ transformer.transform(source, result);
+ }
+}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java Wed Dec 23 10:45:50 2020
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
class AdobePDFErrorsTest
{
- private XMPMetadata metadata = XMPMetadata.createXMPMetadata();
+ private final XMPMetadata metadata = XMPMetadata.createXMPMetadata();
@Test
void testPDFAIdentification() throws Exception
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/SchemaTester.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/SchemaTester.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/SchemaTester.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/SchemaTester.java Wed Dec 23 10:45:50 2020
@@ -43,10 +43,10 @@ class SchemaTester extends AbstractTypeT
private final XMPMetadata metadata;
private final Class<?> schemaClass;
private final String fieldName;
- private Types type;
- private Cardinality cardinality;
+ private final Types type;
+ private final Cardinality cardinality;
- private TypeMapping typeMapping;
+ private final TypeMapping typeMapping;
XMPSchema getSchema()
{
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java?rev=1884743&r1=1884742&r2=1884743&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java Wed Dec 23 10:45:50 2020
@@ -1,98 +1,98 @@
-/*****************************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-package org.apache.xmpbox.type;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.Calendar;
-import org.apache.xmpbox.XMPMetadata;
-import org.junit.jupiter.api.Test;
-
-class TestAbstractStructuredType
-{
-
- private static class MyStructuredType extends AbstractStructuredType
- {
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String MYTEXT = "my-text";
-
- @PropertyType(type = Types.Date, card = Cardinality.Simple)
- public static final String MYDATE = "my-date";
-
- public MyStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix)
- {
- super(metadata, namespaceURI, fieldPrefix, "structuredPN");
- }
-
- }
-
- XMPMetadata xmp = XMPMetadata.createXMPMetadata();
-
- public static final String MY_NS = "http://www.apache.org/test#";
- public static final String MY_PREFIX = "test";
-
- protected MyStructuredType st = new MyStructuredType(xmp, MY_NS, MY_PREFIX);
-
- @Test
- void validate() throws Exception
- {
- assertEquals(MY_NS, st.getNamespace());
- assertEquals(MY_PREFIX, st.getPrefix());
- assertEquals(MY_PREFIX, st.getPrefix());
- }
-
- @Test
- void testNonExistingProperty() throws Exception
- {
- assertNull(st.getProperty("NOT_EXISTING"));
- }
-
- @Test
- void testNotValuatedPropertyProperty() throws Exception
- {
- assertNull(st.getProperty(MyStructuredType.MYTEXT));
- }
-
- @Test
- void testValuatedTextProperty() throws Exception
- {
- String s = "my value";
- st.addSimpleProperty(MyStructuredType.MYTEXT, s);
- assertEquals(s, st.getPropertyValueAsString(MyStructuredType.MYTEXT));
- assertNull(st.getPropertyValueAsString(MyStructuredType.MYDATE));
- assertNotNull(st.getProperty(MyStructuredType.MYTEXT));
- }
-
- @Test
- void testValuatedDateProperty() throws Exception
- {
- Calendar c = Calendar.getInstance();
- st.addSimpleProperty(MyStructuredType.MYDATE, c);
- assertEquals(c, st.getDatePropertyAsCalendar(MyStructuredType.MYDATE));
- assertNull(st.getDatePropertyAsCalendar(MyStructuredType.MYTEXT));
- assertNotNull(st.getProperty(MyStructuredType.MYDATE));
- }
-
-}
+/*****************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+package org.apache.xmpbox.type;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.util.Calendar;
+import org.apache.xmpbox.XMPMetadata;
+import org.junit.jupiter.api.Test;
+
+class TestAbstractStructuredType
+{
+
+ private static class MyStructuredType extends AbstractStructuredType
+ {
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String MYTEXT = "my-text";
+
+ @PropertyType(type = Types.Date, card = Cardinality.Simple)
+ public static final String MYDATE = "my-date";
+
+ public MyStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix)
+ {
+ super(metadata, namespaceURI, fieldPrefix, "structuredPN");
+ }
+
+ }
+
+ final XMPMetadata xmp = XMPMetadata.createXMPMetadata();
+
+ public static final String MY_NS = "http://www.apache.org/test#";
+ public static final String MY_PREFIX = "test";
+
+ protected final MyStructuredType st = new MyStructuredType(xmp, MY_NS, MY_PREFIX);
+
+ @Test
+ void validate() throws Exception
+ {
+ assertEquals(MY_NS, st.getNamespace());
+ assertEquals(MY_PREFIX, st.getPrefix());
+ assertEquals(MY_PREFIX, st.getPrefix());
+ }
+
+ @Test
+ void testNonExistingProperty() throws Exception
+ {
+ assertNull(st.getProperty("NOT_EXISTING"));
+ }
+
+ @Test
+ void testNotValuatedPropertyProperty() throws Exception
+ {
+ assertNull(st.getProperty(MyStructuredType.MYTEXT));
+ }
+
+ @Test
+ void testValuatedTextProperty() throws Exception
+ {
+ String s = "my value";
+ st.addSimpleProperty(MyStructuredType.MYTEXT, s);
+ assertEquals(s, st.getPropertyValueAsString(MyStructuredType.MYTEXT));
+ assertNull(st.getPropertyValueAsString(MyStructuredType.MYDATE));
+ assertNotNull(st.getProperty(MyStructuredType.MYTEXT));
+ }
+
+ @Test
+ void testValuatedDateProperty() throws Exception
+ {
+ Calendar c = Calendar.getInstance();
+ st.addSimpleProperty(MyStructuredType.MYDATE, c);
+ assertEquals(c, st.getDatePropertyAsCalendar(MyStructuredType.MYDATE));
+ assertNull(st.getDatePropertyAsCalendar(MyStructuredType.MYTEXT));
+ assertNotNull(st.getProperty(MyStructuredType.MYDATE));
+ }
+
+}