Return-Path: Delivered-To: apmail-incubator-abdera-commits-archive@locus.apache.org Received: (qmail 79835 invoked from network); 3 Dec 2007 04:33:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2007 04:33:45 -0000 Received: (qmail 74013 invoked by uid 500); 3 Dec 2007 04:33:33 -0000 Delivered-To: apmail-incubator-abdera-commits-archive@incubator.apache.org Received: (qmail 73998 invoked by uid 500); 3 Dec 2007 04:33:33 -0000 Mailing-List: contact abdera-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: abdera-dev@incubator.apache.org Delivered-To: mailing list abdera-commits@incubator.apache.org Received: (qmail 73989 invoked by uid 99); 3 Dec 2007 04:33:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Dec 2007 20:33:33 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2007 04:33:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E62091A9832; Sun, 2 Dec 2007 20:33:23 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r600426 - in /incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates: Evaluator.java Operation.java Template.java Date: Mon, 03 Dec 2007 04:33:23 -0000 To: abdera-commits@incubator.apache.org From: jmsnell@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071203043323.E62091A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jmsnell Date: Sun Dec 2 20:33:20 2007 New Revision: 600426 URL: http://svn.apache.org/viewvc?rev=600426&view=rev Log: Additional tweaks for bidi support. This should be about finished. Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Evaluator.java incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Operation.java incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Evaluator.java URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Evaluator.java?rev=600426&r1=600425&r2=600426&view=diff ============================================================================== --- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Evaluator.java (original) +++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Evaluator.java Sun Dec 2 20:33:20 2007 @@ -17,6 +17,7 @@ */ package org.apache.abdera.i18n.templates; +import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -45,10 +46,12 @@ /** * Writes a plain-text description of the template token + * @throws IOException */ void explain( String token, - StringBuilder buf) { + Appendable buf) + throws IOException { Matcher matcher = PATTERN.matcher(token); if (matcher.find()) { String op = matcher.group(1); Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Operation.java URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Operation.java?rev=600426&r1=600425&r2=600426&view=diff ============================================================================== --- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Operation.java (original) +++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Operation.java Sun Dec 2 20:33:20 2007 @@ -51,7 +51,7 @@ public abstract String evaluate(String var, String arg, Context context); - public abstract void explain(String var, String arg, StringBuilder buf); + public abstract void explain(String var, String arg, Appendable buf) throws IOException; public String[] getVariables(String var) { List list = new ArrayList(); @@ -328,10 +328,10 @@ public String evaluate(String var, String arg, Context context) { return eval(var, context); } - public void explain(String var, String arg, StringBuilder buf) { - buf.append("Replaced with the value of '"); - buf.append(var); - buf.append("'"); + public void explain(String var, String arg, Appendable buf) throws IOException { + buf.append("Replaced with the value of '") + .append(var) + .append("'"); } } @@ -342,14 +342,14 @@ String value = eval(var,context); return value == null || value.length() == 0 ? "" : arg != null ? arg + value : value; } - public void explain(String var, String arg, StringBuilder buf) { - buf.append("If '"); - buf.append(var); - buf.append("' is defined then prefix the value of '"); - buf.append(var); - buf.append("' with '"); - buf.append(arg); - buf.append("'"); + public void explain(String var, String arg, Appendable buf) throws IOException { + buf.append("If '") + .append(var) + .append("' is defined then prefix the value of '") + .append(var) + .append("' with '") + .append(arg) + .append("'"); } } @@ -360,14 +360,14 @@ String value = eval(var,context); return value == null || value.length() == 0 ? "" : arg != null ? value + arg : value; } - public void explain(String var, String arg, StringBuilder buf) { - buf.append("If '"); - buf.append(var); - buf.append("' is defined then append '"); - buf.append(arg); - buf.append("' to the value of '"); - buf.append(var); - buf.append("'"); + public void explain(String var, String arg, Appendable buf) throws IOException { + buf.append("If '") + .append(var) + .append("' is defined then append '") + .append(arg) + .append("' to the value of '") + .append(var) + .append("'"); } } @@ -389,16 +389,16 @@ String value = buf.toString(); return value; } - public void explain(String var, String arg, StringBuilder buf) { + public void explain(String var, String arg, Appendable buf) throws IOException { buf.append("Join 'var=value' with '" + arg + "' for each variable in ["); String[] vars = getVariables(var); boolean b = false; for (String v : vars) { if (b) buf.append(','); else b = true; - buf.append("'"); - buf.append(v); - buf.append("'"); + buf.append("'") + .append(v) + .append("'"); } buf.append("]"); } @@ -410,12 +410,12 @@ public String evaluate(String var, String arg, Context context) { return evallist(var,context,arg); } - public void explain(String var, String arg, StringBuilder buf) { - buf.append("Join the members of the list '"); - buf.append(var); - buf.append("' together with '"); - buf.append(arg); - buf.append("'"); + public void explain(String var, String arg, Appendable buf) throws IOException { + buf.append("Join the members of the list '") + .append(var) + .append("' together with '") + .append(arg) + .append("'"); } } @@ -429,20 +429,20 @@ } return null; } - public void explain(String var, String arg, StringBuilder buf) { + public void explain(String var, String arg, Appendable buf) throws IOException { buf.append("If ["); String[] vars = getVariables(var); boolean b = false; for (String v : vars) { if (b) buf.append(','); else b = true; - buf.append("'"); - buf.append(v); - buf.append("'"); - } - buf.append("] is defined and a string, or a list with one or more members, then insert '"); - buf.append(arg); - buf.append("'"); + buf.append("'") + .append(v) + .append("'"); + } + buf.append("] is defined and a string, or a list with one or more members, then insert '") + .append(arg) + .append("'"); } } @@ -456,20 +456,20 @@ } return null; } - public void explain(String var, String arg, StringBuilder buf) { + public void explain(String var, String arg, Appendable buf) throws IOException { buf.append("If ["); String[] vars = getVariables(var); boolean b = false; for (String v : vars) { if (b) buf.append(','); else b = true; - buf.append("'"); - buf.append(v); - buf.append("'"); - } - buf.append("] is undefined, or a zero length list, then insert '"); - buf.append(arg); - buf.append("'"); + buf.append("'") + .append(v) + .append("'"); + } + buf.append("] is undefined, or a zero length list, then insert '") + .append(arg) + .append("'"); } } Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java?rev=600426&r1=600425&r2=600426&view=diff ============================================================================== --- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java (original) +++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java Sun Dec 2 20:33:20 2007 @@ -17,6 +17,7 @@ */ package org.apache.abdera.i18n.templates; +import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -239,7 +240,25 @@ @Override public String toString() { - StringBuilder buf = new StringBuilder(); + StringBuilder buf = new StringBuilder(); + buf.append("V:" + getPatternForDisplay()); + buf.append('\n'); + buf.append("L:" + CharUtils.bidiLRO(getPattern())); + buf.append('\n'); + return buf.toString(); + } + + public String explain() { + StringBuilder buf = new StringBuilder(); + try { + explain(buf); + } catch (IOException e) { + throw new RuntimeException(e); + } + return buf.toString(); + } + + public void explain(Appendable buf) throws IOException { buf.append("Template:"); buf.append('\n'); buf.append("\t"+getPatternForDisplay()); @@ -258,7 +277,7 @@ buf.append('\n'); for (String token : this) { buf.append('\t'); - buf.append("{" + token + "} \n\t\t "); + buf.append(forDisplay(token) + " \n\t\t "); EVALUATOR.explain(token, buf); buf.append('\n'); } @@ -310,8 +329,6 @@ } buf.append('\n'); buf.append("\t" + expand(c)); - - return buf.toString(); } public static String expand(String pattern, Context context) { @@ -346,7 +363,13 @@ } public static String explain(String pattern) { - Template template = new Template(pattern); - return template.toString(); + return new Template(pattern).explain(); + } + + public static void explain( + String pattern, + Appendable buf) + throws IOException { + new Template(pattern).explain(buf); } }