[richfaces-svn-commits] JBoss Rich Faces SVN: r1304 - trunk/richfaces/common/src/main/java/org/richfaces/renderkit.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jun 25 12:53:45 EDT 2007


Author: nbelaevski
Date: 2007-06-25 12:53:45 -0400 (Mon, 25 Jun 2007)
New Revision: 1304

Removed:
   trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java
Log:
TemplateUtil removed

Deleted: trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java
===================================================================
--- trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java	2007-06-25 16:48:09 UTC (rev 1303)
+++ trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java	2007-06-25 16:53:45 UTC (rev 1304)
@@ -1,167 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007  Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
-
-/**
- * @author Nick Belaevski - nbelaevski at exadel.com
- * created 11.12.2006
- * 
- */
-public class TemplateUtil {
-	
-	public static interface MacroTemplateHandler {
-		public String handle(String body);
-	};
-
-	private StringBuffer definitionBuffer = new StringBuffer();
-	private StringBuffer result = new StringBuffer();
-
-	private int macroDefDepth = 0;
-	private boolean escapeCharOccured = false;
-	private MacroTemplateHandler templateHandler;
-	private boolean macroDefined = false;
-	
-	public TemplateUtil(MacroTemplateHandler templateHandler) {
-		super();
-		this.templateHandler = templateHandler;
-	}
-
-	private Boolean literalMode = null;
-
-	private void doWriteChar(char c) throws IOException {
-		if (macroDefDepth == 0) {
-			if (literalMode == null) {
-				result.append('\'');
-				literalMode = Boolean.TRUE;
-			} else if (Boolean.FALSE.equals(literalMode)) {
-				result.append(" + \'");
-				literalMode = Boolean.TRUE;
-			}
-
-			if (escapeCharOccured) {
-				result.append("\\\\");
-			} 
-
-			result.append(StringEscapeUtils.escapeJavaScript(String.valueOf(c)));
-		} else {
-			if (escapeCharOccured) {
-				definitionBuffer.append('\\');
-			} 
-
-			definitionBuffer.append(c);
-		}
-	}
-
-	/* (non-Javadoc)
-	 * @see java.io.Writer#write(char[], int, int)
-	 */
-	public TemplateUtil append(String string) throws IOException {
-		char[] cbuf = string.toCharArray();
-		for (int i = 0; i < cbuf.length; i++) {
-			char c = cbuf[i];
-
-			if (c == '{') {
-				if (escapeCharOccured) {
-					escapeCharOccured = false;
-					doWriteChar(c);
-				} else {
-					if (macroDefDepth++ != 0) {
-						doWriteChar(c);
-					}
-				}
-			} else if (c == '}') {
-				if (escapeCharOccured) {
-					if (macroDefDepth == 0) {
-						doWriteChar(c);
-						escapeCharOccured = false;
-					} else {
-						escapeCharOccured = false;
-						doWriteChar(c);
-					}
-				} else {
-					if (macroDefDepth > 0 && --macroDefDepth == 0) {
-						if (Boolean.TRUE.equals(literalMode)) {
-							result.append('\'');
-						}
-
-						if (literalMode != null) {
-							result.append(" + ");
-						}
-
-						literalMode = Boolean.FALSE;
-
-						macroDefined = true;
-						result.append(templateHandler.handle(definitionBuffer.toString()));
-						definitionBuffer = new StringBuffer();
-					} else {
-						doWriteChar(c);
-					}
-				}
-			} else {
-				if (c == '\\') {
-					if (escapeCharOccured) {
-						escapeCharOccured = false;
-						doWriteChar(c);
-					}
-
-					escapeCharOccured = true;
-				} else {
-					doWriteChar(c);
-					escapeCharOccured = false;
-				}
-			}
-		}
-		
-		return this;
-	}
-
-	public String getResult() throws IOException {
-		boolean tmpEscapeCharOccured = escapeCharOccured;
-		escapeCharOccured = false;
-
-		if (macroDefDepth > 0) {
-			macroDefDepth = 0;
-			doWriteChar('{');
-			result.append(StringEscapeUtils.escapeJavaScript(definitionBuffer.toString()));
-		}
-
-		if (tmpEscapeCharOccured) {
-			doWriteChar('\\');
-		}
-
-		if (Boolean.TRUE.equals(literalMode)) {
-			result.append('\'');
-		}
-
-		literalMode = null;
-		
-		return result.toString();
-	}
-	
-	public boolean isMacroDefined() {
-		return macroDefined;
-	}
-}




More information about the richfaces-svn-commits mailing list