You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Sérgio 7 Reais <co...@newenterprise.com.br> on 2007/06/05 06:45:04 UTC
Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: nbubna@apache.org
To: commits@velocity.apache.org
Sent: Monday, June 04, 2007 11:25 PM
Subject: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Author: nbubna
Date: Mon Jun 4 19:25:18 2007
New Revision: 544345
URL: http://svn.apache.org/viewvc?view=rev&rev=544345
Log:
drop jdk 1.3 support for LinkTool
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java?view=diff&rev=544345&r1=544344&r2=544345
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java Mon Jun 4 19:25:18 2007
@@ -19,8 +19,7 @@
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
@@ -113,27 +112,6 @@
private boolean selfParams;
- /** Java 1.4 encode method to use instead of deprecated 1.3 version. */
- private static Method encode = null;
-
- /* Initialize the encode variable with the 1.4 method if available.
- * this code was adapted from org.apache.struts.utils.RequestUtils */
- static
- {
- try
- {
- /* get version of encode method with two String args */
- Class[] args = new Class[] { String.class, String.class };
- encode = URLEncoder.class.getMethod("encode", args);
- }
- catch (NoSuchMethodException e)
- {
- //TODO: drop JDK 1.3 support in separate commit
- //LOG.debug("LinkTool : Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
- }
- }
-
-
/**
* Default constructor. Tool must be initialized before use.
*/
@@ -805,39 +783,24 @@
/**
- * Use the new URLEncoder.encode() method from java 1.4 if available, else
- * use the old deprecated version. This method uses reflection to find the appropriate
- * method; if the reflection operations throw exceptions, this will return the url
- * encoded with the old URLEncoder.encode() method.
+ * Delegates encoding of the specified url to
+ * {@link URLEncoder#encode} using the character encoding for the current
+ * {@link HttpServletResponse}.
*
* @return String - the encoded url.
*/
public String encodeURL(String url)
{
- /* first try encoding with new 1.4 method */
- if (encode != null)
+ try
{
- try
- {
- Object[] args =
- new Object[] { url, this.response.getCharacterEncoding() };
- return (String)encode.invoke(null, args);
- }
- catch (IllegalAccessException e)
- {
- // don't keep trying if we get one of these
- encode = null;
-
- LOG.debug("LinkTool : Can't access JDK 1.4 encode method."
- + " Using deprecated version from now on.", e);
- }
- catch (InvocationTargetException e)
- {
- LOG.debug("LinkTool : Error using JDK 1.4 encode method."
- + " Using deprecated version.", e);
- }
+ return URLEncoder.encode(url, this.response.getCharacterEncoding());
+ }
+ catch(UnsupportedEncodingException uee)
+ {
+ LOG.error("LinkTool : Response character encoding '" +
+ response.getCharacterEncoding() + "' is unsupported", uee);
+ return null;
}
- return URLEncoder.encode(url);
}
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Posted by Sérgio 7 Reais <co...@newenterprise.com.br>.
----- Original Message -----
From: Sérgio 7 Reais
To: dev@velocity.apache.org
Sent: Thursday, June 07, 2007 12:42 AM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: Sérgio 7 Reais
To: Velocity Developers List ; Sérgio 7 Reais
Sent: Wednesday, June 06, 2007 11:26 PM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: Sérgio 7 Reais
To: dev@velocity.apache.org
Sent: Tuesday, June 05, 2007 1:45 AM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: nbubna@apache.org
To: commits@velocity.apache.org
Sent: Monday, June 04, 2007 11:25 PM
Subject: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Author: nbubna
Date: Mon Jun 4 19:25:18 2007
New Revision: 544345
URL: http://svn.apache.org/viewvc?view=rev&rev=544345
Log:
drop jdk 1.3 support for LinkTool
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java?view=diff&rev=544345&r1=544344&r2=544345
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java Mon Jun 4 19:25:18 2007
@@ -19,8 +19,7 @@
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
@@ -113,27 +112,6 @@
private boolean selfParams;
- /** Java 1.4 encode method to use instead of deprecated 1.3 version. */
- private static Method encode = null;
-
- /* Initialize the encode variable with the 1.4 method if available.
- * this code was adapted from org.apache.struts.utils.RequestUtils */
- static
- {
- try
- {
- /* get version of encode method with two String args */
- Class[] args = new Class[] { String.class, String.class };
- encode = URLEncoder.class.getMethod("encode", args);
- }
- catch (NoSuchMethodException e)
- {
- //TODO: drop JDK 1.3 support in separate commit
- //LOG.debug("LinkTool : Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
- }
- }
-
-
/**
* Default constructor. Tool must be initialized before use.
*/
@@ -805,39 +783,24 @@
/**
- * Use the new URLEncoder.encode() method from java 1.4 if available, else
- * use the old deprecated version. This method uses reflection to find the appropriate
- * method; if the reflection operations throw exceptions, this will return the url
- * encoded with the old URLEncoder.encode() method.
+ * Delegates encoding of the specified url to
+ * {@link URLEncoder#encode} using the character encoding for the current
+ * {@link HttpServletResponse}.
*
* @return String - the encoded url.
*/
public String encodeURL(String url)
{
- /* first try encoding with new 1.4 method */
- if (encode != null)
+ try
{
- try
- {
- Object[] args =
- new Object[] { url, this.response.getCharacterEncoding() };
- return (String)encode.invoke(null, args);
- }
- catch (IllegalAccessException e)
- {
- // don't keep trying if we get one of these
- encode = null;
-
- LOG.debug("LinkTool : Can't access JDK 1.4 encode method."
- + " Using deprecated version from now on.", e);
- }
- catch (InvocationTargetException e)
- {
- LOG.debug("LinkTool : Error using JDK 1.4 encode method."
- + " Using deprecated version.", e);
- }
+ return URLEncoder.encode(url, this.response.getCharacterEncoding());
+ }
+ catch(UnsupportedEncodingException uee)
+ {
+ LOG.error("LinkTool : Response character encoding '" +
+ response.getCharacterEncoding() + "' is unsupported", uee);
+ return null;
}
- return URLEncoder.encode(url);
}
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.9/834 - Release Date: 5/6/2007 14:38
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.9/834 - Release Date: 5/6/2007 14:38
Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Posted by Sérgio 7 Reais <co...@newenterprise.com.br>.
----- Original Message -----
From: Sérgio 7 Reais
To: Velocity Developers List ; Sérgio 7 Reais
Sent: Wednesday, June 06, 2007 11:26 PM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: Sérgio 7 Reais
To: dev@velocity.apache.org
Sent: Tuesday, June 05, 2007 1:45 AM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: nbubna@apache.org
To: commits@velocity.apache.org
Sent: Monday, June 04, 2007 11:25 PM
Subject: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Author: nbubna
Date: Mon Jun 4 19:25:18 2007
New Revision: 544345
URL: http://svn.apache.org/viewvc?view=rev&rev=544345
Log:
drop jdk 1.3 support for LinkTool
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java?view=diff&rev=544345&r1=544344&r2=544345
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java Mon Jun 4 19:25:18 2007
@@ -19,8 +19,7 @@
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
@@ -113,27 +112,6 @@
private boolean selfParams;
- /** Java 1.4 encode method to use instead of deprecated 1.3 version. */
- private static Method encode = null;
-
- /* Initialize the encode variable with the 1.4 method if available.
- * this code was adapted from org.apache.struts.utils.RequestUtils */
- static
- {
- try
- {
- /* get version of encode method with two String args */
- Class[] args = new Class[] { String.class, String.class };
- encode = URLEncoder.class.getMethod("encode", args);
- }
- catch (NoSuchMethodException e)
- {
- //TODO: drop JDK 1.3 support in separate commit
- //LOG.debug("LinkTool : Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
- }
- }
-
-
/**
* Default constructor. Tool must be initialized before use.
*/
@@ -805,39 +783,24 @@
/**
- * Use the new URLEncoder.encode() method from java 1.4 if available, else
- * use the old deprecated version. This method uses reflection to find the appropriate
- * method; if the reflection operations throw exceptions, this will return the url
- * encoded with the old URLEncoder.encode() method.
+ * Delegates encoding of the specified url to
+ * {@link URLEncoder#encode} using the character encoding for the current
+ * {@link HttpServletResponse}.
*
* @return String - the encoded url.
*/
public String encodeURL(String url)
{
- /* first try encoding with new 1.4 method */
- if (encode != null)
+ try
{
- try
- {
- Object[] args =
- new Object[] { url, this.response.getCharacterEncoding() };
- return (String)encode.invoke(null, args);
- }
- catch (IllegalAccessException e)
- {
- // don't keep trying if we get one of these
- encode = null;
-
- LOG.debug("LinkTool : Can't access JDK 1.4 encode method."
- + " Using deprecated version from now on.", e);
- }
- catch (InvocationTargetException e)
- {
- LOG.debug("LinkTool : Error using JDK 1.4 encode method."
- + " Using deprecated version.", e);
- }
+ return URLEncoder.encode(url, this.response.getCharacterEncoding());
+ }
+ catch(UnsupportedEncodingException uee)
+ {
+ LOG.error("LinkTool : Response character encoding '" +
+ response.getCharacterEncoding() + "' is unsupported", uee);
+ return null;
}
- return URLEncoder.encode(url);
}
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.9/834 - Release Date: 5/6/2007 14:38
Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Posted by Sérgio 7 Reais <co...@newenterprise.com.br>.
----- Original Message -----
From: Sérgio 7 Reais
To: dev@velocity.apache.org
Sent: Tuesday, June 05, 2007 1:45 AM
Subject: Re: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
----- Original Message -----
From: nbubna@apache.org
To: commits@velocity.apache.org
Sent: Monday, June 04, 2007 11:25 PM
Subject: svn commit: r544345 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Author: nbubna
Date: Mon Jun 4 19:25:18 2007
New Revision: 544345
URL: http://svn.apache.org/viewvc?view=rev&rev=544345
Log:
drop jdk 1.3 support for LinkTool
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java?view=diff&rev=544345&r1=544344&r2=544345
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/LinkTool.java Mon Jun 4 19:25:18 2007
@@ -19,8 +19,7 @@
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
@@ -113,27 +112,6 @@
private boolean selfParams;
- /** Java 1.4 encode method to use instead of deprecated 1.3 version. */
- private static Method encode = null;
-
- /* Initialize the encode variable with the 1.4 method if available.
- * this code was adapted from org.apache.struts.utils.RequestUtils */
- static
- {
- try
- {
- /* get version of encode method with two String args */
- Class[] args = new Class[] { String.class, String.class };
- encode = URLEncoder.class.getMethod("encode", args);
- }
- catch (NoSuchMethodException e)
- {
- //TODO: drop JDK 1.3 support in separate commit
- //LOG.debug("LinkTool : Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
- }
- }
-
-
/**
* Default constructor. Tool must be initialized before use.
*/
@@ -805,39 +783,24 @@
/**
- * Use the new URLEncoder.encode() method from java 1.4 if available, else
- * use the old deprecated version. This method uses reflection to find the appropriate
- * method; if the reflection operations throw exceptions, this will return the url
- * encoded with the old URLEncoder.encode() method.
+ * Delegates encoding of the specified url to
+ * {@link URLEncoder#encode} using the character encoding for the current
+ * {@link HttpServletResponse}.
*
* @return String - the encoded url.
*/
public String encodeURL(String url)
{
- /* first try encoding with new 1.4 method */
- if (encode != null)
+ try
{
- try
- {
- Object[] args =
- new Object[] { url, this.response.getCharacterEncoding() };
- return (String)encode.invoke(null, args);
- }
- catch (IllegalAccessException e)
- {
- // don't keep trying if we get one of these
- encode = null;
-
- LOG.debug("LinkTool : Can't access JDK 1.4 encode method."
- + " Using deprecated version from now on.", e);
- }
- catch (InvocationTargetException e)
- {
- LOG.debug("LinkTool : Error using JDK 1.4 encode method."
- + " Using deprecated version.", e);
- }
+ return URLEncoder.encode(url, this.response.getCharacterEncoding());
+ }
+ catch(UnsupportedEncodingException uee)
+ {
+ LOG.error("LinkTool : Response character encoding '" +
+ response.getCharacterEncoding() + "' is unsupported", uee);
+ return null;
}
- return URLEncoder.encode(url);
}
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47