[jboss-cvs] JBossAS SVN: r76175 - projects/vfs/trunk/src/main/java/org/jboss/virtual.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 24 10:02:12 EDT 2008
Author: alesj
Date: 2008-07-24 10:02:12 -0400 (Thu, 24 Jul 2008)
New Revision: 76175
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
Log:
Add decode method.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java 2008-07-24 13:33:21 UTC (rev 76174)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java 2008-07-24 14:02:12 UTC (rev 76175)
@@ -27,6 +27,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -59,6 +60,10 @@
{
/** The log */
private static final Logger log = Logger.getLogger(VFSUtils.class);
+
+ /** The default encoding */
+ private static final String DEFAULT_ENCODING = "UTF-8";
+
/** The link */
public static final String VFS_LINK_PREFIX = ".vfslink";
/** The link name */
@@ -304,10 +309,41 @@
return name;
if (name.charAt(length-1) == '/')
return name.substring(0, length-1);
+
return name;
}
/**
+ * Decode the path with UTF-8 encoding..
+ *
+ * @param path the path to decode
+ * @return decoded path
+ */
+ public static String decode(String path)
+ {
+ return decode(path, DEFAULT_ENCODING);
+ }
+
+ /**
+ * Decode the path.
+ *
+ * @param path the path to decode
+ * @param encoding the encodeing
+ * @return decoded path
+ */
+ public static String decode(String path, String encoding)
+ {
+ try
+ {
+ return URLDecoder.decode(path, encoding);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IllegalArgumentException("Cannot decode: " + path + " [" + encoding + "]", e);
+ }
+ }
+
+ /**
* Get the name.
*
* @param uri the uri
More information about the jboss-cvs-commits
mailing list