You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2008/04/18 15:10:16 UTC

svn commit: r649521 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java

Author: jeremias
Date: Fri Apr 18 06:10:14 2008
New Revision: 649521

URL: http://svn.apache.org/viewvc?rev=649521&view=rev
Log:
Refinement for last change for ImageUtil: Ignore any string without a "#" because in that case there's no page information to get anyway. This way normal filenames are just passed through.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java
    xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java?rev=649521&r1=649520&r2=649521&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java Fri Apr 18 06:10:14 2008
@@ -337,6 +337,9 @@
      *         in the URI
      */
     public static Integer getPageIndexFromURI(String uri) {
+        if (uri.indexOf('#') < 0) {
+            return null;
+        }
         try {
             URI u = new URI(uri);
             String fragment = u.getFragment();

Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java?rev=649521&r1=649520&r2=649521&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageUtilTestCase.java Fri Apr 18 06:10:14 2008
@@ -74,6 +74,10 @@
         pageIndex = ImageUtil.getPageIndexFromURI("http://localhost/images/scan1.tif#page=3");
         assertEquals(2, pageIndex.intValue());
         //Note: no detailed test anymore as this is tested through needPageIndexFromURI().
+        
+        //getPageIndexFromURI only works on URIs, so ignore anything that doesn't have a '#'
+        pageIndex = ImageUtil.getPageIndexFromURI("C:\\Temp\\scan1.tif");
+        assertNull(pageIndex);
     }
     
 }



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org