cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r280946 - in /cocoon/trunk/src/java/org/apache/cocoon/util/location: LocationAttributes.java LocationImpl.java LocationUtils.java
Date Wed, 14 Sep 2005 21:43:10 GMT
Author: sylvain
Date: Wed Sep 14 14:43:05 2005
New Revision: 280946

URL: http://svn.apache.org/viewcvs?rev=280946&view=rev
Log:
Move the static toString() to LocationUtils

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationAttributes.java
    cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationImpl.java
    cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationUtils.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationAttributes.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationAttributes.java?rev=280946&r1=280945&r2=280946&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationAttributes.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationAttributes.java Wed Sep
14 14:43:05 2005
@@ -115,7 +115,7 @@
     public static String getLocationString(Attributes attrs) {
         String src = attrs.getValue(URI, SRC_ATTR);
         if (src == null) {
-            return LocationImpl.UNKNOWN_STRING;
+            return LocationUtils.UNKNOWN_STRING;
         }
         
         return src + ":" + attrs.getValue(URI, LINE_ATTR) + ":" + attrs.getValue(URI, COL_ATTR);
@@ -130,7 +130,7 @@
      */
     public static String getURI(Attributes attrs) {
         String src = attrs.getValue(URI, SRC_ATTR);
-        return src != null ? src : LocationImpl.UNKNOWN_STRING;
+        return src != null ? src : LocationUtils.UNKNOWN_STRING;
     }
     
     /**
@@ -193,7 +193,7 @@
     public static String getLocationString(Element elem) {
         Attr srcAttr = elem.getAttributeNodeNS(URI, SRC_ATTR);
         if (srcAttr == null) {
-            return LocationImpl.UNKNOWN_STRING;
+            return LocationUtils.UNKNOWN_STRING;
         }
         
         return srcAttr.getValue() + ":" + elem.getAttributeNS(URI, LINE_ATTR) + ":" + elem.getAttributeNS(URI,
COL_ATTR);
@@ -208,7 +208,7 @@
      */
     public static String getURI(Element elem) {
         Attr attr = elem.getAttributeNodeNS(URI, SRC_ATTR);
-        return attr != null ? attr.getValue() : LocationImpl.UNKNOWN_STRING;
+        return attr != null ? attr.getValue() : LocationUtils.UNKNOWN_STRING;
     }
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationImpl.java?rev=280946&r1=280945&r2=280946&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationImpl.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationImpl.java Wed Sep 14 14:43:05
2005
@@ -35,11 +35,6 @@
     static final LocationImpl UNKNOWN = new LocationImpl(null, null, -1, -1);
 
     /**
-     * The string representation of an unknown location: "<code>[unknown location]</code>".
-     */
-    public static final String UNKNOWN_STRING = "[unknown location]";
-
-    /**
      * Build a location for a given URI, with unknown line and column numbers.
      * 
      * @param uri the resource URI
@@ -168,33 +163,7 @@
     }
     
     public String toString() {
-        return toString(this);
-    }
-    
-    /**
-     * Builds a string representation of a location, in the
-     * "<code><em>descripton</em> - <em>uri</em>:<em>line</em>:<em>column</em></code>"
-     * format (e.g. "<code>path/to/file.xml:3:40</code>"). For {@link Location#UNKNOWN
an unknown location}, returns
-     * {@link #UNKNOWN_STRING}.
-     * 
-     * @return the string representation
-     */
-    public static String toString(Location location) {
-        StringBuffer result = new StringBuffer();
-
-        String description = location.getDescription();
-        if (description != null) {
-            result.append(description).append(" - ");
-        }
-
-        String uri = location.getURI();
-        if (uri != null) {
-            result.append(uri).append(':').append(location.getLineNumber()).append(':').append(location.getColumnNumber());
-        } else {
-            result.append(UNKNOWN_STRING);
-        }
-        
-        return result.toString();
+        return LocationUtils.toString(this);
     }
     
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationUtils.java?rev=280946&r1=280945&r2=280946&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationUtils.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/location/LocationUtils.java Wed Sep 14 14:43:05
2005
@@ -33,6 +33,11 @@
  */
 public class LocationUtils {
     
+    /**
+     * The string representation of an unknown location: "<code>[unknown location]</code>".
+     */
+    public static final String UNKNOWN_STRING = "[unknown location]";
+    
     private static List finders = new ArrayList();
     
     /**
@@ -56,6 +61,32 @@
     }
     
     /**
+     * Builds a string representation of a location, in the
+     * "<code><em>descripton</em> - <em>uri</em>:<em>line</em>:<em>column</em></code>"
+     * format (e.g. "<code>foo - file://path/to/file.xml:3:40</code>"). For {@link
Location#UNKNOWN an unknown location}, returns
+     * {@link #UNKNOWN_STRING}.
+     * 
+     * @return the string representation
+     */
+    public static String toString(Location location) {
+        StringBuffer result = new StringBuffer();
+
+        String description = location.getDescription();
+        if (description != null) {
+            result.append(description).append(" - ");
+        }
+
+        String uri = location.getURI();
+        if (uri != null) {
+            result.append(uri).append(':').append(location.getLineNumber()).append(':').append(location.getColumnNumber());
+        } else {
+            result.append(UNKNOWN_STRING);
+        }
+        
+        return result.toString();
+    }
+
+    /**
      * Parse a location string of the form "<code><em>uri</em>:<em>line</em>:<em>column</em></code>"
(e.g.
      * "<code>path/to/file.xml:3:40</code>") to a Location object. Additionally,
a description may
      * also optionally be present, separated with an hyphen (e.g. "<code>foo - path/to/file.xml:3.40</code>").
@@ -91,7 +122,7 @@
                 }
             } else {
                 // unkonwn?
-                if (text.endsWith(LocationImpl.UNKNOWN_STRING)) {
+                if (text.endsWith(UNKNOWN_STRING)) {
                     return LocationImpl.UNKNOWN;
                 }
             }



Mime
View raw message