[jboss-svn-commits] JBoss Common SVN: r2302 - in common-old/branches/Branch_1_0: src/main/org/jboss/util/propertyeditor and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Mar 26 13:47:57 EDT 2007
Author: dimitris at jboss.org
Date: 2007-03-26 13:47:57 -0400 (Mon, 26 Mar 2007)
New Revision: 2302
Modified:
common-old/branches/Branch_1_0/src/main/org/jboss/util/Strings.java
common-old/branches/Branch_1_0/src/main/org/jboss/util/propertyeditor/URIEditor.java
common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent
Log:
JBCOMMON-19, Deal with spaces in local file URIs
Modified: common-old/branches/Branch_1_0/src/main/org/jboss/util/Strings.java
===================================================================
--- common-old/branches/Branch_1_0/src/main/org/jboss/util/Strings.java 2007-03-20 00:56:36 UTC (rev 2301)
+++ common-old/branches/Branch_1_0/src/main/org/jboss/util/Strings.java 2007-03-26 17:47:57 UTC (rev 2302)
@@ -1,30 +1,33 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.util;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLEncoder;
import java.util.Map;
/**
@@ -812,6 +815,25 @@
return url;
}
+ public static URI toURI(String urispec, final String relativePrefix)
+ throws URISyntaxException
+ {
+ urispec = urispec.trim();
+
+ URI uri;
+
+ if( urispec.startsWith("file:") )
+ {
+ uri = makeURIFromFilespec(urispec.substring(5), relativePrefix);
+ }
+ else
+ {
+ uri = new URI(urispec);
+ }
+
+ return uri;
+ }
+
/** A helper to make a URL from a filespec. */
private static URL makeURLFromFilespec(final String filespec, final String relativePrefix)
throws IOException
@@ -830,6 +852,19 @@
return file.toURL();
}
+ private static URI makeURIFromFilespec(final String filespec, final String relativePrefix)
+ {
+ // make sure the file is absolute & canonical file url
+ File file = new File(filespec);
+
+ // if we have a prefix and the file is not abs then prepend
+ if (relativePrefix != null && !file.isAbsolute())
+ {
+ file = new File(relativePrefix, filespec);
+ }
+
+ return file.toURI();
+ }
/**
* Make a URL from the given string.
@@ -847,6 +882,18 @@
}
/**
+ *
+ * @param urispec
+ * @return
+ * @throws MalformedURLException
+ */
+ public static URI toURI(final String urispec)
+ throws URISyntaxException
+ {
+ return toURI(urispec, null);
+ }
+
+ /**
* Check whether the given String is a reserved Java Keyword
* according to the Java Language Specifications.
*
@@ -977,13 +1024,13 @@
else
return object.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(object));
}
-
+
/**
- * The default toString implementation of an object creates string in the
- * form className at hexHashCode
+ * The default toString implementation of an object
*
* @param object the object
* @param buffer the string builder
+ * @return a string in the form className at hexHashCode
*/
public static final void defaultToString(JBossStringBuilder buffer, Object object)
{
@@ -998,11 +1045,11 @@
}
/**
- * The default toString implementation of an object creates string in the
- * form className at hexHashCode
+ * The default toString implementation of an object
*
* @param object the object
* @param buffer the string buffer
+ * @return a string in the form className at hexHashCode
*/
public static final void defaultToString(StringBuffer buffer, Object object)
{
Modified: common-old/branches/Branch_1_0/src/main/org/jboss/util/propertyeditor/URIEditor.java
===================================================================
--- common-old/branches/Branch_1_0/src/main/org/jboss/util/propertyeditor/URIEditor.java 2007-03-20 00:56:36 UTC (rev 2301)
+++ common-old/branches/Branch_1_0/src/main/org/jboss/util/propertyeditor/URIEditor.java 2007-03-26 17:47:57 UTC (rev 2302)
@@ -1,30 +1,31 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.util.propertyeditor;
import java.net.URI;
import java.net.URISyntaxException;
import org.jboss.util.NestedRuntimeException;
+import org.jboss.util.Strings;
/**
* A property editor for {@link java.net.URI}.
@@ -45,8 +46,7 @@
{
try
{
- // TODO - more strict checking, like URLEditor
- return new URI(getAsText());
+ return Strings.toURI(getAsText());
}
catch (URISyntaxException e)
{
Modified: common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent
===================================================================
--- common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent 2007-03-20 00:56:36 UTC (rev 2301)
+++ common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent 2007-03-26 17:47:57 UTC (rev 2302)
@@ -103,7 +103,7 @@
<property name="version.major" value="1"/>
<property name="version.minor" value="0"/>
<property name="version.revision" value="5"/>
- <property name="version.tag" value="snapshot"/>
+ <property name="version.tag" value="snapshot-Branch_1_0"/>
<property name="version.name" value="Zion"/>
<!-- This must be set to the SVN tag for any release -->
<property name="version.cvstag" value="https://svn.jboss.org/repos/common/common-old/branches/Branch_1_0/"/>
More information about the jboss-svn-commits
mailing list