Return-Path: Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 11032 invoked from network); 4 Aug 2003 00:53:02 -0000 Received: from eng.werken.com (HELO codehaus.org) (66.216.68.111) by daedalus.apache.org with SMTP; 4 Aug 2003 00:53:02 -0000 Received: from hogshead.codehaus.org (hogshead.codehaus.org [66.216.68.111]) by codehaus.org (8.11.6/8.11.6) with ESMTP id h740vbT23431 for ; Sun, 3 Aug 2003 19:57:37 -0500 Message-ID: <26269381.1059958657117.JavaMail.orion@hogshead.codehaus.org> Date: Sun, 3 Aug 2003 19:57:37 -0500 (CDT) From: jira@codehaus.org To: commons-dev@jakarta.apache.org Subject: [jira] Updated: (JELLY-57) support encoding parameter for util:loadText Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N The following issue has been updated: Updater: Bill Keese (mailto:billk@tech.beacon-it.co.jp) Date: Sun, 3 Aug 2003 7:56 PM Comment: Patch file for LoadTextTag.java Changes: Attachment changed to LoadTextTag.patchFile.txt --------------------------------------------------------------------- For a full history of the issue, see: http://jira.codehaus.org/secure/ViewIssue.jspa?key=JELLY-57&page=history --------------------------------------------------------------------- View the issue: http://jira.codehaus.org/secure/ViewIssue.jspa?key=JELLY-57 Here is an overview of the issue: --------------------------------------------------------------------- Key: JELLY-57 Summary: support encoding parameter for util:loadText Type: Improvement Status: Unassigned Priority: Minor Time Spent: Unknown Remaining: 2 hours Project: jelly Assignee: Reporter: Bill Keese Created: Sun, 22 Jun 2003 9:42 PM Updated: Sun, 3 Aug 2003 7:56 PM Description: This patch lets you specify the encoding of files you read in with LoadTextTag.java. Index: LoadTextTag.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/jelly/jelly-tags/util/src/java/org/apache/commons/jelly/tags/util/LoadTextTag.java,v retrieving revision 1.2 diff -u -r1.2 LoadTextTag.java --- LoadTextTag.java 25 Jan 2003 19:31:48 -0000 1.2 +++ LoadTextTag.java 20 Jun 2003 04:06:02 -0000 @@ -64,7 +64,8 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileReader; +import java.io.UnsupportedEncodingException; +import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; @@ -92,6 +93,7 @@ private String var; private File file; private String uri; + private String encoding="utf-8"; public LoadTextTag() { } @@ -105,27 +107,31 @@ if (file == null && uri == null) { throw new JellyTagException( "This tag must have a 'file' or 'uri' specified" ); } - Reader reader = null; + + InputStream in = null; if (file != null) { if (! file.exists()) { throw new JellyTagException( "The file: " + file + " does not exist" ); } - try { - reader = new FileReader(file); + in = new FileInputStream(file); } catch (FileNotFoundException e) { throw new JellyTagException("could not find the file",e); } - } - else { - InputStream in = context.getResourceAsStream(uri); + } else { + in = context.getResourceAsStream(uri); if (in == null) { throw new JellyTagException( "Could not find uri: " + uri ); } - // @todo should we allow an encoding to be specified? - reader = new InputStreamReader(in); } - + + Reader reader = null; + try { + reader = new InputStreamReader(in, encoding); + } catch (UnsupportedEncodingException e) { + throw new JellyTagException("unsupported encoding",e); + } + String text = null; try { @@ -177,6 +183,13 @@ */ public void setFile(File file) { this.file = file; + } + + /** + * Sets the encoding to use to read the file + */ + public void setEncoding(String encoding) { + this.encoding = encoding; } /** --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira