亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? eventexample.java

?? velocity 的腳本語言的全部代碼集合
?? JAVA
字號:
/*
 * 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.StringWriter;
import java.util.Properties;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.VelocityContext;

import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.MethodInvocationException;

import org.apache.velocity.runtime.log.LogSystem;
import org.apache.velocity.runtime.RuntimeServices;

import org.apache.velocity.app.event.EventCartridge;
import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
import org.apache.velocity.app.event.MethodExceptionEventHandler;
import org.apache.velocity.app.event.NullSetEventHandler;

import org.apache.velocity.context.Context;

/**
 *   This class is a simple demonstration of how the event handling
 *   features of the Velocity Servlet Engine are used.  It uses a
 *   custom logger as well to check the log message stream
 *   when testing the NullSetEventHandler
 *
 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
 * @version $Id: EventExample.java,v 1.3.10.1 2004/03/04 00:18:29 geirm Exp $
 */

public class EventExample implements ReferenceInsertionEventHandler, 
                                     NullSetEventHandler, MethodExceptionEventHandler,
                                     LogSystem
{

    private boolean logOutput = false;
    private boolean exceptionSwitch = false;

    public static void main( String args[] )
    {
        EventExample ee = new EventExample();
    }

    public EventExample()
    {
        try
        {
            /*
             *  this class implements the LogSystem interface, so we
             *  can use it as a logger for Velocity
             */
            
            Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
            Velocity.init();
        }
        catch(Exception e)
        {
            System.out.println("Problem initializing Velocity : " + e );
            return;
        }

        /* 
         *  lets make a Context and add some data
         */

        VelocityContext context = new VelocityContext();

        context.put("name", "Velocity");

        /*
         *  Now make an event cartridge, register all the 
         *  event handlers (at once) and attach it to the
         *  Context
         */

        EventCartridge ec = new EventCartridge();
        ec.addEventHandler(this);
        ec.attachToContext( context );
  
        try
        {
            /* 
             *  lets test each type of event handler individually
             *  using 'dynamic' templates
             *
             *  First, the reference insertion handler
             */

            System.out.println("");
            System.out.println("Velocity Event Handling Demo");
            System.out.println("============================");
            System.out.println("");

            String s = "The word 'Velocity' should be bounded by emoticons :  $name.";
            
            StringWriter w = new StringWriter();
            Velocity.evaluate( context, w, "mystring", s );

            System.out.println("Reference Insertion Test : ");
            System.out.println("   " +  w.toString());
            System.out.println("");

            /*
             *  using the same handler, we can deal with 
             *  null references as well
             */

            s = "There is no reference $floobie, $nullvalue or anything in the brackets : >$!silentnull<";

            w = new StringWriter();
            Velocity.evaluate( context, w, "mystring", s );

            System.out.println("Reference Insertion Test with null references : ");
            System.out.println("   " + w.toString());
            System.out.println("");

            /*
             *  now lets test setting a null value - this test
             *  should result in *no* log output.
             *  Turn on the logger output.
             */

            logOutput = true;

            s = "#set($settest = $NotAReference)";
            w = new StringWriter();

            System.out.println("NullSetEventHandler test : " );
            System.out.print("      There should be nothing between >");
            Velocity.evaluate( context, w, "mystring", s );
            System.out.println("< the brackets.");
            System.out.println("");

            /*
             *  now lets test setting a null value - this test
             *  should result in log output.
             */

            s = "#set($logthis = $NotAReference)";
            w = new StringWriter();

            System.out.println("NullSetEventHandler test : " );
            System.out.print("     There should be a log message between >");
            Velocity.evaluate( context, w, "mystring", s );
            System.out.println("< the brackets.");
            System.out.println("");

            logOutput = false;

            /*
             *  finally, we test a method exception event - we do this 
             *  by putting this class in the context, and calling 
             *  a method that does nothing but throw an exception.
             *  we use a little switch to turn the event handling
             *  on and off
             *
             *  Note also how the reference insertion process
             *  happens as well
             */
            
            exceptionSwitch = true;

            context.put("this", this );

            s = " $this.throwException()";
            w = new StringWriter();

            System.out.println("MethodExceptionEventHandler test : " );
            System.out.print("    This exception will be controlled and converted into a string : ");
            Velocity.evaluate( context, w, "mystring", s );
            System.out.println("   " + w.toString());
            System.out.println("");

            /*
             *  now, we turn the switch off, and we can see that the 
             *  exception will propgate all the way up here, and 
             *  wil be caught by the catch() block below
             */

            exceptionSwitch = false;

            s = " $this.throwException()";
            w = new StringWriter();

            System.out.println("MethodExceptionEventHandler test : " );
            System.out.println("    This exception will NOT be controlled. "
                             + " The next thing you should see is the catch() output ");
            Velocity.evaluate( context, w, "mystring", s );
            System.out.println("If you see this, it didn't work!");

        }
        catch( ParseErrorException pee )
        {
            /*
             * thrown if something is wrong with the
             * syntax of our template string
             */
            System.out.println("ParseErrorException : " + pee );
        }
        catch( MethodInvocationException mee )
        {
            /*
             *  thrown if a method of a reference
             *  called by the template
             *  throws an exception. That won't happen here
             *  as we aren't calling any methods in this
             *  example, but we have to catch them anyway
             */
            System.out.println("   Catch Block : MethodInvocationException : " + mee );
        }
        catch( Exception e )
        {
            System.out.println("Exception : " + e );
        }
    }

    /**
     *  silly method to throw an exception to demonstrate
     *  the method invocation exception event handling
     */
    public void throwException()
        throws Exception
    {
        throw new Exception("Hello from throwException()");
    }

    /**
     *  Event handler for when a reference is inserted into the output stream.
     */
    public Object referenceInsert( String reference, Object value  )
    {
        /*
         *  if we have a value
         *  lets decorate the reference with emoticons
         */

        String s = null;

        if( value != null )
        {
            s = " ;) " + value.toString() + " :-)";
        }
        else
        {
            /*
             * we only want to deal with $floobie - anything
             *  else we let go
             */
            if ( reference.equals("floobie") )
            {
                s = "<no floobie value>";
            }
        }
        return s;
    }

    /**
     *  Event handler for when the right hand side of
     *  a #set() directive is null, which results in 
     *  a log message.  This method gives the application
     *  a chance to 'vote' on msg generation
     */
    public boolean shouldLogOnNullSet( String lhs, String rhs )
    {
        if (lhs.equals("$settest"))
            return false;
        
        return true;
    }

    public Object methodException( Class claz, String method, Exception e )
         throws Exception
    {
        /*
         *  only do processing if the switch is on
         */

        if( exceptionSwitch && method.equals("throwException"))
        {
            return "Hello from the methodException() event handler method.";
        }

        throw e;
    } 

	/**
	 *  Required init method for LogSystem
	 *  to get access to RuntimeServices
	 */ 
	 public void init( RuntimeServices rs )
	 {
	 	return;
	 }

    /**
     *  This is the key method needed to implement a logging interface
     *  for Velocity.
     */ 
    public void logVelocityMessage(int level, String message)
    {
        if (logOutput)
        {
            System.out.print("Velocity Log : level : " + level + " msg : " + message);
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线短视频| 中文在线资源观看网站视频免费不卡 | 色噜噜久久综合| 日韩欧美视频在线 | 精品成人一区二区三区| 一区二区三区久久| 国产不卡视频在线观看| 日韩视频一区二区在线观看| 国产精品电影一区二区三区| 精品一区二区三区在线观看国产| 色综合中文字幕| 国产精品进线69影院| 国产美女在线观看一区| 欧美一区二区精美| 午夜久久久久久久久久一区二区| 91亚洲精品久久久蜜桃网站| 国产女同互慰高潮91漫画| 九九久久精品视频| 日韩一二三四区| 日日摸夜夜添夜夜添亚洲女人| 成人av网站在线观看免费| 久久久一区二区| 国产综合色视频| 日韩精品一区二区三区视频在线观看| 亚洲第一狼人社区| 欧美色国产精品| 亚洲综合丁香婷婷六月香| 99久久99久久综合| 亚洲色大成网站www久久九九| 国产激情一区二区三区四区 | 色中色一区二区| 亚洲欧美一区二区视频| 成人av免费在线| 国产精品久久国产精麻豆99网站| 国产伦精品一区二区三区免费| 精品国产一区二区三区久久影院| 久久国产视频网| 精品国产乱码久久久久久久| 狠狠色综合色综合网络| 精品国产人成亚洲区| 国内精品国产成人| 中文字幕二三区不卡| 九九久久精品视频| 久久精品人人做人人爽人人| 国产.欧美.日韩| 国产精品第一页第二页第三页| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 日韩精品在线网站| 激情国产一区二区 | 亚洲综合久久av| 欧美日韩国产片| 久久精品国产亚洲高清剧情介绍 | 国产精品毛片a∨一区二区三区| 成人免费视频网站在线观看| 自拍av一区二区三区| 在线看日本不卡| 男女激情视频一区| 欧美激情一区二区三区蜜桃视频| 99视频一区二区| 丝袜诱惑亚洲看片| 久久综合色鬼综合色| 91婷婷韩国欧美一区二区| 午夜精品久久久久久不卡8050| 精品久久久久香蕉网| 成人毛片在线观看| 天天综合日日夜夜精品| 久久久久青草大香线综合精品| 99久久夜色精品国产网站| 五月天中文字幕一区二区| 国产亚洲美州欧州综合国| 色综合天天在线| 九九九久久久精品| 一区二区成人在线观看| 26uuu精品一区二区在线观看| 色综合视频一区二区三区高清| 青青草成人在线观看| 亚洲人成电影网站色mp4| 日韩天堂在线观看| 色哟哟一区二区| 国内精品伊人久久久久影院对白| 一区二区在线免费观看| 久久久久久久国产精品影院| 欧美日韩在线播放| 成人福利视频在线| 久久成人综合网| 日日摸夜夜添夜夜添亚洲女人| 中文字幕亚洲精品在线观看| 日韩久久久久久| 欧美日韩国产综合一区二区| 成人丝袜18视频在线观看| 美女看a上一区| 亚洲综合激情网| 中文字幕综合网| 欧美极品aⅴ影院| 精品国产污污免费网站入口 | 久久女同精品一区二区| 欧美午夜片在线看| 成人av电影免费观看| 捆绑紧缚一区二区三区视频 | 久99久精品视频免费观看| 亚洲福利视频三区| 亚洲欧美视频在线观看| 中文字幕av一区二区三区免费看| 日韩美女天天操| 欧美一区二区播放| 欧美日韩免费一区二区三区| 91首页免费视频| 91色九色蝌蚪| 91最新地址在线播放| 成人99免费视频| 成人精品视频一区二区三区尤物| 国产在线一区观看| 国产一区二区三区免费观看| 日本不卡中文字幕| 日韩成人伦理电影在线观看| 午夜精品久久久久| 日韩国产一二三区| 美女在线视频一区| 久久激情五月婷婷| 国模少妇一区二区三区| 国产麻豆精品视频| 成人黄色av网站在线| 东方aⅴ免费观看久久av| 国产福利精品导航| 成人午夜激情影院| 色综合一个色综合亚洲| 91成人在线精品| 91超碰这里只有精品国产| 欧美精品一二三四| 日韩精品一区在线观看| 精品国产伦一区二区三区免费| 国产午夜亚洲精品午夜鲁丝片| 欧美激情一二三区| 一区二区三区四区高清精品免费观看 | 4hu四虎永久在线影院成人| 欧美一区二区三区四区在线观看| 精品久久一区二区| 国产欧美一区二区精品秋霞影院| 国产精品久久久久久久第一福利 | 色婷婷综合五月| 欧美一区二区三区在| 久久看人人爽人人| 国产精品美女久久久久久久网站| 亚洲欧美日韩久久| 日本女优在线视频一区二区| 精品夜夜嗨av一区二区三区| 成人高清免费观看| 欧美一区二区三区男人的天堂| 2017欧美狠狠色| 一区二区三区在线免费| 日韩二区三区在线观看| 国产乱国产乱300精品| 色综合天天综合网天天看片| 日韩精品中文字幕一区| 亚洲欧美日韩在线| 久久99久久99| 欧美在线观看视频在线| 精品剧情在线观看| 一个色在线综合| 国产成人精品一区二| 欧美三级资源在线| 国产精品久久免费看| 人人狠狠综合久久亚洲| 91免费看视频| 26uuu亚洲| 日本免费新一区视频| 99视频精品在线| 久久这里只有精品首页| 亚洲超碰精品一区二区| 大尺度一区二区| 日韩欧美美女一区二区三区| 亚洲激情校园春色| 成人视屏免费看| 精品伦理精品一区| 偷窥国产亚洲免费视频| 色偷偷成人一区二区三区91| 国产人成亚洲第一网站在线播放| 调教+趴+乳夹+国产+精品| 一本色道久久综合狠狠躁的推荐| 久久丝袜美腿综合| 久久精品噜噜噜成人av农村| 欧美日韩欧美一区二区| 亚洲欧美日韩一区二区 | 国产精品成人一区二区艾草| 久久99久久精品| 欧美一二三区精品| 日日噜噜夜夜狠狠视频欧美人| 92国产精品观看| 国产精品三级视频| 国产精华液一区二区三区| 日韩免费一区二区三区在线播放| 日韩精品一级中文字幕精品视频免费观看 | 国产欧美日本一区视频| 久久不见久久见免费视频7| 666欧美在线视频| 一个色妞综合视频在线观看| 91豆麻精品91久久久久久| 一级特黄大欧美久久久| 欧美主播一区二区三区美女| 亚洲一线二线三线久久久|