You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/09/14 22:54:22 UTC
svn commit: r280939 - in
/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location:
LocationAttributes.java LocationImpl.java LocationUtils.java
Author: sylvain
Date: Wed Sep 14 13:54:16 2005
New Revision: 280939
URL: http://svn.apache.org/viewcvs?rev=280939&view=rev
Log:
Move the static toString() to LocationUtils
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationAttributes.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationImpl.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationUtils.java
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationAttributes.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationAttributes.java?rev=280939&r1=280938&r2=280939&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationAttributes.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationAttributes.java Wed Sep 14 13:54:16 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/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationImpl.java?rev=280939&r1=280938&r2=280939&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationImpl.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationImpl.java Wed Sep 14 13:54:16 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/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationUtils.java?rev=280939&r1=280938&r2=280939&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationUtils.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/location/LocationUtils.java Wed Sep 14 13:54:16 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();
/**
@@ -55,6 +60,33 @@
// Forbid instanciation
}
+
+ /**
+ * 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
@@ -91,7 +123,7 @@
}
} else {
// unkonwn?
- if (text.endsWith(LocationImpl.UNKNOWN_STRING)) {
+ if (text.endsWith(UNKNOWN_STRING)) {
return LocationImpl.UNKNOWN;
}
}