You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/05/29 17:35:15 UTC
svn commit: r1343781 [6/17] - in /incubator/flex/trunk/modules: ./
thirdparty/velocity/ thirdparty/velocity/build/
thirdparty/velocity/build/lib/ thirdparty/velocity/build/xsl/
thirdparty/velocity/src/java/org/apache/velocity/anakia/
thirdparty/velocit...
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/NodeException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/NodeException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/NodeException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/NodeException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,29 @@
+package org.apache.velocity.runtime.exception;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import org.apache.velocity.runtime.parser.node.Node;
+
+public class NodeException extends Exception
+{
+ public NodeException(String exceptionMessage, Node node)
+ {
+ super(exceptionMessage + ": " + node.literal() +
+ " [line " + node.getLine() + ",column " +
+ node.getColumn() + "]");
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/NodeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/ReferenceException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/ReferenceException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/ReferenceException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/ReferenceException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,35 @@
+package org.apache.velocity.runtime.exception;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import org.apache.velocity.runtime.parser.node.Node;
+
+/**
+ * Exception thrown when a bad reference is found.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: ReferenceException.java,v 1.5.14.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public class ReferenceException extends Exception
+{
+ public ReferenceException(String exceptionMessage, Node node)
+ {
+ super(exceptionMessage + " [line " + node.getLine() + ",column " +
+ node.getColumn() + "] : " + node.literal() +
+ " is not a valid reference.");
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/exception/ReferenceException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,155 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.io.File;
+
+import org.apache.log.Priority;
+import org.apache.log.Logger;
+import org.apache.log.Hierarchy;
+import org.apache.log.LogTarget;
+import org.apache.log.output.io.FileTarget;
+
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * Implementation of a Avalon logger.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: AvalonLogSystem.java,v 1.12.4.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public class AvalonLogSystem implements LogSystem
+{
+ private Logger logger = null;
+
+ private RuntimeServices rsvc = null;
+
+ /**
+ * default CTOR. Initializes itself using the property RUNTIME_LOG
+ * from the Velocity properties
+ */
+
+ public AvalonLogSystem()
+ {
+ }
+
+ public void init( RuntimeServices rs )
+ throws Exception
+ {
+ this.rsvc = rs;
+
+ /*
+ * if a logger is specified, we will use this instead of
+ * the default
+ */
+ String loggerName = (String) rsvc.getProperty("runtime.log.logsystem.avalon.logger");
+
+ if (loggerName != null)
+ {
+ this.logger = Hierarchy.getDefaultHierarchy().getLoggerFor(loggerName);
+ }
+ else
+ {
+ /*
+ * since this is a Velocity-provided logger, we will
+ * use the Runtime configuration
+ */
+ String logfile = (String) rsvc.getProperty( RuntimeConstants.RUNTIME_LOG );
+
+ /*
+ * now init. If we can't, panic!
+ */
+ try
+ {
+ init( logfile );
+
+ logVelocityMessage( 0,
+ "AvalonLogSystem initialized using logfile '" + logfile + "'" );
+ }
+ catch( Exception e )
+ {
+ System.out.println(
+ "PANIC : Error configuring AvalonLogSystem : " + e );
+ System.err.println(
+ "PANIC : Error configuring AvalonLogSystem : " + e );
+
+ throw new Exception("Unable to configure AvalonLogSystem : " + e );
+ }
+ }
+ }
+
+ /**
+ * initializes the log system using the logfile argument
+ *
+ * @param logFile file for log messages
+ */
+ public void init(String logFile)
+ throws Exception
+ {
+
+ /*
+ * make our FileTarget. Note we are going to keep the
+ * default behavior of not appending...
+ */
+ FileTarget target = new FileTarget( new File( logFile),
+ false,
+ new VelocityFormatter("%{time} %{message}\\n%{throwable}" ) );
+
+ /*
+ * use the toString() of RuntimeServices to make a unique logger
+ */
+
+ logger = Hierarchy.getDefaultHierarchy().getLoggerFor( rsvc.toString() );
+ logger.setPriority( Priority.DEBUG );
+ logger.setLogTargets( new LogTarget[] { target } );
+ }
+
+ /**
+ * logs messages
+ *
+ * @param level severity level
+ * @param message complete error message
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ /*
+ * based on level, call teh right logger method
+ * and prefix with the appropos prefix
+ */
+
+ switch (level)
+ {
+ case LogSystem.WARN_ID:
+ logger.warn( RuntimeConstants.WARN_PREFIX + message );
+ break;
+ case LogSystem.INFO_ID:
+ logger.info( RuntimeConstants.INFO_PREFIX + message);
+ break;
+ case LogSystem.DEBUG_ID:
+ logger.debug( RuntimeConstants.DEBUG_PREFIX + message);
+ break;
+ case LogSystem.ERROR_ID:
+ logger.error(RuntimeConstants.ERROR_PREFIX + message);
+ break;
+ default:
+ logger.info( message);
+ break;
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/Log4JLogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/Log4JLogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/Log4JLogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/Log4JLogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,273 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.util.Enumeration;
+
+import org.apache.log4j.*;
+import org.apache.log4j.net.*;
+
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Implementation of a Log4J logger.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @version $Id: Log4JLogSystem.java,v 1.7.4.1 2004/03/03 23:22:56 geirm Exp $
+ *
+ * @deprecated As of v1.3. Use
+ * {@link SimpleLog4jLogSystem}
+ */
+public class Log4JLogSystem implements LogSystem
+{
+ private RuntimeServices rsvc = null;
+
+ /** log4java logging interface */
+ protected Category logger = null;
+
+ /** logging layout */
+ protected Layout layout = null;
+
+ /** the runtime.log property value */
+ private String logfile = "";
+
+ /**
+ * default CTOR. Initializes itself using the property RUNTIME_LOG
+ * from the Velocity properties
+ */
+ public Log4JLogSystem()
+ {
+ }
+
+ public void init( RuntimeServices rs )
+ {
+ rsvc = rs;
+
+ /*
+ * since this is a Velocity-provided logger, we will
+ * use the Runtime configuration
+ */
+ logfile = rsvc.getString( RuntimeConstants.RUNTIME_LOG );
+
+ /*
+ * now init. If we can't, panic!
+ */
+ try
+ {
+ internalInit();
+
+ logVelocityMessage( 0,
+ "Log4JLogSystem initialized using logfile " + logfile );
+ }
+ catch( Exception e )
+ {
+ System.out.println(
+ "PANIC : error configuring Log4JLogSystem : " + e );
+ }
+ }
+
+ /**
+ * initializes the log system using the logfile argument
+ *
+ * @param logFile file for log messages
+ */
+ private void internalInit()
+ throws Exception
+ {
+ logger = Category.getInstance("");
+ logger.setAdditivity(false);
+
+ /*
+ * Priority is set for DEBUG becouse this implementation checks
+ * log level.
+ */
+ logger.setPriority(Priority.DEBUG);
+
+ String pattern = rsvc.getString( RuntimeConstants.LOGSYSTEM_LOG4J_PATTERN );
+
+ if (pattern == null || pattern.length() == 0)
+ {
+ pattern = "%d - %m%n";
+ }
+
+ layout = new PatternLayout(pattern);
+
+ configureFile();
+ configureRemote();
+ configureSyslog();
+ configureEmail();
+ }
+
+ /**
+ * Configures the logging to a file.
+ */
+ private void configureFile()
+ throws Exception
+ {
+ int backupFiles =
+ rsvc.getInt(RuntimeConstants.LOGSYSTEM_LOG4J_FILE_BACKUPS, 1);
+ int fileSize =
+ rsvc.getInt(RuntimeConstants.LOGSYSTEM_LOG4J_FILE_SIZE, 100000);
+
+ Appender appender = new RollingFileAppender(layout,logfile,true);
+
+ ((RollingFileAppender)appender).setMaxBackupIndex(backupFiles);
+
+ /* finding file size */
+ if (fileSize > -1)
+ {
+ ((RollingFileAppender)appender).setMaximumFileSize(fileSize);
+ }
+ logger.addAppender(appender);
+ }
+
+ /**
+ * Configures the logging to a remote server
+ */
+ private void configureRemote()
+ throws Exception
+ {
+ String remoteHost =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_REMOTE_HOST);
+ int remotePort =
+ rsvc.getInt(RuntimeConstants.LOGSYSTEM_LOG4J_REMOTE_PORT, 1099);
+
+ if (remoteHost == null || remoteHost.trim().equals("") ||
+ remotePort <= 0)
+ {
+ return;
+ }
+
+ Appender appender=new SocketAppender(remoteHost,remotePort);
+
+ logger.addAppender(appender);
+ }
+
+ /**
+ * Configures the logging to syslogd
+ */
+ private void configureSyslog()
+ throws Exception
+ {
+ String syslogHost =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_SYSLOGD_HOST);
+ String syslogFacility =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_SYSLOGD_FACILITY);
+
+ if (syslogHost == null || syslogHost.trim().equals("") ||
+ syslogFacility == null )
+ {
+ return;
+ }
+
+ Appender appender = new SyslogAppender();
+
+ ((SyslogAppender)appender).setLayout(layout);
+ ((SyslogAppender)appender).setSyslogHost(syslogHost);
+ ((SyslogAppender)appender).setFacility(syslogFacility);
+
+ logger.addAppender(appender);
+ }
+
+ /**
+ * Configures the logging to email
+ */
+ private void configureEmail()
+ throws Exception
+ {
+ String smtpHost =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_EMAIL_SERVER);
+ String emailFrom =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_EMAIL_FROM);
+ String emailTo =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_EMAIL_TO);
+ String emailSubject =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_EMAIL_SUBJECT);
+ String bufferSize =
+ rsvc.getString(RuntimeConstants.LOGSYSTEM_LOG4J_EMAIL_BUFFER_SIZE);
+
+ if (smtpHost == null || smtpHost.trim().equals("")
+ || emailFrom == null || smtpHost.trim().equals("")
+ || emailTo == null || emailTo.trim().equals("")
+ || emailSubject == null || emailSubject.trim().equals("")
+ || bufferSize == null || bufferSize.trim().equals("") )
+ {
+ return;
+ }
+
+ SMTPAppender appender = new SMTPAppender();
+
+ appender.setSMTPHost( smtpHost );
+ appender.setFrom( emailFrom );
+ appender.setTo( emailTo );
+ appender.setSubject( emailSubject );
+
+ appender.setBufferSize( Integer.parseInt(bufferSize) );
+
+ appender.setLayout(layout);
+ appender.activateOptions();
+ logger.addAppender(appender);
+ }
+
+ /**
+ * logs messages
+ *
+ * @param level severity level
+ * @param message complete error message
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ switch (level)
+ {
+ case LogSystem.WARN_ID:
+ logger.warn( message );
+ break;
+ case LogSystem.INFO_ID:
+ logger.info(message);
+ break;
+ case LogSystem.DEBUG_ID:
+ logger.debug(message);
+ break;
+ case LogSystem.ERROR_ID:
+ logger.error(message);
+ break;
+ default:
+ logger.debug(message);
+ break;
+ }
+ }
+
+ /**
+ * Also do a shutdown if the object is destroy()'d.
+ */
+ protected void finalize() throws Throwable
+ {
+ shutdown();
+ }
+
+ /** Close all destinations*/
+ public void shutdown()
+ {
+ Enumeration appenders = logger.getAllAppenders();
+ while (appenders.hasMoreElements())
+ {
+ Appender appender = (Appender)appenders.nextElement();
+ appender.close();
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/Log4JLogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogManager.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogManager.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogManager.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogManager.java Tue May 29 15:35:01 2012
@@ -0,0 +1,186 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * <p>
+ * This class is responsible for instantiating the correct LoggingSystem
+ * </p>
+ *
+ * <p>
+ * The approach is :
+ * </p>
+ * <ul>
+ * <li>
+ * First try to see if the user is passing in a living object
+ * that is a LogSystem, allowing the app to give is living
+ * custom loggers.
+ * </li>
+ * <li>
+ * Next, run through the (possible) list of classes specified
+ * specified as loggers, taking the first one that appears to
+ * work. This is how we support finding either log4j or
+ * logkit, whichever is in the classpath, as both are
+ * listed as defaults.
+ * </li>
+ * <li>
+ * Finally, we turn to 'faith-based' logging, and hope that
+ * logkit is in the classpath, and try for an AvalonLogSystem
+ * as a final gasp. After that, there is nothing we can do.
+ * </li>
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: LogManager.java,v 1.10.4.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public class LogManager
+{
+ /**
+ * Creates a new logging system or returns an existing one
+ * specified by the application.
+ */
+ public static LogSystem createLogSystem( RuntimeServices rsvc )
+ throws Exception
+ {
+ /*
+ * if a logSystem was set as a configuation value, use that.
+ * This is any class the user specifies.
+ */
+
+ Object o = rsvc.getProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM );
+
+ if (o != null && o instanceof LogSystem)
+ {
+ ((LogSystem) o).init( rsvc );
+
+ return (LogSystem) o;
+ }
+
+ /*
+ * otherwise, see if a class was specified. You
+ * can put multiple classes, and we use the first one we find.
+ *
+ * Note that the default value of this property contains both the
+ * AvalonLogSystem and the SimpleLog4JLogSystem for convenience -
+ * so we use whichever we find.
+ */
+
+ List classes = null;
+ Object obj = rsvc.getProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS );
+
+ /*
+ * we might have a list, or not - so check
+ */
+
+ if ( obj instanceof List)
+ {
+ classes = (List) obj;
+ }
+ else if ( obj instanceof String)
+ {
+ classes = new ArrayList();
+ classes.add( obj );
+ }
+
+ /*
+ * now run through the list, trying each. It's ok to
+ * fail with a class not found, as we do this to also
+ * search out a default simple file logger
+ */
+
+ for( Iterator ii = classes.iterator(); ii.hasNext(); )
+ {
+ String claz = (String) ii.next();
+
+ if (claz != null && claz.length() > 0 )
+ {
+ rsvc.info("Trying to use logger class " + claz );
+
+ try
+ {
+ o = Class.forName( claz ).newInstance();
+
+ if ( o instanceof LogSystem )
+ {
+ ((LogSystem) o).init( rsvc );
+
+ rsvc.info("Using logger class " + claz );
+
+ return (LogSystem) o;
+ }
+ else
+ {
+ rsvc.error("The specifid logger class " + claz +
+ " isn't a valid LogSystem");
+ }
+ }
+ catch( NoClassDefFoundError ncdfe )
+ {
+ rsvc.debug("Couldn't find class " + claz
+ + " or necessary supporting classes in "
+ + "classpath. Exception : " + ncdfe);
+ }
+ }
+ }
+
+ /*
+ * if the above failed, then we are in deep doo-doo, as the
+ * above means that either the user specified a logging class
+ * that we can't find, there weren't the necessary
+ * dependencies in the classpath for it, or there were no
+ * dependencies for the default loggers, log4j and logkit.
+ * Since we really don't know,
+ * then take a wack at the AvalonLogSystem as a last resort.
+ */
+
+ LogSystem als = null;
+
+ try
+ {
+ als = new AvalonLogSystem();
+
+ als.init( rsvc );
+ }
+ catch( NoClassDefFoundError ncdfe )
+ {
+ String errstr = "PANIC : Velocity cannot find any of the"
+ + " specified or default logging systems in the classpath,"
+ + " or the classpath doesn't contain the necessary classes"
+ + " to support them."
+ + " Please consult the documentation regarding logging."
+ + " Exception : " + ncdfe;
+
+ System.out.println( errstr );
+ System.err.println( errstr );
+
+ throw ncdfe;
+ }
+
+ rsvc.info("Using AvalonLogSystem as logger of final resort.");
+
+ return als;
+ }
+}
+
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,61 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Base interface that Logging systems need to implement.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: LogSystem.java,v 1.7.10.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public interface LogSystem
+{
+ public final static boolean DEBUG_ON = true;
+
+ /**
+ * Prefix for debug messages.
+ */
+ public final static int DEBUG_ID = 0;
+
+ /**
+ * Prefix for info messages.
+ */
+ public final static int INFO_ID = 1;
+
+ /**
+ * Prefix for warning messages.
+ */
+ public final static int WARN_ID = 2;
+
+ /**
+ * Prefix for error messages.
+ */
+ public final static int ERROR_ID = 3;
+
+ /**
+ * init()
+ */
+ public void init( RuntimeServices rs ) throws Exception;
+
+ /**
+ * Send a log message from Velocity.
+ */
+ public void logVelocityMessage(int level, String message);
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/NullLogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/NullLogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/NullLogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/NullLogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,48 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Logger used in case of failure. Does nothing.
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: NullLogSystem.java,v 1.1.10.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public class NullLogSystem implements LogSystem
+{
+ public NullLogSystem()
+ {
+ }
+
+ public void init( RuntimeServices rs )
+ throws Exception
+ {
+ }
+
+ /**
+ * logs messages to the great Garbage Collector
+ * in the sky
+ *
+ * @param level severity level
+ * @param message complete error message
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/NullLogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/PrimordialLogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/PrimordialLogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/PrimordialLogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/PrimordialLogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,90 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.util.Vector;
+import java.util.Enumeration;
+
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Pre-init logger. I believe that this was suggested by
+ * Carsten Ziegeler <cz...@sundn.de> and
+ * Jeroen C. van Gelderen. If this isn't correct, let me
+ * know as this was a good idea...
+ *
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @version $Id: PrimordialLogSystem.java,v 1.4.4.1 2004/03/03 23:22:56 geirm Exp $
+ */
+public class PrimordialLogSystem implements LogSystem
+{
+ private Vector pendingMessages = new Vector();
+ private RuntimeServices rsvc = null;
+
+ /**
+ * default CTOR.
+ */
+ public PrimordialLogSystem()
+ {
+ }
+
+ public void init( RuntimeServices rs )
+ throws Exception
+ {
+ rsvc = rs;
+ }
+
+ /**
+ * logs messages. All we do is store them until
+ * 'later'.
+ *
+ * @param level severity level
+ * @param message complete error message
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ synchronized( this )
+ {
+ Object[] data = new Object[2];
+ data[0] = new Integer(level);
+ data[1] = message;
+ pendingMessages.addElement(data);
+ }
+ }
+
+ /**
+ * dumps the log messages this logger is holding into a new logger
+ */
+ public void dumpLogMessages( LogSystem newLogger )
+ {
+ synchronized( this )
+ {
+ if ( !pendingMessages.isEmpty())
+ {
+ /*
+ * iterate and log each individual message...
+ */
+
+ for( Enumeration e = pendingMessages.elements(); e.hasMoreElements(); )
+ {
+ Object[] data = (Object[]) e.nextElement();
+ newLogger.logVelocityMessage(((Integer) data[0]).intValue(), (String) data[1]);
+ }
+ }
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/PrimordialLogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/SimpleLog4JLogSystem.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/SimpleLog4JLogSystem.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/SimpleLog4JLogSystem.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/SimpleLog4JLogSystem.java Tue May 29 15:35:01 2012
@@ -0,0 +1,169 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.util.Enumeration;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.RollingFileAppender;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.Priority;
+import org.apache.log4j.Appender;
+
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
+
+/**
+ * Implementation of a simple log4j system that will either
+ * latch onto an existing category, or just do a simple
+ * rolling file log. Derived from Jon's 'complicated'
+ * version :)
+ *
+ * @author <a href="mailto:geirm@apache.org>Geir Magnusson Jr.</a>
+ * @version $Id: SimpleLog4JLogSystem.java,v 1.1.8.1 2004/03/03 23:22:57 geirm Exp $
+ */
+public class SimpleLog4JLogSystem implements LogSystem
+{
+ private RuntimeServices rsvc = null;
+
+ /** log4java logging interface */
+ protected Category logger = null;
+
+ public SimpleLog4JLogSystem()
+ {
+ }
+
+ public void init( RuntimeServices rs )
+ {
+ rsvc = rs;
+
+ /*
+ * first see if there is a category specified and just use that - it allows
+ * the application to make us use an existing logger
+ */
+
+ String categoryname = (String) rsvc.getProperty("runtime.log.logsystem.log4j.category");
+
+ if ( categoryname != null )
+ {
+ logger = Category.getInstance( categoryname );
+
+ logVelocityMessage( 0,
+ "SimpleLog4JLogSystem using category '" + categoryname + "'");
+
+ return;
+ }
+
+ /*
+ * if not, use the file...
+ */
+
+ String logfile = rsvc.getString( RuntimeConstants.RUNTIME_LOG );
+
+ /*
+ * now init. If we can't, panic!
+ */
+ try
+ {
+ internalInit( logfile );
+
+ logVelocityMessage( 0,
+ "SimpleLog4JLogSystem initialized using logfile '" + logfile + "'" );
+ }
+ catch( Exception e )
+ {
+ System.out.println(
+ "PANIC : error configuring SimpleLog4JLogSystem : " + e );
+ }
+ }
+
+ /**
+ * initializes the log system using the logfile argument
+ */
+ private void internalInit( String logfile )
+ throws Exception
+ {
+ /*
+ * do it by our classname to avoid conflicting with anything else
+ * that might be used...
+ */
+
+ logger = Category.getInstance(this.getClass().getName());
+ logger.setAdditivity(false);
+
+ /*
+ * Priority is set for DEBUG becouse this implementation checks
+ * log level.
+ */
+ logger.setPriority(Priority.DEBUG);
+
+ RollingFileAppender appender = new RollingFileAppender( new PatternLayout( "%d - %m%n"), logfile, true);
+
+ appender.setMaxBackupIndex( 1 );
+
+ appender.setMaximumFileSize( 100000 );
+
+ logger.addAppender(appender);
+ }
+
+ /**
+ * logs messages
+ *
+ * @param level severity level
+ * @param message complete error message
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ switch (level)
+ {
+ case LogSystem.WARN_ID:
+ logger.warn( message );
+ break;
+ case LogSystem.INFO_ID:
+ logger.info(message);
+ break;
+ case LogSystem.DEBUG_ID:
+ logger.debug(message);
+ break;
+ case LogSystem.ERROR_ID:
+ logger.error(message);
+ break;
+ default:
+ logger.debug(message);
+ break;
+ }
+ }
+
+ /**
+ * Also do a shutdown if the object is destroy()'d.
+ */
+ protected void finalize() throws Throwable
+ {
+ shutdown();
+ }
+
+ /** Close all destinations*/
+ public void shutdown()
+ {
+ Enumeration appenders = logger.getAllAppenders();
+ while (appenders.hasMoreElements())
+ {
+ Appender appender = (Appender)appenders.nextElement();
+ appender.close();
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/SimpleLog4JLogSystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/VelocityFormatter.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/VelocityFormatter.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/VelocityFormatter.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/VelocityFormatter.java Tue May 29 15:35:01 2012
@@ -0,0 +1,40 @@
+package org.apache.velocity.runtime.log;
+
+/*
+ * Copyright 2001,2004 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.
+ */
+
+import java.util.Date;
+import org.apache.log.format.PatternFormatter;
+
+public class VelocityFormatter extends PatternFormatter
+{
+ public VelocityFormatter( String format )
+ {
+ super( format );
+ }
+
+ /**
+ * Utility method to format time.
+ *
+ * @param time the time
+ * @param format ancilliary format parameter - allowed to be null
+ * @return the formatted string
+ */
+ protected String getTime( final long time, final String format )
+ {
+ return new Date().toString();
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/log/VelocityFormatter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/BUILD_README.txt
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/BUILD_README.txt?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/BUILD_README.txt (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/BUILD_README.txt Tue May 29 15:35:01 2012
@@ -0,0 +1,24 @@
+Quick Note:
+-----------
+The parser is a 'special' piece of the build tree - currently it doesn't
+behave as everything else due to javacc and the package layout.
+
+1) The build script in this directory will take care of the simple case
+when the parser is modified via Parser.jjt. It runs 'jjtree' on Parser.jjt
+to make the AST nodes (which are then deleted later - more on this in a bit)
+and creates Parser.jj for javacc.
+
+2) Javacc is then run on Parser.jj to make Parser.java, which will be compiled
+like any other piece of java source via build-velocity.sh (or whatever follows.)
+
+3) In the event that something 'serious' changes, such as an AST node is created
+or altered, it must be *manually* moved to the node subdirectory, and have it's
+package declaration fixed. This should be an extremely rare event at this point
+and will change with javacc 2.0.
+
+4) When committing changes, to aid readability to those watching the cvs commit
+messages, please commit Parser.jjt separately from the .jj and .java
+files generated from .jjt.
+
+-gmj
+
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/BUILD_README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/CharStream.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/CharStream.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/CharStream.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/CharStream.java Tue May 29 15:35:01 2012
@@ -0,0 +1,110 @@
+/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 2.1 */
+package org.apache.velocity.runtime.parser;
+
+/**
+ * This interface describes a character stream that maintains line and
+ * column number positions of the characters. It also has the capability
+ * to backup the stream to some extent. An implementation of this
+ * interface is used in the TokenManager implementation generated by
+ * JavaCCParser.
+ *
+ * All the methods except backup can be implemented in any fashion. backup
+ * needs to be implemented correctly for the correct operation of the lexer.
+ * Rest of the methods are all used to get information like line number,
+ * column number and the String that constitutes a token and are not used
+ * by the lexer. Hence their implementation won't affect the generated lexer's
+ * operation.
+ */
+
+public interface CharStream {
+
+ /**
+ * Returns the next character from the selected input. The method
+ * of selecting the input is the responsibility of the class
+ * implementing this interface. Can throw any java.io.IOException.
+ */
+ char readChar() throws java.io.IOException;
+
+ /**
+ * Returns the column position of the character last read.
+ * @deprecated
+ * @see #getEndColumn
+ */
+ int getColumn();
+
+ /**
+ * Returns the line number of the character last read.
+ * @deprecated
+ * @see #getEndLine
+ */
+ int getLine();
+
+ /**
+ * Returns the column number of the last character for current token (being
+ * matched after the last call to BeginTOken).
+ */
+ int getEndColumn();
+
+ /**
+ * Returns the line number of the last character for current token (being
+ * matched after the last call to BeginTOken).
+ */
+ int getEndLine();
+
+ /**
+ * Returns the column number of the first character for current token (being
+ * matched after the last call to BeginTOken).
+ */
+ int getBeginColumn();
+
+ /**
+ * Returns the line number of the first character for current token (being
+ * matched after the last call to BeginTOken).
+ */
+ int getBeginLine();
+
+ /**
+ * Backs up the input stream by amount steps. Lexer calls this method if it
+ * had already read some characters, but could not use them to match a
+ * (longer) token. So, they will be used again as the prefix of the next
+ * token and it is the implemetation's responsibility to do this right.
+ */
+ void backup(int amount);
+
+ /**
+ * Returns the next character that marks the beginning of the next token.
+ * All characters must remain in the buffer between two successive calls
+ * to this method to implement backup correctly.
+ */
+ char BeginToken() throws java.io.IOException;
+
+ /**
+ * Returns a string made up of characters from the marked token beginning
+ * to the current buffer position. Implementations have the choice of returning
+ * anything that they want to. For example, for efficiency, one might decide
+ * to just return null, which is a valid implementation.
+ */
+ String GetImage();
+
+ /**
+ * Returns an array of characters that make up the suffix of length 'len' for
+ * the currently matched token. This is used to build up the matched string
+ * for use in actions in the case of MORE. A simple and inefficient
+ * implementation of this is as follows :
+ *
+ * {
+ * String t = GetImage();
+ * return t.substring(t.length() - len, t.length()).toCharArray();
+ * }
+ */
+ char[] GetSuffix(int len);
+
+ /**
+ * The lexer calls this function to indicate that it is done with the stream
+ * and hence implementations can free any resources held by this class.
+ * Again, the body of this function can be just empty and it will not
+ * affect the lexer's operation.
+ */
+ void Done();
+
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/CharStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/JJTParserState.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/JJTParserState.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/JJTParserState.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/JJTParserState.java Tue May 29 15:35:01 2012
@@ -0,0 +1,125 @@
+/* Generated By:JJTree: Do not edit this line. JJTParserState.java */
+
+package org.apache.velocity.runtime.parser;
+
+import org.apache.velocity.runtime.parser.node.*;
+
+class JJTParserState {
+ private java.util.Stack nodes;
+ private java.util.Stack marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTParserState() {
+ nodes = new java.util.Stack();
+ marks = new java.util.Stack();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+ automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+ this after a successful parse. */
+ Node rootNode() {
+ return (Node)nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = ((Integer)marks.pop()).intValue();
+ }
+ return (Node)nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return (Node)nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = ((Integer)marks.pop()).intValue();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(new Integer(mk));
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+ children. That number of nodes are popped from the stack and
+ made the children of the definite node. Then the definite node
+ is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = ((Integer)marks.pop()).intValue();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+ the nodes that have been pushed since the node was opened are
+ made children of the the conditional node, which is then pushed
+ on to the stack. If the condition is false the node is not
+ constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = ((Integer)marks.pop()).intValue();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = ((Integer)marks.pop()).intValue();
+ node_created = false;
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/JJTParserState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java Tue May 29 15:35:01 2012
@@ -0,0 +1,192 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 2.1 */
+package org.apache.velocity.runtime.parser;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ String expected = "";
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected += "...";
+ }
+ expected += eol + " ";
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected;
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParseException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParserConstants.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParserConstants.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParserConstants.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParserConstants.java Tue May 29 15:35:01 2012
@@ -0,0 +1,140 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. ParserConstants.java */
+package org.apache.velocity.runtime.parser;
+
+public interface ParserConstants {
+
+ int EOF = 0;
+ int LBRACKET = 1;
+ int RBRACKET = 2;
+ int COMMA = 3;
+ int DOUBLEDOT = 4;
+ int LPAREN = 5;
+ int RPAREN = 6;
+ int REFMOD2_RPAREN = 7;
+ int ESCAPE_DIRECTIVE = 8;
+ int SET_DIRECTIVE = 9;
+ int DOLLAR = 10;
+ int DOLLARBANG = 11;
+ int HASH = 15;
+ int DOUBLE_ESCAPE = 16;
+ int ESCAPE = 17;
+ int TEXT = 18;
+ int SINGLE_LINE_COMMENT = 19;
+ int FORMAL_COMMENT = 20;
+ int MULTI_LINE_COMMENT = 21;
+ int WHITESPACE = 23;
+ int STRING_LITERAL = 24;
+ int TRUE = 25;
+ int FALSE = 26;
+ int NEWLINE = 27;
+ int MINUS = 28;
+ int PLUS = 29;
+ int MULTIPLY = 30;
+ int DIVIDE = 31;
+ int MODULUS = 32;
+ int LOGICAL_AND = 33;
+ int LOGICAL_OR = 34;
+ int LOGICAL_LT = 35;
+ int LOGICAL_LE = 36;
+ int LOGICAL_GT = 37;
+ int LOGICAL_GE = 38;
+ int LOGICAL_EQUALS = 39;
+ int LOGICAL_NOT_EQUALS = 40;
+ int LOGICAL_NOT = 41;
+ int EQUALS = 42;
+ int END = 43;
+ int IF_DIRECTIVE = 44;
+ int ELSEIF_DIRECTIVE = 45;
+ int ELSE_DIRECTIVE = 46;
+ int STOP_DIRECTIVE = 47;
+ int DIGIT = 48;
+ int NUMBER_LITERAL = 49;
+ int LETTER = 50;
+ int DIRECTIVE_CHAR = 51;
+ int WORD = 52;
+ int ALPHA_CHAR = 53;
+ int ALPHANUM_CHAR = 54;
+ int IDENTIFIER_CHAR = 55;
+ int IDENTIFIER = 56;
+ int DOT = 57;
+ int LCURLY = 58;
+ int RCURLY = 59;
+ int REFERENCE_TERMINATOR = 60;
+ int DIRECTIVE_TERMINATOR = 61;
+
+ int DIRECTIVE = 0;
+ int REFMOD2 = 1;
+ int REFMODIFIER = 2;
+ int DEFAULT = 3;
+ int PRE_DIRECTIVE = 4;
+ int REFERENCE = 5;
+ int IN_MULTI_LINE_COMMENT = 6;
+ int IN_FORMAL_COMMENT = 7;
+ int IN_SINGLE_LINE_COMMENT = 8;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\"[\"",
+ "\"]\"",
+ "\",\"",
+ "\"..\"",
+ "\"(\"",
+ "<RPAREN>",
+ "\")\"",
+ "<ESCAPE_DIRECTIVE>",
+ "<SET_DIRECTIVE>",
+ "<DOLLAR>",
+ "<DOLLARBANG>",
+ "\"##\"",
+ "<token of kind 13>",
+ "\"#*\"",
+ "\"#\"",
+ "\"\\\\\\\\\"",
+ "\"\\\\\"",
+ "<TEXT>",
+ "<SINGLE_LINE_COMMENT>",
+ "\"*#\"",
+ "\"*#\"",
+ "<token of kind 22>",
+ "<WHITESPACE>",
+ "<STRING_LITERAL>",
+ "\"true\"",
+ "\"false\"",
+ "<NEWLINE>",
+ "\"-\"",
+ "\"+\"",
+ "\"*\"",
+ "\"/\"",
+ "\"%\"",
+ "\"&&\"",
+ "\"||\"",
+ "\"<\"",
+ "\"<=\"",
+ "\">\"",
+ "\">=\"",
+ "\"==\"",
+ "\"!=\"",
+ "\"!\"",
+ "\"=\"",
+ "<END>",
+ "\"if\"",
+ "\"elseif\"",
+ "<ELSE_DIRECTIVE>",
+ "\"stop\"",
+ "<DIGIT>",
+ "<NUMBER_LITERAL>",
+ "<LETTER>",
+ "<DIRECTIVE_CHAR>",
+ "<WORD>",
+ "<ALPHA_CHAR>",
+ "<ALPHANUM_CHAR>",
+ "<IDENTIFIER_CHAR>",
+ "<IDENTIFIER>",
+ "<DOT>",
+ "\"{\"",
+ "\"}\"",
+ "<REFERENCE_TERMINATOR>",
+ "<DIRECTIVE_TERMINATOR>",
+ };
+
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/runtime/parser/ParserConstants.java
------------------------------------------------------------------------------
svn:eol-style = native