You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by lg...@apache.org on 2005/09/07 00:22:04 UTC
svn commit: r279154 -
/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java
Author: lgawron
Date: Tue Sep 6 15:21:40 2005
New Revision: 279154
URL: http://svn.apache.org/viewcvs?rev=279154&view=rev
Log:
jxt expression compiler supporting {language:expression} syntax.
Added:
cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java (with props)
Added: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java?rev=279154&view=auto
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java (added)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java Tue Sep 6 15:21:40 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.template.expression;
+
+import java.io.Reader;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @version SVN $Id$
+ */
+public class NewStyleJXTExpressionCompiler extends JXTExpressionCompiler {
+ public List compileSubstitutions(Reader in) throws Exception {
+ LinkedList substitutions = new LinkedList();
+ StringBuffer buf = new StringBuffer();
+ buf.setLength(0);
+ int ch;
+ boolean inExpr = false;
+ top: while ((ch = in.read()) != -1) {
+ // column++;
+ char c = (char) ch;
+ processChar: while (true) {
+ if (inExpr) {
+ if (c == '\\') {
+ ch = in.read();
+ buf.append(ch == -1 ? '\\' : (char) ch);
+ } else if (c == '}') {
+ String str = buf.toString();
+ substitutions.add(compile(str));
+ buf.setLength(0);
+ inExpr = false;
+ } else {
+ buf.append(c);
+ }
+ } else if (c == '{' ) {
+ ch = in.read();
+ if (ch != '{') {
+ inExpr = true;
+ if (buf.length() > 0) {
+ substitutions.add(new Literal(buf.toString()));
+ buf.setLength(0);
+ }
+ buf.append((char) ch);
+ continue top;
+ }
+ buf.append(c);
+ if (ch != -1) {
+ c = (char) ch;
+ continue processChar;
+ }
+ } else {
+ buf.append(c);
+ }
+ break;
+ }
+ }
+ if (inExpr)
+ throw new Exception("Unterminated {");
+ substitutions.add(new Literal(buf.toString()));
+ return substitutions;
+ }
+
+}
Propchange: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/NewStyleJXTExpressionCompiler.java
------------------------------------------------------------------------------
svn:keywords = Id