pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1760748 - in /pdfbox/branches/2.0: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/ pdfbox/src/main/java/org/apache/pdfbo...
Date Wed, 14 Sep 2016 20:17:11 GMT
Author: tilman
Date: Wed Sep 14 20:17:11 2016
New Revision: 1760748

URL: http://svn.apache.org/viewvc?rev=1760748&view=rev
Log:
PDFBOX-2852: more efficient strings, as suggested by Simon Steiner

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDMarkedContentReference.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserProperty.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/PDMarkedContent.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java
    pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
    pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
    pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDAttributeObject.java
Wed Sep 14 20:17:11 2016
@@ -197,7 +197,7 @@ public abstract class PDAttributeObject
     @Override
     public String toString()
     {
-        return new StringBuilder("O=").append(this.getOwner()).toString();
+        return "O=" + this.getOwner();
     }
 
     /**

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDMarkedContentReference.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDMarkedContentReference.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDMarkedContentReference.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDMarkedContentReference.java
Wed Sep 14 20:17:11 2016
@@ -109,7 +109,7 @@ public class PDMarkedContentReference im
     @Override
     public String toString()
     {
-        return new StringBuilder().append("mcid=").append(this.getMCID()).toString();
+        return "mcid=" + this.getMCID();
     }
 
 }

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserAttributeObject.java
Wed Sep 14 20:17:11 2016
@@ -127,9 +127,9 @@ public class PDUserAttributeObject exten
     @Override
     public String toString()
     {
-        return new StringBuilder().append(super.toString())
-            .append(", userProperties=")
-            .append(this.getOwnerUserProperties()).toString();
+        return super.toString() +
+                ", userProperties=" +
+                this.getOwnerUserProperties();
     }
 
 }

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserProperty.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserProperty.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDUserProperty.java
Wed Sep 14 20:17:11 2016
@@ -145,10 +145,10 @@ public class PDUserProperty extends PDDi
     @Override
     public String toString()
     {
-        return new StringBuilder("Name=").append(this.getName())
-            .append(", Value=").append(this.getValue())
-            .append(", FormattedValue=").append(this.getFormattedValue())
-            .append(", Hidden=").append(this.isHidden()).toString();
+        return "Name=" + this.getName() +
+                ", Value=" + this.getValue() +
+                ", FormattedValue=" + this.getFormattedValue() +
+                ", Hidden=" + this.isHidden();
     }
 
 
@@ -223,4 +223,4 @@ public class PDUserProperty extends PDDi
         return true;
     }
 
-}
\ No newline at end of file
+}

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/PDMarkedContent.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/PDMarkedContent.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/PDMarkedContent.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/markedcontent/PDMarkedContent.java
Wed Sep 14 20:17:11 2016
@@ -1,202 +1,201 @@
-/*
- * 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.documentinterchange.markedcontent;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDArtifactMarkedContent;
-import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.text.TextPosition;
-
-/**
- * A marked content.
- * 
- * @author Johannes Koch
- */
-public class PDMarkedContent
-{
-
-    /**
-     * Creates a marked-content sequence.
-     * 
-     * @param tag the tag
-     * @param properties the properties
-     * @return the marked-content sequence
-     */
-    public static PDMarkedContent create(COSName tag, COSDictionary properties)
-    {
-        if (COSName.ARTIFACT.equals(tag))
-        {
-            return new PDArtifactMarkedContent(properties);
-        }
-        return new PDMarkedContent(tag, properties);
-    }
-
-
-    private final String tag;
-    private final COSDictionary properties;
-    private final List<Object> contents;
-
-
-    /**
-     * Creates a new marked content object.
-     * 
-     * @param tag the tag
-     * @param properties the properties
-     */
-    public PDMarkedContent(COSName tag, COSDictionary properties)
-    {
-        this.tag = tag == null ? null : tag.getName();
-        this.properties = properties;
-        this.contents = new ArrayList<Object>();
-    }
-
-
-    /**
-     * Gets the tag.
-     * 
-     * @return the tag
-     */
-    public String getTag()
-    {
-        return this.tag;
-    }
-
-    /**
-     * Gets the properties.
-     * 
-     * @return the properties
-     */
-    public COSDictionary getProperties()
-    {
-        return this.properties;
-    }
-
-    /**
-     * Gets the marked-content identifier.
-     * 
-     * @return the marked-content identifier, or -1 if it doesn't exist.
-     */
-    public int getMCID()
-    {
-        return this.getProperties() == null ? -1 :
-            this.getProperties().getInt(COSName.MCID);
-    }
-
-    /**
-     * Gets the language (Lang).
-     * 
-     * @return the language
-     */
-    public String getLanguage()
-    {
-        return this.getProperties() == null ? null :
-            this.getProperties().getNameAsString(COSName.LANG);
-    }
-
-    /**
-     * Gets the actual text (ActualText).
-     * 
-     * @return the actual text
-     */
-    public String getActualText()
-    {
-        return this.getProperties() == null ? null :
-            this.getProperties().getString(COSName.ACTUAL_TEXT);
-    }
-
-    /**
-     * Gets the alternate description (Alt).
-     * 
-     * @return the alternate description
-     */
-    public String getAlternateDescription()
-    {
-        return this.getProperties() == null ? null :
-            this.getProperties().getString(COSName.ALT);
-    }
-
-    /**
-     * Gets the expanded form (E).
-     * 
-     * @return the expanded form
-     */
-    public String getExpandedForm()
-    {
-        return this.getProperties() == null ? null :
-            this.getProperties().getString(COSName.E);
-    }
-
-    /**
-     * Gets the contents of the marked content sequence. Can be
-     * <ul>
-     *   <li>{@link TextPosition},</li>
-     *   <li>{@link PDMarkedContent}, or</li>
-     *   <li>{@link PDXObject}.</li>
-     * </ul>
-     * 
-     * @return the contents of the marked content sequence
-     */
-    public List<Object> getContents()
-    {
-        return this.contents;
-    }
-
-    /**
-     * Adds a text position to the contents.
-     * 
-     * @param text the text position
-     */
-    public void addText(TextPosition text)
-    {
-        this.getContents().add(text);
-    }
-
-    /**
-     * Adds a marked content to the contents.
-     * 
-     * @param markedContent the marked content
-     */
-    public void addMarkedContent(PDMarkedContent markedContent)
-    {
-        this.getContents().add(markedContent);
-    }
-
-    /**
-     * Adds an XObject to the contents.
-     * 
-     * @param xobject the XObject
-     */
-    public void addXObject(PDXObject xobject)
-    {
-        this.getContents().add(xobject);
-    }
-
-
-    @Override
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder("tag=").append(this.tag)
-            .append(", properties=").append(this.properties);
-        sb.append(", contents=").append(this.contents);
-        return sb.toString();
-    }
-
-}
+/*
+ * 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.documentinterchange.markedcontent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDArtifactMarkedContent;
+import org.apache.pdfbox.pdmodel.graphics.PDXObject;
+import org.apache.pdfbox.text.TextPosition;
+
+/**
+ * A marked content.
+ * 
+ * @author Johannes Koch
+ */
+public class PDMarkedContent
+{
+
+    /**
+     * Creates a marked-content sequence.
+     * 
+     * @param tag the tag
+     * @param properties the properties
+     * @return the marked-content sequence
+     */
+    public static PDMarkedContent create(COSName tag, COSDictionary properties)
+    {
+        if (COSName.ARTIFACT.equals(tag))
+        {
+            return new PDArtifactMarkedContent(properties);
+        }
+        return new PDMarkedContent(tag, properties);
+    }
+
+
+    private final String tag;
+    private final COSDictionary properties;
+    private final List<Object> contents;
+
+
+    /**
+     * Creates a new marked content object.
+     * 
+     * @param tag the tag
+     * @param properties the properties
+     */
+    public PDMarkedContent(COSName tag, COSDictionary properties)
+    {
+        this.tag = tag == null ? null : tag.getName();
+        this.properties = properties;
+        this.contents = new ArrayList<Object>();
+    }
+
+
+    /**
+     * Gets the tag.
+     * 
+     * @return the tag
+     */
+    public String getTag()
+    {
+        return this.tag;
+    }
+
+    /**
+     * Gets the properties.
+     * 
+     * @return the properties
+     */
+    public COSDictionary getProperties()
+    {
+        return this.properties;
+    }
+
+    /**
+     * Gets the marked-content identifier.
+     * 
+     * @return the marked-content identifier, or -1 if it doesn't exist.
+     */
+    public int getMCID()
+    {
+        return this.getProperties() == null ? -1 :
+            this.getProperties().getInt(COSName.MCID);
+    }
+
+    /**
+     * Gets the language (Lang).
+     * 
+     * @return the language
+     */
+    public String getLanguage()
+    {
+        return this.getProperties() == null ? null :
+            this.getProperties().getNameAsString(COSName.LANG);
+    }
+
+    /**
+     * Gets the actual text (ActualText).
+     * 
+     * @return the actual text
+     */
+    public String getActualText()
+    {
+        return this.getProperties() == null ? null :
+            this.getProperties().getString(COSName.ACTUAL_TEXT);
+    }
+
+    /**
+     * Gets the alternate description (Alt).
+     * 
+     * @return the alternate description
+     */
+    public String getAlternateDescription()
+    {
+        return this.getProperties() == null ? null :
+            this.getProperties().getString(COSName.ALT);
+    }
+
+    /**
+     * Gets the expanded form (E).
+     * 
+     * @return the expanded form
+     */
+    public String getExpandedForm()
+    {
+        return this.getProperties() == null ? null :
+            this.getProperties().getString(COSName.E);
+    }
+
+    /**
+     * Gets the contents of the marked content sequence. Can be
+     * <ul>
+     *   <li>{@link TextPosition},</li>
+     *   <li>{@link PDMarkedContent}, or</li>
+     *   <li>{@link PDXObject}.</li>
+     * </ul>
+     * 
+     * @return the contents of the marked content sequence
+     */
+    public List<Object> getContents()
+    {
+        return this.contents;
+    }
+
+    /**
+     * Adds a text position to the contents.
+     * 
+     * @param text the text position
+     */
+    public void addText(TextPosition text)
+    {
+        this.getContents().add(text);
+    }
+
+    /**
+     * Adds a marked content to the contents.
+     * 
+     * @param markedContent the marked content
+     */
+    public void addMarkedContent(PDMarkedContent markedContent)
+    {
+        this.getContents().add(markedContent);
+    }
+
+    /**
+     * Adds an XObject to the contents.
+     * 
+     * @param xobject the XObject
+     */
+    public void addXObject(PDXObject xobject)
+    {
+        this.getContents().add(xobject);
+    }
+
+
+    @Override
+    public String toString()
+    {
+        return "tag=" + this.tag +
+                ", properties=" + this.properties +
+                ", contents=" + this.contents;
+    }
+
+}

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java Wed Sep 14
20:17:11 2016
@@ -666,14 +666,13 @@ public final class Matrix implements Clo
     @Override
     public String toString()
     {
-        StringBuffer sb = new StringBuffer( "" );
-        sb.append("[");
-        sb.append(single[0] + ",");
-        sb.append(single[1] + ",");
-        sb.append(single[3] + ",");
-        sb.append(single[4] + ",");
-        sb.append(single[6] + ",");
-        sb.append(single[7] + "]");
-        return sb.toString();
+        String sb = "" + "[" +
+                single[0] + "," +
+                single[1] + "," +
+                single[3] + "," +
+                single[4] + "," +
+                single[6] + "," +
+                single[7] + "]";
+        return sb;
     }
 }

Modified: pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java (original)
+++ pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java Wed Sep
14 20:17:11 2016
@@ -341,11 +341,11 @@ public class TextToPDF
         StringBuilder message = new StringBuilder();       
         message.append("Usage: jar -jar pdfbox-app-x.y.z.jar TextToPDF [options] <outputfile>
<textfile>\n");
         message.append("\nOptions:\n");
-        message.append("  -standardFont <name> : " + DEFAULT_FONT.getBaseFont() + "
(default)\n");
+        message.append("  -standardFont <name> : ").append(DEFAULT_FONT.getBaseFont()).append("
(default)\n");
 
         for (String std14String : std14)
         {
-            message.append("                         " + std14String + "\n");
+            message.append("                         ").append(std14String).append("\n");
         }
         message.append("  -ttf <ttf file>      : The TTF font to use.\n");
         message.append("  -fontSize <fontSize> : default: " + DEFAULT_FONT_SIZE );

Modified: pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
(original)
+++ pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
Wed Sep 14 20:17:11 2016
@@ -99,10 +99,7 @@ public abstract class AbstractSimpleProp
     @Override
     public String toString()
     {
-        StringBuilder sb = new StringBuilder();
-        sb.append("[").append(this.getClass().getSimpleName()).append(":");
-        sb.append(getStringValue()).append("]");
-        return sb.toString();
+        return "[" + this.getClass().getSimpleName() + ":" + getStringValue() + "]";
     }
 
     /**

Modified: pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java?rev=1760748&r1=1760747&r2=1760748&view=diff
==============================================================================
--- pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java (original)
+++ pdfbox/branches/2.0/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java Wed Sep
14 20:17:11 2016
@@ -118,9 +118,7 @@ public class Attribute
 
     public String toString()
     {
-        StringBuilder sb = new StringBuilder(80);
-        sb.append("[attr:{").append(nsURI).append("}").append(name).append("=").append(value).append("]");
-        return sb.toString();
+        return "[attr:{" + nsURI + "}" + name + "=" + value + "]";
     }
 
 }



Mime
View raw message