velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sérgio 7 Reais <convi...@newenterprise.com.br>
Subject Re: svn commit: r544331 [2/2] - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: struts/ view/ view/i18n/ view/tools/
Date Fri, 08 Jun 2007 03:56:52 GMT

  ----- Original Message ----- 
  From: Sérgio 7 Reais 
  To: commits@velocity.apache.org 
  Sent: Wednesday, June 06, 2007 11:29 PM
  Subject: Re: svn commit: r544331 [2/2] - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: struts/ view/ view/i18n/ view/tools/



    ----- Original Message ----- 
    From: Sérgio 7 Reais 
    To: dev@velocity.apache.org 
    Sent: Tuesday, June 05, 2007 1:45 AM
    Subject: Re: svn commit: r544331 [2/2] - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: struts/ view/ view/i18n/ view/tools/



      ----- Original Message ----- 
      From: nbubna@apache.org 
      To: commits@velocity.apache.org 
      Sent: Monday, June 04, 2007 9:24 PM
      Subject: svn commit: r544331 [2/2] - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: struts/ view/ view/i18n/ view/tools/


      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/BrowserSnifferTool.java Mon Jun  4 17:24:29 2007
      @@ -19,74 +19,15 @@
        * under the License.
        */
       
      -import java.util.regex.Matcher;
      -import java.util.regex.Pattern;
      -import java.util.regex.PatternSyntaxException;
      -import javax.servlet.http.HttpServletRequest;
      -import org.apache.velocity.tools.config.DefaultKey;
       import org.apache.velocity.tools.view.ViewContext;
      -import org.apache.velocity.tools.config.InvalidScope;
       
       /**
      - *  <p>browser-sniffing tool (session or request scope requested, session scope advised).</p>
      - *  <p></p>
      - * <p><b>Usage:</b></p>
      - * <p>BrowserSniffer defines properties that are used to test the client browser, operating system, device...
      - * Apart from properties related to versioning, all properties are booleans.</p>
      - * <p>The following properties are available:</p>
      - * <ul>
      - * <li><i>Versioning:</i>version majorVersion minorVersion geckoVersion</li>
      - * <li><i>Browser:</i>mosaic netscape nav2 nav3 nav4 nav4up nav45 nav45up nav6 nav6up navgold firefox safari
      - * ie ie3 ie4 ie4up ie5 ie5up ie55 ie55up ie6 opera opera3 opera4 opera5 opera6 opera7 lynx links
      - * aol aol3 aol4 aol5 aol6 neoplanet neoplanet2 amaya icab avantgo emacs mozilla gecko webtv staroffice
      - * lotusnotes konqueror</li>
      - * <li><i>Operating systems:</i>win16 win3x win31 win95 win98 winnt windows win32 win2k winxp winme dotnet
      - * mac macosx mac68k macppc os2 unix sun sun4 sun5 suni86 irix irix5 irix6 hpux hpux9 hpux10 aix aix1 aix2 aix3 aix4
      - * linux sco unixware mpras reliant dec sinix freebsd bsd vms x11 amiga</li>
      - * <li><i>Devices:</i>palm audrey iopener wap blackberry</li>
      - * <li><i>Features:</i>javascript css css1 css2 dom0 dom1 dom2</li>
      - * <li><i>Special:</i>robot (true if the page is requested by a robot, i.e. when one of the following properties is true:
      - * wget getright yahoo altavista lycos infoseek lwp webcrawler linkexchange slurp google java)
      - * </ul>
      - *
      - * Thanks to Lee Semel (lee@semel.net), the author of the HTTP::BrowserDetect Perl module.
      - * See also:
      - * * http://www.zytrax.com/tech/web/browser_ids.htm
      - * * http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
      - * * http://en.wikipedia.org/wiki/User_agent
      - *
      - * @author <a href="mailto:claude@renegat.net">Claude Brisson</a>
      - * @since VelocityTools 1.2
      - * @version $Revision$ $Date$
      + * Use {@link org.apache.velocity.view.BrowserTool}
        */
      -@DefaultKey("browser")
      -@InvalidScope("application")
      -public class BrowserSnifferTool implements java.io.Serializable
      +@Deprecated
      +public class BrowserSnifferTool extends
      +    org.apache.velocity.tools.view.BrowserTool
       {
      -    private static final long serialVersionUID = 1734529350532353339L;
      -
      -    private String userAgent = null;
      -    private String version = null;
      -    private int majorVersion = -1;
      -    private int minorVersion = -1;
      -    private String geckoVersion = null;
      -    private int geckoMajorVersion = -1;
      -    private int geckoMinorVersion = -1;
      -
      -    /**
      -     * Initializes this tool by setting the current {@link HttpServletRequest}.
      -     * This is required for this tool to operate and will throw a
      -     * NullPointerException if this is not set or is set to {@code null}.
      -     */
      -    public void setRequest(HttpServletRequest request)
      -    {
      -        if (request == null)
      -        {
      -            throw new NullPointerException("request should not be null");
      -        }
      -        userAgent = request.getHeader("User-Agent").toLowerCase();
      -    }
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -95,988 +36,4 @@
                   setRequest(((ViewContext)obj).getRequest());
               }
           }
      -
      -    /* Generic getter for unknown tests
      -     */
      -    public boolean get(String key)
      -    {
      -        return test(key);
      -    }
      -
      -    /* Versioning */
      -
      -    public String getVersion()
      -    {
      -        parseVersion();
      -        return version;
      -    }
      -
      -    public int getMajorVersion()
      -    {
      -        parseVersion();
      -        return majorVersion;
      -    }
      -
      -    public int getMinorVersion()
      -    {
      -        parseVersion();
      -        return minorVersion;
      -    }
      -
      -    public String getGeckoVersion()
      -    {
      -        parseVersion();
      -        return geckoVersion;
      -    }
      -
      -    public int getGeckoMajorVersion()
      -    {
      -        parseVersion();
      -        return geckoMajorVersion;
      -    }
      -
      -    public int getGeckoMinorVersion()
      -    {
      -        parseVersion();
      -        return geckoMinorVersion;
      -    }
      -
      -    /* Browsers */
      -
      -    public boolean getGecko()
      -    {
      -        return test("gecko");
      -    }
      -
      -    public boolean getFirefox()
      -    {
      -        return test("firefox") || test("firebird") || test("phoenix") || test("iceweasel");
      -    }
      -
      -    public boolean getIceweasel()
      -    {
      -        return test("iceweasel");
      -    }
      -
      -    public boolean getEpiphany()
      -    {
      -        return test("epiphany");
      -    }
      -
      -    public boolean getSafari()
      -    {
      -        return test("safari") || test("applewebkit");
      -    }
      -
      -    public boolean getNetscape()
      -    {
      -        return !getFirefox() && !getSafari() && test("mozilla") &&
      -               !test("spoofer") && !test("compatible") && !test("opera") &&
      -               !test("webtv") && !test("hotjava");
      -    }
      -
      -    public boolean getNav2()
      -    {
      -        return getNetscape() && getMajorVersion() == 2;
      -    }
      -
      -    public boolean getNav3()
      -    {
      -        return getNetscape() && getMajorVersion() == 3;
      -    }
      -
      -    public boolean getNav4()
      -    {
      -        return getNetscape() && getMajorVersion() == 4;
      -    }
      -
      -    public boolean getNav4up()
      -    {
      -        return getNetscape() && getMajorVersion() >= 4;
      -    }
      -
      -    public boolean getNav45()
      -    {
      -        return getNetscape() && getMajorVersion() == 4 &&
      -               getMinorVersion() == 5;
      -    }
      -
      -    public boolean getNav45up()
      -    {
      -        return getNetscape() && getMajorVersion() >= 5 ||
      -               getNav4() && getMinorVersion() >= 5;
      -    }
      -
      -    public boolean getNavgold()
      -    {
      -        return test("gold");
      -    }
      -
      -    public boolean getNav6()
      -    {
      -        return getNetscape() && getMajorVersion() == 5; /* sic */
      -    }
      -
      -    public boolean getNav6up()
      -    {
      -        return getNetscape() && getMajorVersion() >= 5;
      -    }
      -
      -    public boolean getMozilla()
      -    {
      -        return getNetscape() && getGecko();
      -    }
      -
      -    public boolean getIe()
      -    {
      -        return test("msie") && !test("opera") ||
      -               test("microsoft internet explorer");
      -    }
      -
      -    public boolean getIe3()
      -    {
      -        return getIe() && getMajorVersion() < 4;
      -    }
      -
      -    public boolean getIe4()
      -    {
      -        return getIe() && getMajorVersion() == 4;
      -    }
      -
      -    public boolean getIe4up()
      -    {
      -        return getIe() && getMajorVersion() >= 4;
      -    }
      -
      -    public boolean getIe5()
      -    {
      -        return getIe() && getMajorVersion() == 5;
      -    }
      -
      -    public boolean getIe5up()
      -    {
      -        return getIe() && getMajorVersion() >= 5;
      -    }
      -
      -    public boolean getIe55()
      -    {
      -        return getIe() && getMajorVersion() == 5 && getMinorVersion() >= 5;
      -    }
      -
      -    public boolean getIe55up()
      -    {
      -        return (getIe5() && getMinorVersion() >= 5) ||
      -               (getIe() && getMajorVersion() >= 6);
      -    }
      -
      -    public boolean getIe6()
      -    {
      -        return getIe() && getMajorVersion() == 6;
      -    }
      -
      -    public boolean getIe6up()
      -    {
      -        return getIe() && getMajorVersion() >= 6;
      -    }
      -
      -    public boolean getIe7()
      -    {
      -        return getIe() && getMajorVersion() == 7;
      -    }
      -
      -    public boolean getIe7up()
      -    {
      -        return getIe() && getMajorVersion() >= 6;
      -    }
      -
      -    public boolean getNeoplanet()
      -    {
      -        return test("neoplanet");
      -    }
      -
      -    public boolean getNeoplanet2()
      -    {
      -        return getNeoplanet() && test("2.");
      -    }
      -
      -    public boolean getAol()
      -    {
      -        return test("aol");
      -    }
      -
      -    public boolean getAol3()
      -    {
      -        return test("aol 3.0") || getAol() && getIe3();
      -    }
      -
      -    public boolean getAol4()
      -    {
      -        return test("aol 4.0") || getAol() && getIe4();
      -    }
      -
      -    public boolean getAol5()
      -    {
      -        return test("aol 5.0");
      -    }
      -
      -    public boolean getAol6()
      -    {
      -        return test("aol 6.0");
      -    }
      -
      -    public boolean getAolTV()
      -    {
      -        return test("navio") || test("navio_aoltv");
      -    }
      -
      -    public boolean getOpera()
      -    {
      -        return test("opera");
      -    }
      -
      -    public boolean getOpera3()
      -    {
      -        return test("opera 3") || test("opera/3");
      -    }
      -
      -    public boolean getOpera4()
      -    {
      -        return test("opera 4") || test("opera/4");
      -    }
      -
      -    public boolean getOpera5()
      -    {
      -        return test("opera 5") || test("opera/5");
      -    }
      -
      -    public boolean getOpera6()
      -    {
      -        return test("opera 6") || test("opera/6");
      -    }
      -
      -    public boolean getOpera7()
      -    {
      -        return test("opera 7") || test("opera/7");
      -    }
      -
      -    public boolean getOpera8()
      -    {
      -        return test("opera 8") || test("opera/8");
      -    }
      -
      -    public boolean getOpera9()
      -    {
      -        return test("opera/9");
      -    }
      -
      -    public boolean getHotjava()
      -    {
      -        return test("hotjava");
      -    }
      -
      -    public boolean getHotjava3()
      -    {
      -        return getHotjava() && getMajorVersion() == 3;
      -    }
      -
      -    public boolean getHotjava3up()
      -    {
      -        return getHotjava() && getMajorVersion() >= 3;
      -    }
      -
      -    public boolean getAmaya()
      -    {
      -        return test("amaya");
      -    }
      -
      -    public boolean getCurl()
      -    {
      -        return test("libcurl");
      -    }
      -
      -    public boolean getStaroffice()
      -    {
      -        return test("staroffice");
      -    }
      -
      -    public boolean getIcab()
      -    {
      -        return test("icab");
      -    }
      -
      -    public boolean getLotusnotes()
      -    {
      -        return test("lotus-notes");
      -    }
      -
      -    public boolean getKonqueror()
      -    {
      -        return test("konqueror");
      -    }
      -
      -    public boolean getLynx()
      -    {
      -        return test("lynx");
      -    }
      -
      -    public boolean getLinks()
      -    {
      -        return test("links");
      -    }
      -
      -    public boolean getWebTV()
      -    {
      -        return test("webtv");
      -    }
      -
      -    public boolean getMosaic()
      -    {
      -        return test("mosaic");
      -    }
      -
      -    public boolean getWget()
      -    {
      -        return test("wget");
      -    }
      -
      -    public boolean getGetright()
      -    {
      -        return test("getright");
      -    }
      -
      -    public boolean getLwp()
      -    {
      -        return test("libwww-perl") || test("lwp-");
      -    }
      -
      -    public boolean getYahoo()
      -    {
      -        return test("yahoo");
      -    }
      -
      -    public boolean getGoogle()
      -    {
      -        return test("google");
      -    }
      -
      -    public boolean getJava()
      -    {
      -        return test("java") || test("jdk") || test("httpunit");
      -    }
      -
      -    public boolean getAltavista()
      -    {
      -        return test("altavista");
      -    }
      -
      -    public boolean getScooter()
      -    {
      -        return test("scooter");
      -    }
      -
      -    public boolean getLycos()
      -    {
      -        return test("lycos");
      -    }
      -
      -    public boolean getInfoseek()
      -    {
      -        return test("infoseek");
      -    }
      -
      -    public boolean getWebcrawler()
      -    {
      -        return test("webcrawler");
      -    }
      -
      -    public boolean getLinkexchange()
      -    {
      -        return test("lecodechecker");
      -    }
      -
      -    public boolean getSlurp()
      -    {
      -        return test("slurp");
      -    }
      -
      -    public boolean getRobot()
      -    {
      -        return getWget() || getGetright() || getLwp() || getYahoo() ||
      -               getGoogle() || getAltavista() || getScooter() || getLycos() ||
      -               getInfoseek() || getWebcrawler() || getLinkexchange() ||
      -               test("bot") || test("spider") || test("crawl") ||
      -               test("agent") || test("seek") || test("search") ||
      -               test("reap") || test("worm") || test("find") || test("index") ||
      -               test("copy") || test("fetch") || test("ia_archive") ||
      -               test("zyborg");
      -    }
      -
      -    /* Devices */
      -
      -    public boolean getBlackberry()
      -    {
      -        return test("blackberry");
      -    }
      -
      -    public boolean getAudrey()
      -    {
      -        return test("audrey");
      -    }
      -
      -    public boolean getIopener()
      -    {
      -        return test("i-opener");
      -    }
      -
      -    public boolean getAvantgo()
      -    {
      -        return test("avantgo");
      -    }
      -
      -    public boolean getPalm()
      -    {
      -        return getAvantgo() || test("palmos");
      -    }
      -
      -    public boolean getWap()
      -    {
      -        return test("up.browser") || test("nokia") || test("alcatel") ||
      -               test("ericsson") || userAgent.indexOf("sie-") == 0 ||
      -               test("wmlib") || test(" wap") || test("wap ") ||
      -               test("wap/") || test("-wap") || test("wap-") ||
      -               userAgent.indexOf("wap") == 0 ||
      -               test("wapper") || test("zetor");
      -    }
      -
      -    /* Operating System */
      -
      -    public boolean getWin16()
      -    {
      -        return test("win16") || test("16bit") || test("windows 3") ||
      -               test("windows 16-bit");
      -    }
      -
      -    public boolean getWin3x()
      -    {
      -        return test("win16") || test("windows 3") || test("windows 16-bit");
      -    }
      -
      -    public boolean getWin31()
      -    {
      -        return test("win16") || test("windows 3.1") || test("windows 16-bit");
      -    }
      -
      -    public boolean getWin95()
      -    {
      -        return test("win95") || test("windows 95");
      -    }
      -
      -    public boolean getWin98()
      -    {
      -        return test("win98") || test("windows 98");
      -    }
      -
      -    public boolean getWinnt()
      -    {
      -        return test("winnt") || test("windows nt") || test("nt4") || test("nt3");
      -    }
      -
      -    public boolean getWin2k()
      -    {
      -        return test("nt 5.0") || test("nt5");
      -    }
      -
      -    public boolean getWinxp()
      -    {
      -        return test("nt 5.1");
      -    }
      -
      -    public boolean getVista()
      -    {
      -        return test("nt 6.0");
      -    }
      -
      -    public boolean getDotnet()
      -    {
      -        return test(".net clr");
      -    }
      -
      -    public boolean getWinme()
      -    {
      -        return test("win 9x 4.90");
      -    }
      -
      -    public boolean getWin32()
      -    {
      -        return getWin95() || getWin98() || getWinnt() || getWin2k() ||
      -               getWinxp() || getWinme() || test("win32");
      -    }
      -
      -    public boolean getWindows()
      -    {
      -        return getWin16() || getWin31() || getWin95() || getWin98() ||
      -               getWinnt() || getWin32() || getWin2k() || getWinme() ||
      -               test("win");
      -    }
      -
      -    public boolean getMac()
      -    {
      -        return test("macintosh") || test("mac_");
      -    }
      -
      -    public boolean getMacosx()
      -    {
      -        return test("macintosh") || test("mac os x");
      -    }
      -
      -    public boolean getMac68k()
      -    {
      -        return getMac() && (test("68k") || test("68000"));
      -    }
      -
      -    public boolean getMacppc()
      -    {
      -        return getMac() && (test("ppc") || test("powerpc"));
      -    }
      -
      -    public boolean getAmiga()
      -    {
      -        return test("amiga");
      -    }
      -
      -    public boolean getEmacs()
      -    {
      -        return test("emacs");
      -    }
      -
      -    public boolean getOs2()
      -    {
      -        return test("os/2");
      -    }
      -
      -    public boolean getSun()
      -    {
      -        return test("sun");
      -    }
      -
      -    public boolean getSun4()
      -    {
      -        return test("sunos 4");
      -    }
      -
      -    public boolean getSun5()
      -    {
      -        return test("sunos 5");
      -    }
      -
      -    public boolean getSuni86()
      -    {
      -        return getSun() && test("i86");
      -    }
      -
      -    public boolean getIrix()
      -    {
      -        return test("irix");
      -    }
      -
      -    public boolean getIrix5()
      -    {
      -        return test("irix5");
      -    }
      -
      -    public boolean getIrix6()
      -    {
      -        return test("irix6");
      -    }
      -
      -    public boolean getHpux()
      -    {
      -        return test("hp-ux");
      -    }
      -
      -    public boolean getHpux9()
      -    {
      -        return getHpux() && test("09.");
      -    }
      -
      -    public boolean getHpux10()
      -    {
      -        return getHpux() && test("10.");
      -    }
      -
      -    public boolean getAix()
      -    {
      -        return test("aix");
      -    }
      -
      -    public boolean getAix1()
      -    {
      -        return test("aix 1");
      -    }
      -
      -    public boolean getAix2()
      -    {
      -        return test("aix 2");
      -    }
      -
      -    public boolean getAix3()
      -    {
      -        return test("aix 3");
      -    }
      -
      -    public boolean getAix4()
      -    {
      -        return test("aix 4");
      -    }
      -
      -    public boolean getLinux()
      -    {
      -        return test("linux");
      -    }
      -
      -    public boolean getSco()
      -    {
      -        return test("sco") || test("unix_sv");
      -    }
      -
      -    public boolean getUnixware()
      -    {
      -        return test("unix_system_v");
      -    }
      -
      -    public boolean getMpras()
      -    {
      -        return test("ncr");
      -    }
      -
      -    public boolean getReliant()
      -    {
      -        return test("reliantunix");
      -    }
      -
      -    public boolean getDec()
      -    {
      -        return test("dec") || test("osf1") || test("delalpha") ||
      -               test("alphaserver") || test("ultrix") || test("alphastation");
      -    }
      -
      -    public boolean getSinix()
      -    {
      -        return test("sinix");
      -    }
      -
      -    public boolean getFreebsd()
      -    {
      -        return test("freebsd");
      -    }
      -
      -    public boolean getBsd()
      -    {
      -        return test("bsd");
      -    }
      -
      -    public boolean getX11()
      -    {
      -        return test("x11");
      -    }
      -
      -    public boolean getUnix()
      -    {
      -        return getX11() || getSun() || getIrix() || getHpux() || getSco() ||
      -               getUnixware() || getMpras() || getReliant() || getDec() ||
      -               getLinux() || getBsd() || test("unix");
      -    }
      -
      -    public boolean getVMS()
      -    {
      -        return test("vax") || test("openvms");
      -    }
      -
      -    /* Features */
      -
      -    /* Since support of those features is often partial, the sniffer returns true
      -        when a consequent subset is supported. */
      -
      -    public boolean getCss()
      -    {
      -        return (getIe() && getMajorVersion() >= 4) ||
      -               (getNetscape() && getMajorVersion() >= 4) ||
      -               getGecko() ||
      -               getKonqueror() ||
      -               (getOpera() && getMajorVersion() >= 3) ||
      -               getSafari() ||
      -               getLinks();
      -    }
      -
      -    public boolean getCss1()
      -    {
      -        return getCss();
      -    }
      -
      -    public boolean getCss2()
      -    {
      -        return getIe() &&
      -               (getMac() && getMajorVersion() >= 5) ||
      -               (getWin32() && getMajorVersion() >= 6) ||
      -               getGecko() || // && version >= ?
      -               (getOpera() && getMajorVersion() >= 4) ||
      -               (getSafari() && getMajorVersion() >= 2) ||
      -               (getKonqueror() && getMajorVersion() >= 2);
      -    }
      -
      -    public boolean getDom0()
      -    {
      -        return (getIe() && getMajorVersion() >= 3) ||
      -               (getNetscape() && getMajorVersion() >= 2) ||
      -               (getOpera() && getMajorVersion() >= 3) ||
      -               getGecko() ||
      -               getSafari() ||
      -               getKonqueror();
      -    }
      -
      -    public boolean getDom1()
      -    {
      -        return (getIe() && getMajorVersion() >= 5) ||
      -               getGecko() ||
      -               (getSafari() && getMajorVersion() >= 2) ||
      -               (getOpera() && getMajorVersion() >= 4) ||
      -               (getKonqueror() && getMajorVersion() >= 2);
      -    }
      -
      -    public boolean getDom2()
      -    {
      -        return (getIe() && getMajorVersion() >= 6) ||
      -               (getMozilla() && getMajorVersion() >= 5.0) ||
      -               (getOpera() && getMajorVersion() >= 7) ||
      -               getFirefox();
      -    }
      -
      -    public boolean getJavascript()
      -    {
      -        return getDom0(); // good approximation
      -    }
      -
      -    /* Helpers */
      -
      -    private boolean test(String key)
      -    {
      -        return userAgent.indexOf(key) != -1;
      -    }
      -
      -    private void parseVersion()
      -    {
      -        try
      -        {
      -            if(version != null)
      -            {
      -                return; /* parsing of version already done */
      -            }
      -
      -            /* generic versionning */
      -            Matcher v = Pattern.compile(
      -                    "/"
      -                    /* Version starts with a slash */
      -                    +
      -                    "([A-Za-z]*"
      -                    /* Eat any letters before the major version */
      -                    +
      -                    "( [\\d]* )"
      -                    /* Major version number is every digit before the first dot */
      -                    + "\\." /* The first dot */
      -                    +
      -                    "( [\\d]* )"
      -                    /* Minor version number is every digit after the first dot */
      -                    + "[^\\s]*)" /* Throw away the remaining */
      -                    , Pattern.COMMENTS).matcher(userAgent);
      -
      -            if(v.find())
      -            {
      -                version = v.group(1);
      -                try
      -                {
      -                    majorVersion = Integer.parseInt(v.group(2));
      -                    String minor = v.group(3);
      -                    if(minor.startsWith("0"))minorVersion = 0;
      -                    else minorVersion = Integer.parseInt(minor);
      -                }
      -                catch(NumberFormatException nfe)
      -                {}
      -            }
      -
      -            /* Firefox versionning */
      -            if(test("firefox"))
      -            {
      -                Matcher fx = Pattern.compile(
      -                        "/"
      -                        +
      -                        "(( [\\d]* )"
      -                        /* Major version number is every digit before the first dot */
      -                        + "\\." /* The first dot */
      -                        +
      -                        "( [\\d]* )"
      -                        /* Minor version number is every digit after the first dot */
      -                        + "[^\\s]*)" /* Throw away the remaining */
      -                        , Pattern.COMMENTS)
      -                        .matcher(userAgent);
      -                if(fx.find())
      -                {
      -                    version = fx.group(1);
      -                    try
      -                    {
      -                        majorVersion = Integer.parseInt(fx.group(2));
      -                        String minor = fx.group(3);
      -                        if(minor.startsWith("0"))minorVersion = 0;
      -                        else minorVersion = Integer.parseInt(minor);
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -
      -            /* IE versionning */
      -            if(test("compatible"))
      -            {
      -                Matcher ie = Pattern.compile(
      -                        "compatible;"
      -                        + "\\s*"
      -                        + "\\w*" /* Browser name */
      -                        + "[\\s|/]"
      -                        +
      -                        "([A-Za-z]*"
      -                        /* Eat any letters before the major version */
      -                        +
      -                        "( [\\d]* )"
      -                        /* Major version number is every digit before first dot */
      -                        + "\\." /* The first dot */
      -                        +
      -                        "( [\\d]* )"
      -                        /* Minor version number is digits after first dot */
      -                        + "[^\\s]*)" /* Throw away remaining dots and digits */
      -                        , Pattern.COMMENTS)
      -                        .matcher(userAgent);
      -                if(ie.find())
      -                {
      -                    version = ie.group(1);
      -                    try
      -                    {
      -                        majorVersion = Integer.parseInt(ie.group(2));
      -                        String minor = ie.group(3);
      -                        if(minor.startsWith("0"))minorVersion = 0;
      -                        else minorVersion = Integer.parseInt(minor);
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -
      -            /* Safari versionning*/
      -            if(getSafari())
      -            {
      -                Matcher safari = Pattern.compile(
      -                        "safari/"
      -                        +
      -                        "(( [\\d]* )"
      -                        /* Major version number is every digit before first dot */
      -                        + "(?:"
      -                        + "\\." /* The first dot */
      -                        +
      -                        " [\\d]* )?)"
      -                        /* Minor version number is digits after first dot */
      -                        , Pattern.COMMENTS)
      -                        .matcher(userAgent);
      -                if(safari.find())
      -                {
      -                    version = safari.group(1);
      -                    try
      -                    {
      -                        int sv = Integer.parseInt(safari.group(2));
      -                        majorVersion = sv / 100;
      -                        minorVersion = sv % 100;
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -
      -            /* Gecko-powered Netscape (i.e. Mozilla) versions */
      -            if(getGecko() && getNetscape() && test("netscape"))
      -            {
      -                Matcher netscape = Pattern.compile(
      -                        "netscape/"
      -                        +
      -                        "(( [\\d]* )"
      -                        /* Major version number is every digit before the first dot */
      -                        + "\\." /* The first dot */
      -                        +
      -                        "( [\\d]* )"
      -                        /* Minor version number is every digit after the first dot */
      -                        + "[^\\s]*)" /* Throw away the remaining */
      -                        , Pattern.COMMENTS)
      -                        .matcher(userAgent);
      -                if(netscape.find())
      -                {
      -                    version = netscape.group(1);
      -                    try
      -                    {
      -                        majorVersion = Integer.parseInt(netscape.group(2));
      -                        String minor = netscape.group(3);
      -                        if(minor.startsWith("0"))minorVersion = 0;
      -                        else minorVersion = Integer.parseInt(minor);
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -
      -            /* last try if version not found */
      -            if(version == null)
      -            {
      -                Matcher mv = Pattern.compile(
      -                        "[\\w]+/"
      -                        +
      -                        "( [\\d]+ );"
      -                        /* Major version number is every digit before the first dot */
      -                        , Pattern.COMMENTS)
      -                        .matcher(userAgent);
      -                if(mv.find())
      -                {
      -                    version = mv.group(1);
      -                    try
      -                    {
      -                        majorVersion = Integer.parseInt(version);
      -                        minorVersion = 0;
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -
      -            /* gecko engine version */
      -            if(getGecko())
      -            {
      -            Matcher g = Pattern.compile(
      -                        "\\([^)]*rv:(([\\d]*)\\.([\\d]*).*?)\\)"
      -                        ).matcher(userAgent);
      -                if(g.find())
      -                {
      -                    geckoVersion = g.group(1);
      -                    try
      -                    {
      -                    geckoMajorVersion = Integer.parseInt(g.group(2));
      -                    String minor = g.group(3);
      -                        if(minor.startsWith("0"))geckoMinorVersion = 0;
      -                        else geckoMinorVersion = Integer.parseInt(minor);
      -                    }
      -                    catch(NumberFormatException nfe)
      -                    {}
      -                }
      -            }
      -        }
      -        catch(PatternSyntaxException nfe)
      -        {
      -            // where should I log ?!
      -        }
      -    }
      -
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java Mon Jun  4 17:24:29 2007
      @@ -19,83 +19,15 @@
        * under the License.
        */
       
      -import java.util.Arrays;
      -import java.util.Enumeration;
      -import java.util.HashSet;
      -import java.util.Iterator;
      -import java.util.Map;
      -import java.util.Set;
      -import javax.servlet.http.HttpServletRequest;
      -import javax.servlet.http.HttpSession;
      -import javax.servlet.ServletContext;
      -import org.apache.velocity.context.AbstractContext;
      -import org.apache.velocity.context.Context;
      -import org.apache.velocity.tools.config.DefaultKey;
      -import org.apache.velocity.tools.config.InvalidScope;
      -import org.apache.velocity.tools.generic.ValueParser;
       import org.apache.velocity.tools.view.ViewContext;
      -import org.apache.velocity.tools.view.ViewToolContext;
       
       /**
      - * <p>View tool for convenient access to {@link ViewContext} data and
      - *  meta-data.</p>
      - * <p><pre>
      - * Template example(s):
      - *  #foreach( $key in $context.keys )
      - *    $key = $context.get($key)
      - *  #end
      - *
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;context&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.ContextTool&lt;/class&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * <p>This class is only designed for use as a request-scope VelocityView tool.</p>
      - *
      - * @author Nathan Bubna
      - * @since VelocityTools 1.3
      - * @version $Id: ContextTool.java 385122 2006-03-11 18:37:42Z nbubna $
      + * Use {@link org.apache.velocity.tools.view.ContextTool}
        */
      -@DefaultKey("context")
      -@InvalidScope({"application","session"})
      -public class ContextTool
      +@Deprecated
      +public class ContextTool extends
      +    org.apache.velocity.tools.view.ContextTool
       {
      -    /**
      -     * The key used for specifying whether to hide keys with '.' in them.
      -     */
      -    public static final String SAFE_MODE_KEY = "safe-mode";
      -
      -    protected ViewContext context;
      -    protected Map toolbox;
      -    protected HttpServletRequest request;
      -    protected HttpSession session;
      -    protected ServletContext application;
      -
      -    private boolean safeMode = true;
      -
      -
      -    /**
      -     * Initializes this instance for the current request.
      -     * Also looks for a safe-mode configuration setting. By default,
      -     * safe-mode is true and thus keys with '.' in them are hidden.
      -     */
      -    public void configure(Map params)
      -    {
      -        if (params != null)
      -        {
      -            ValueParser parser = new ValueParser(params);
      -            safeMode = parser.getBoolean(SAFE_MODE_KEY, true);
      -        }
      -
      -        this.context = (ViewContext)params.get(ViewToolContext.CONTEXT_KEY);
      -        this.request = (HttpServletRequest)params.get(ViewContext.REQUEST);
      -        this.session = request.getSession(false);
      -        this.application = (ServletContext)params.get(ViewContext.SERVLET_CONTEXT_KEY);
      -    }
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -107,141 +39,4 @@
                   this.application = context.getServletContext();
               }
           }
      -
      -
      -    /**
      -     * Returns the context being analyzed by this tool.
      -     */
      -    public ViewContext getThis()
      -    {
      -        return this.context;
      -    }
      -
      -    /**
      -     * <p>Returns a read-only view of the toolbox {@link Map}
      -     * for this context.</p>
      -     * @return a map of all available tools for this request
      -     *         or {@code null} if such a map is not available
      -     */
      -    public Map getToolbox()
      -    {
      -        if (this.toolbox == null && this.context instanceof ViewToolContext)
      -        {
      -            this.toolbox = ((ViewToolContext)context).getToolbox();
      -        }
      -        return this.toolbox;
      -    }
      -
      -    /**
      -     * <p>Return a {@link Set} of the available reference keys in the current
      -     * context.</p>
      -     */
      -    public Set getKeys()
      -    {
      -        Set keys = new HashSet();
      -
      -        // get the tool keys, if there is a toolbox
      -        Map tools = getToolbox();
      -        if (tools != null)
      -        {
      -            keys.addAll(tools.keySet());
      -        }
      -
      -        // recurse down the velocity context collecting keys
      -        Context velctx = this.context.getVelocityContext();
      -        while (velctx != null)
      -        {
      -            Object[] ctxKeys = velctx.getKeys();
      -            keys.addAll(Arrays.asList(ctxKeys));
      -            if (velctx instanceof AbstractContext)
      -            {
      -                velctx = ((AbstractContext)velctx).getChainedContext();
      -            }
      -            else
      -            {
      -                velctx = null;
      -            }
      -        }
      -
      -        // get request attribute keys
      -        Enumeration e = request.getAttributeNames();
      -        while (e.hasMoreElements())
      -        {
      -            keys.add(e.nextElement());
      -        }
      -
      -        // get session attribute keys if we have a session
      -        if (session != null)
      -        {
      -            e = session.getAttributeNames();
      -            while (e.hasMoreElements())
      -            {
      -                keys.add(e.nextElement());
      -            }
      -        }
      -
      -        // get request attribute keys
      -        e = application.getAttributeNames();
      -        while (e.hasMoreElements())
      -        {
      -            keys.add(e.nextElement());
      -        }
      -
      -        // if we're in safe mode, remove keys that contain '.'
      -        if (safeMode)
      -        {
      -            for (Iterator i = keys.iterator(); i.hasNext(); )
      -            {
      -                String key = String.valueOf(i.next());
      -                if (key.indexOf('.') >= 0)
      -                {
      -                    i.remove();
      -                }
      -            }
      -        }
      -
      -        // return the key set
      -        return keys;
      -    }
      -
      -    /**
      -     * <p>Return a {@link Set} of the available values in the current
      -     * context.</p>
      -     */
      -    public Set getValues()
      -    {
      -        //TODO: this could be a lot more efficient
      -        Set keys = getKeys();
      -        Set values = new HashSet(keys.size());
      -        for (Iterator i = keys.iterator(); i.hasNext(); )
      -        {
      -            String key = String.valueOf(i.next());
      -            values.add(this.context.getVelocityContext().get(key));
      -        }
      -        return values;
      -    }
      -
      -
      -    /**
      -     * <p>Returns {@code true} if the context contains a value for the specified
      -     * reference name (aka context key).</p>
      -     */
      -    public boolean contains(Object refName)
      -    {
      -        return (get(refName) != null);
      -    }
      -
      -    /**
      -     * Retrieves the value for the specified reference name (aka context key).
      -     */
      -    public Object get(Object refName)
      -    {
      -        String key = String.valueOf(refName);
      -        if (safeMode && key.indexOf('.') >= 0)
      -        {
      -            return null;
      -        }
      -        return this.context.getVelocityContext().get(key);
      -    }
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/CookieTool.java Mon Jun  4 17:24:29 2007
      @@ -19,45 +19,15 @@
        * under the License.
        */
       
      -import javax.servlet.http.Cookie;
      -import javax.servlet.http.HttpServletRequest;
      -import javax.servlet.http.HttpServletResponse;
      -import org.apache.velocity.tools.config.DefaultKey;
      -import org.apache.velocity.tools.config.ValidScope;
       import org.apache.velocity.tools.view.ViewContext;
       
       /**
      - * <p>View tool for convenient cookie access and creation.</p>
      - * <p><pre>
      - * Template example(s):
      - *  $cookie.foo.value
      - *  $cookie.add("bar",'woogie')
      - *
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;cookie&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.CookieTool&lt;/class&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * <p>This class is only designed for use as a request-scope tool.</p>
      - *
      - * @author <a href="mailto:dim@colebatch.com">Dmitri Colebatch</a>
      - * @author Nathan Bubna
      - * @since VelocityTools 1.1
      - * @version $Id$
      + * Use {@link org.apache.velocity.tools.view.CookieTool}
        */
      -@DefaultKey("cookies")
      -@ValidScope("request")
      -public class CookieTool
      +@Deprecated
      +public class CookieTool extends
      +    org.apache.velocity.tools.view.CookieTool
       {
      -
      -    protected HttpServletRequest request;
      -    protected HttpServletResponse response;
      -
      -    // --------------------------------------- Setup Methods -------------
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -67,160 +37,5 @@
                   setRequest(ctx.getRequest());
                   setResponse(ctx.getResponse());
               }
      -    }
      -
      -    /**
      -     * Sets the current {@link HttpServletRequest}. This is required
      -     * for this tool to operate and will throw a NullPointerException
      -     * if this is not set or is set to {@code null}.
      -     */
      -    public void setRequest(HttpServletRequest request)
      -    {
      -        if (request == null)
      -        {
      -            throw new NullPointerException("request should not be null");
      -        }
      -        this.request = request;
      -    }
      -
      -    /**
      -     * Sets the current {@link HttpServletResponse}. This is required
      -     * for this tool to operate and will throw a NullPointerException
      -     * if this is not set or is set to {@code null}.
      -     */
      -    public void setResponse(HttpServletResponse response)
      -    {
      -        if (response == null)
      -        {
      -            throw new NullPointerException("response should not be null");
      -        }
      -        this.response = response;
      -    }
      -
      -
      -    /**
      -     * Expose array of Cookies for this request to the template.
      -     *
      -     * <p>This is equivalent to <code>$request.cookies</code>.</p>
      -     *
      -     * @return array of Cookie objects for this request
      -     */
      -    public Cookie[] getAll()
      -    {
      -        return request.getCookies();
      -    }
      -
      -
      -    /**
      -     * Returns the Cookie with the specified name, if it exists.
      -     *
      -     * <p>So, if you had a cookie named 'foo', you'd get it's value
      -     * by <code>$cookies.foo.value</code> or it's max age
      -     * by <code>$cookies.foo.maxAge</code></p>
      -     */
      -    public Cookie get(String name)
      -    {
      -        Cookie[] all = getAll();
      -        if (all == null)
      -        {
      -            return null;
      -        }
      -
      -        for (int i = 0; i < all.length; i++)
      -        {
      -            Cookie cookie = all[i];
      -            if (cookie.getName().equals(name))
      -            {
      -                return cookie;
      -            }
      -        }
      -        return null;
      -    }
      -
      -
      -    /**
      -     * Adds a new Cookie with the specified name and value
      -     * to the HttpServletResponse.  This does *not* add a Cookie
      -     * to the current request.
      -     *
      -     * @param name the name to give this cookie
      -     * @param value the value to be set for this cookie
      -     */
      -    public void add(String name, String value)
      -    {
      -        response.addCookie(create(name, value));
      -    }
      -
      -
      -    /**
      -     * Convenience method to add a new Cookie to the response
      -     * and set an expiry time for it.
      -     *
      -     * @param name the name to give this cookie
      -     * @param value the value to be set for this cookie
      -     * @param maxAge the expiry to be set for this cookie
      -     */
      -    public void add(String name, String value, Object maxAge)
      -    {
      -        Cookie c = create(name, value, maxAge);
      -        if (c == null)
      -        {
      -            /* TODO: something better? */
      -            return;
      -        }
      -        response.addCookie(c);
      -    }
      -
      -
      -    /**
      -     * Creates a new Cookie with the specified name and value.
      -     * This does *not* add the Cookie to the response, so the
      -     * created Cookie will not be set unless you do
      -     * <code>$response.addCookie($myCookie)</code>.
      -     *
      -     * @param name the name to give this cookie
      -     * @param value the value to be set for this cookie
      -     * @return The new Cookie object.
      -     * @since VelocityTools 1.3
      -     */
      -    public Cookie create(String name, String value)
      -    {
      -        return new Cookie(name, value);
      -    }
      -
      -
      -    /**
      -     * Convenience method to create a new Cookie
      -     * and set an expiry time for it.
      -     *
      -     * @param name the name to give this cookie
      -     * @param value the value to be set for this cookie
      -     * @param maxAge the expiry to be set for this cookie
      -     * @return The new Cookie object.
      -     * @since VelocityTools 1.3
      -     */
      -    public Cookie create(String name, String value, Object maxAge)
      -    {
      -        int expiry;
      -        if (maxAge instanceof Number)
      -        {
      -            expiry = ((Number)maxAge).intValue();
      -        }
      -        else
      -        {
      -            try
      -            {
      -                expiry = Integer.parseInt(String.valueOf(maxAge));
      -            }
      -            catch (NumberFormatException nfe)
      -            {
      -                return null;
      -            }
      -        }
      -        
      -        /* c is for cookie.  that's good enough for me. */
      -        Cookie c = new Cookie(name, value);
      -        c.setMaxAge(expiry);
      -        return c;
           }
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ImportTool.java Mon Jun  4 17:24:29 2007
      @@ -19,39 +19,14 @@
        * under the License.
        */
       
      -import org.apache.velocity.tools.config.DefaultKey;
      -import org.apache.velocity.tools.config.ValidScope;
      -import org.apache.velocity.tools.view.ImportSupport;
       import org.apache.velocity.tools.view.ViewContext;
       
       /**
      - * General-purpose text-importing view tool for templates.
      - * <p>Usage:<br />
      - * Just call $import.read("http://www.foo.com/bleh.jsp?sneh=bar") to insert the contents of the named
      - * resource into the template.
      - * </p>
      - * <p><pre>
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;import&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.ImportTool&lt;/class&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * @author <a href="mailto:marinoj@centrum.is">Marino A. Jonsson</a>
      - * @since VelocityTools 1.1
      - * @version $Revision$ $Date$
      + * Use {@link org.apache.velocity.tools.view.tools.ImportTool}
        */
      -@DefaultKey("import")
      -@ValidScope("request")
      -public class ImportTool extends ImportSupport
      +@Deprecated
      +public class ImportTool extends org.apache.velocity.tools.view.ImportTool
       {
      -    /**
      -     * Default constructor. Tool must be initialized before use.
      -     */
      -    public ImportTool() {}
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -64,27 +39,4 @@
                   setLog(ctx.getVelocityEngine().getLog());
               }
           }
      -
      -    /**
      -     * Returns the supplied URL rendered as a String.
      -     *
      -     * @param url the URL to import
      -     * @return the URL as a string
      -     */
      -    public String read(String url) {
      -        try {
      -            // check the URL
      -            if (url == null || url.equals("")) {
      -                LOG.warn("ImportTool : Import URL is null or empty");
      -                return null;
      -            }
      -
      -            return acquireString(url);
      -        }
      -        catch (Exception ex) {
      -            LOG.error("ImportTool : Exception while importing URL", ex);
      -            return null;
      -        }
      -    }
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/LinkTool.java Mon Jun  4 17:24:29 2007
      @@ -19,138 +19,14 @@
        * under the License.
        */
       
      -import java.lang.reflect.InvocationTargetException;
      -import java.lang.reflect.Method;
      -import java.net.URLEncoder;
      -import java.util.ArrayList;
      -import java.util.Iterator;
      -import java.util.List;
      -import java.util.Map;
      -import javax.servlet.ServletContext;
      -import javax.servlet.http.HttpServletRequest;
      -import javax.servlet.http.HttpServletResponse;
      -import org.apache.velocity.runtime.log.Log;
      -import org.apache.velocity.tools.config.DefaultKey;
      -import org.apache.velocity.tools.config.ValidScope;
      -import org.apache.velocity.tools.generic.ValueParser;
       import org.apache.velocity.tools.view.ViewContext;
      -import org.apache.velocity.tools.view.ServletUtils;
       
       /**
      - * View tool to make building URIs pleasant and fun!
      - * <p><pre>
      - * Template example(s):
      - *   #set( $base = $link.relative('MyPage.vm').anchor('view') )
      - *   &lt;a href="$base.param('select','this')"&gt;this&lt;/a&gt;
      - *   &lt;a href="$base.param('select','that')"&gt;that&lt;/a&gt;
      - *
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;link&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.LinkTool&lt;/class&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * <p>This tool should only be used in the request scope.</p>
      - *
      - * @author <a href="mailto:sidler@teamup.com">Gabe Sidler</a>
      - * @author Nathan Bubna
      - * @since VelocityTools 1.0
      - * @version $Id$
      + * Use {@link org.apache.velocity.tools.view.LinkTool}
        */
      -@DefaultKey("link")
      -@ValidScope("request")
      -public class LinkTool implements Cloneable
      +@Deprecated
      +public class LinkTool extends org.apache.velocity.tools.view.LinkTool
       {
      -    /**
      -     * Parameter key for configuring {@link #setSelfAbsolute} state
      -     * @since VelocityTools 1.3
      -     */
      -    public static final String SELF_ABSOLUTE_KEY = "self-absolute";
      -
      -    /**
      -     * Parameter key for configuring {@link #setSelfIncludeParameters} state
      -     * @since VelocityTools 1.3
      -     */
      -    public static final String SELF_INCLUDE_PARAMETERS_KEY = "self-include-parameters";
      -
      -    /** Standard HTML delimiter for query data ('&') */
      -    public static final String HTML_QUERY_DELIMITER = "&";
      -
      -    /** XHTML delimiter for query data ('&amp;amp;') */
      -    public static final String XHTML_QUERY_DELIMITER = "&amp;";
      -
      -
      -    /** A reference to the ServletContext */
      -    protected ServletContext application;
      -
      -    /** A reference to the HttpServletRequest. */
      -    protected HttpServletRequest request;
      -
      -    /** A reference to the HttpServletResponse. */
      -    protected HttpServletResponse response;
      -
      -    /** A reference to the Velocity runtime's {@link Log}. */
      -    protected Log LOG;
      -
      -
      -    /** The URI reference set for this link. */
      -    private String uri;
      -
      -    /** The anchor set for this link. */
      -    private String anchor;
      -
      -    /** A list of query string parameters. */
      -    private ArrayList queryData;
      -
      -    /** The current delimiter for query data */
      -    private String queryDataDelim;
      -
      -    /** The self-absolute status */
      -    private boolean selfAbsolute;
      -
      -    /** The self-include-parameters status */
      -    private boolean selfParams;
      -
      -
      -    /** Java 1.4 encode method to use instead of deprecated 1.3 version. */
      -    private static Method encode = null;
      -
      -    /* Initialize the encode variable with the 1.4 method if available.
      -     * this code was adapted from org.apache.struts.utils.RequestUtils */
      -    static
      -    {
      -        try
      -        {
      -            /* get version of encode method with two String args  */
      -            Class[] args = new Class[] { String.class, String.class };
      -            encode = URLEncoder.class.getMethod("encode", args);
      -        }
      -        catch (NoSuchMethodException e)
      -        {
      -            //TODO: drop JDK 1.3 support in separate commit
      -            //LOG.debug("LinkTool : Can't find JDK 1.4 encode method. Using JDK 1.3 version.");
      -        }
      -    }
      -
      -
      -    /**
      -     * Default constructor. Tool must be initialized before use.
      -     */
      -    public LinkTool()
      -    {
      -        uri = null;
      -        anchor = null;
      -        queryData = null;
      -        queryDataDelim = XHTML_QUERY_DELIMITER;
      -        selfAbsolute = false;
      -        selfParams = false;
      -    }
      -
      -
      -    // --------------------------------------- Setup Methods -------------
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -164,778 +40,9 @@
               }
           }
       
      -    /**
      -     * Sets the current {@link HttpServletRequest}. This is required
      -     * for this tool to operate and will throw a NullPointerException
      -     * if this is not set or is set to {@code null}.
      -     */
      -    public void setRequest(HttpServletRequest request)
      -    {
      -        if (request == null)
      -        {
      -            throw new NullPointerException("request should not be null");
      -        }
      -        this.request = request;
      -    }
      -
      -    /**
      -     * Sets the current {@link HttpServletResponse}. This is required
      -     * for this tool to operate and will throw a NullPointerException
      -     * if this is not set or is set to {@code null}.
      -     */
      -    public void setResponse(HttpServletResponse response)
      -    {
      -        if (response == null)
      -        {
      -            throw new NullPointerException("response should not be null");
      -        }
      -        this.response = response;
      -    }
      -
      -    public void setServletContext(ServletContext application)
      -    {
      -        if (application == null)
      -        {
      -            throw new NullPointerException("servletContext should not be null");
      -        }
      -        this.application = application;
      -    }
      -
      -    public void setLog(Log log)
      -    {
      -        if (log == null)
      -        {
      -            throw new NullPointerException("log should not be null");
      -        }
      -        this.LOG = log;
      -    }
      -
           @Deprecated
           public void setXhtml(boolean useXhtml)
           {
      -        queryDataDelim =
      -            (useXhtml) ? XHTML_QUERY_DELIMITER : HTML_QUERY_DELIMITER;
      -    }
      -
      -    /**
      -     * <p>Controls the delimiter used for separating query data pairs.
      -     *    By default, the standard '&' character is used.</p>
      -     * <p>This is not exposed to templates as this decision is best not
      -     *    made at that level.</p>
      -     * <p>Subclasses may easily override the init() method to set this
      -     *    appropriately and then call super.init()</p>
      -     *
      -     * @param useXhtml if true, the XHTML query data delimiter ('&amp;amp;')
      -     *        will be used.  if false, then '&' will be used.
      -     * @see <a href="http://www.w3.org/TR/xhtml1/#C_12">Using Ampersands in Attribute Values (and Elsewhere)</a>
      -     */
      -    public void setXHTML(boolean useXhtml)
      -    {
      -        setXhtml(useXhtml);
      -    }
      -    
      -    /**
      -     * <p>Controls whether or not the {@link #getSelf()} method will return
      -     *    a duplicate with a URI in absolute or relative form.</p>
      -     *
      -     * @param selfAbsolute if true, the {@link #getSelf()} method will return
      -     *        a duplicate of this tool with an absolute self-referencing URI;
      -     *        if false, a duplicate with a relative self-referencing URI will
      -     *        be returned
      -     * @see #getSelf()
      -     * @since VelocityTools 1.3
      -     */
      -    public void setSelfAbsolute(boolean selfAbsolute)
      -    {
      -        this.selfAbsolute = selfAbsolute;
      -    }
      -
      -    /**
      -     * <p>Controls whether or not the {@link #getSelf()} method will return
      -     *    a duplicate that includes current request parameters.</p>
      -     *
      -     * @param selfParams if true, the {@link #getSelf()} method will return
      -     *        a duplicate of this tool that includes current request parameters
      -     * @see #getSelf()
      -     * @since VelocityTools 1.3
      -     */
      -    public void setSelfIncludeParameters(boolean selfParams)
      -    {
      -        this.selfParams = selfParams;
      -    }
      -
      -
      -    /**
      -     * For internal use.
      -     *
      -     * Copies 'that' LinkTool into this one and adds the new query data.
      -     *
      -     * @param pair the query parameter to add
      -     */
      -    protected LinkTool copyWith(QueryPair pair)
      -    {
      -        LinkTool copy = duplicate();
      -        if (copy.queryData != null)
      -        {
      -            // set the copy's query data to a shallow clone of
      -            // the current query data array
      -            copy.queryData = (ArrayList)this.queryData.clone();
      -        }
      -        else
      -        {
      -            copy.queryData = new ArrayList();
      -        }
      -        //add new pair to this LinkTool's query data
      -        copy.queryData.add(pair);
      -        return copy;
      -    }
      -
      -
      -    /**
      -     * For internal use.
      -     *
      -     * Copies 'that' LinkTool into this one and adds the new query data.
      -     *
      -     * @param newQueryData the query parameters to add
      -     * @since VelocityTools 1.3
      -     */
      -    protected LinkTool copyWith(Map newQueryData)
      -    {
      -        LinkTool copy = duplicate();
      -        if (copy.queryData != null)
      -        {
      -            // set the copy's query data to a shallow clone of
      -            // the current query data array
      -            copy.queryData = (ArrayList)this.queryData.clone();
      -        }
      -        else
      -        {
      -            copy.queryData = new ArrayList();
      -        }
      -        for (Iterator i = newQueryData.keySet().iterator(); i.hasNext(); )
      -        {
      -            Object key = i.next();
      -            Object value = newQueryData.get(key);
      -            copy.queryData.add(new QueryPair(String.valueOf(key), value));
      -        }
      -        return copy;
      -    }
      -
      -
      -    /**
      -     * For internal use.
      -     *
      -     * Copies 'that' LinkTool into this one and sets the new URI.
      -     *
      -     * @param uri uri string
      -     */
      -    protected LinkTool copyWith(String uri)
      -    {
      -        LinkTool copy = duplicate();
      -        copy.uri = uri;
      -        return copy;
      -    }
      -
      -
      -    /**
      -     * For internal use.
      -     *
      -     * Copies 'that' LinkTool into this one and sets the new
      -     * anchor for the link.
      -     *
      -     * @param anchor URI string
      -     */
      -    protected LinkTool copyWithAnchor(String anchor)
      -    {
      -        LinkTool copy = duplicate();
      -        copy.anchor = anchor;
      -        return copy;
      -    }
      -
      -
      -    /**
      -     * This is just to avoid duplicating this code for both copyWith() methods
      -     */
      -    protected LinkTool duplicate()
      -    {
      -        try
      -        {
      -            return (LinkTool)this.clone();
      -        }
      -        catch (CloneNotSupportedException e)
      -        {
      -            LOG.warn("LinkTool : Could not properly clone " + getClass(), e);
      -
      -            // "clone" manually
      -            LinkTool copy;
      -            try
      -            {
      -                // one last try for a subclass instance...
      -                copy = (LinkTool)getClass().newInstance();
      -            }
      -            catch (Exception ee)
      -            {
      -                // fine, we'll use the base class
      -                copy = new LinkTool();
      -            }
      -            copy.application = this.application;
      -            copy.request = this.request;
      -            copy.response = this.response;
      -            copy.uri = this.uri;
      -            copy.anchor = this.anchor;
      -            copy.queryData = this.queryData;
      -            copy.queryDataDelim = this.queryDataDelim;
      -            copy.selfAbsolute = this.selfAbsolute;
      -            copy.selfParams = this.selfParams;
      -            return copy;
      -        }
      -    }
      -
      -    // --------------------------------------------- Template Methods -----------
      -
      -    /**
      -     * <p>Returns a copy of the link with the specified anchor to be
      -     *    added to the end of the generated hyperlink.</p>
      -     *
      -     * Example:<br>
      -     * <code>&lt;a href='$link.setAnchor("foo")'&gt;Foo&lt;/a&gt;</code><br>
      -     * produces something like</br>
      -     * <code>&lt;a href="#foo"&gt;Foo&lt;/a&gt;</code><br>
      -     *
      -     * @param anchor an internal document reference
      -     *
      -     * @return a new instance of LinkTool with the set anchor
      -     */
      -    public LinkTool setAnchor(String anchor)
      -    {
      -        return copyWithAnchor(anchor);
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #setAnchor}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool anchor(String anchor)
      -    {
      -        return setAnchor(anchor);
      -    }
      -
      -    /**
      -     * Returns the anchor (internal document reference) set for this link.
      -     */
      -    public String getAnchor()
      -    {
      -        return anchor;
      -    }
      -
      -
      -    /**
      -     * <p>Returns a copy of the link with the specified context-relative
      -     * URI reference converted to a server-relative URI reference. This
      -     * method will overwrite any previous URI reference settings but will
      -     * copy the query string.</p>
      -     *
      -     * Example:<br>
      -     * <code>&lt;a href='$link.setRelative("/templates/login/index.vm")'&gt;Login Page&lt;/a&gt;</code><br>
      -     * produces something like</br>
      -     * <code>&lt;a href="/myapp/templates/login/index.vm"&gt;Login Page&lt;/a&gt;</code><br>
      -     *
      -     * @param uri A context-relative URI reference. A context-relative URI
      -     * is a URI that is relative to the root of this web application.
      -     *
      -     * @return a new instance of LinkTool with the specified URI
      -     */
      -    public LinkTool setRelative(String uri)
      -    {
      -        String ctxPath = request.getContextPath();
      -        /* if the context path is the webapp root */
      -        if (ctxPath.equals("/"))
      -        {
      -            /* then don't append anything for it */
      -            ctxPath = "";
      -        }
      -        if (uri.startsWith("/"))
      -        {
      -            return copyWith(ctxPath + uri);
      -        }
      -        else
      -        {
      -            return copyWith(ctxPath + '/' + uri);
      -        }
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #setRelative}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool relative(String uri)
      -    {
      -        return setRelative(uri);
      -    }
      -
      -
      -    /**
      -     * <p>Returns a copy of the link with the specified URI reference
      -     * either used as or converted to an absolute (non-relative)
      -     * URI reference. This method will overwrite any previous URI
      -     * reference settings but will copy the query string.</p>
      -     *
      -     * Example:<br>
      -     * <code>&lt;a href='$link.setAbsolute("/templates/login/index.vm")'&gt;Login Page&lt;/a&gt;</code><br>
      -     * produces something like<br/>
      -     * <code>&lt;a href="http://myserver.net/myapp/templates/login/index.vm"&gt;Login Page&lt;/a&gt;</code><br>
      -     * and<br>
      -     * <code>&lt;a href='$link.setAbsolute("http://theirserver.com/index.jsp")'&gt;Their, Inc.&lt;/a&gt;</code><br>
      -     * produces something like<br/>
      -     * <code>&lt;a href="http://theirserver.net/index.jsp"&gt;Their, Inc.&lt;/a&gt;</code><br>
      -     *
      -     * @param uri A context-relative URI reference or absolute URL.
      -     * @return a new instance of LinkTool with the specified URI
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool setAbsolute(String uri)
      -    {
      -        // if they're creating a url for a separate site
      -        if (uri.startsWith("http"))
      -        {
      -            // just set the URI
      -            return setURI(uri);
      -        }
      -        else
      -        {
      -            // otherwise, prepend this webapp's context url
      -            String fullCtx = getContextURL();
      -            if (uri.startsWith("/"))
      -            {
      -                return copyWith(fullCtx + uri);
      -            }
      -            else
      -            {
      -                return copyWith(fullCtx + '/' + uri);
      -            }
      -        }
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #setAbsolute}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool absolute(String uri)
      -    {
      -        return setAbsolute(uri);
      -    }
      -
      -
      -    /**
      -     * <p>Returns a copy of the link with the given URI reference set.
      -     * No conversions are applied to the given URI reference. The URI
      -     * reference can be absolute, server-relative, relative and may
      -     * contain query parameters. This method will overwrite any
      -     * previous URI reference settings but will copy the query
      -     * string.</p>
      -     *
      -     * @param uri URI reference to set
      -     *
      -     * @return a new instance of LinkTool
      -     */
      -    public LinkTool setURI(String uri)
      -    {
      -        return copyWith(uri);
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #setURI}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool uri(String uri)
      -    {
      -        return setURI(uri);
      -    }
      -
      -    /**
      -     * <p>Returns the current URI of this link as set by the setURI(String),
      -     * setAbsolute(String) or setRelative(String) methods. Any conversions
      -     * have been applied. The returned URI reference does not include query
      -     * data that was added with method addQueryData().</p>
      -     */
      -    public String getURI()
      -    {
      -        return uri;
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #getURI} to enable
      -     * all lowercase {@code $link.uri} syntax.
      -     * @since VelocityTools 1.3
      -     */
      -    public String getUri()
      -    {
      -        return getURI();
      -    }
      -
      -
      -    /**
      -     * <p>Adds a key=value pair to the query data. This returns a new LinkTool
      -     * containing both a copy of this LinkTool's query data and the new data.
      -     * Query data is URL encoded before it is appended.</p>
      -     *
      -     * @param key key of new query parameter
      -     * @param value value of new query parameter
      -     *
      -     * @return a new instance of LinkTool
      -     */
      -    public LinkTool addQueryData(String key, Object value)
      -    {
      -        return copyWith(new QueryPair(key, value));
      -    }
      -
      -    /**
      -     * <p>Adds multiple key=value pairs to the query data.
      -     * This returns a new LinkTool containing both a copy of
      -     * this LinkTool's query data and the new data.
      -     * Query data is URL encoded before it is appended.</p>
      -     *
      -     * @param parameters map of new query data keys to values
      -     * @return a new instance of LinkTool
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool addQueryData(Map parameters)
      -    {
      -        // don't waste time with null/empty data
      -        if (parameters == null || parameters.isEmpty())
      -        {
      -            return this;
      -        }
      -        return copyWith(parameters);
      -    }
      -
      -    /**
      -     * Convenience method equivalent to {@link #addQueryData}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool param(Object key, Object value)
      -    {
      -        return addQueryData(String.valueOf(key), value);
      -    }
      -
      -    /**
      -     * Convenience method equivalent to
      -     * {@link #addQueryData(Map parameters)}.
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool params(Map parameters)
      -    {
      -        return addQueryData(parameters);
      -    }
      -
      -    /**
      -     * <p>Returns this link's query data as a url-encoded string e.g.
      -     * <code>key=value&foo=this+is+encoded</code>.</p>
      -     */
      -    public String getQueryData()
      -    {
      -        if (queryData != null && !queryData.isEmpty())
      -        {
      -
      -            StringBuffer out = new StringBuffer();
      -            for(int i=0; i < queryData.size(); i++)
      -            {
      -                out.append(queryData.get(i));
      -                if (i+1 < queryData.size())
      -                {
      -                    out.append(queryDataDelim);
      -                }
      -            }
      -            return out.toString();
      -        }
      -        return null;
      -    }
      -
      -    /**
      -     * Convenience method equivalent to
      -     * {@link #getQueryData()}.
      -     * @since VelocityTools 1.3
      -     */
      -    public String getParams()
      -    {
      -        return getQueryData();
      -    }
      -
      -
      -    /**
      -     * <p>Returns the URI that addresses this web application. E.g.
      -     * <code>http://myserver.net/myapp</code>. This string does not end
      -     * with a "/".  Note! This will not represent any URI reference or
      -     * query data set for this LinkTool.</p>
      -     */
      -    public String getContextURL()
      -    {
      -        String scheme = request.getScheme();
      -        int port = request.getServerPort();
      -
      -        StringBuffer out = new StringBuffer();
      -        out.append(request.getScheme());
      -        out.append("://");
      -        out.append(request.getServerName());
      -        if ((scheme.equals("http") && port != 80) ||
      -            (scheme.equals("https") && port != 443))
      -        {
      -            out.append(':');
      -            out.append(port);
      -        }
      -        out.append(request.getContextPath());
      -        return out.toString();
      -    }
      -
      -
      -    /**
      -     * <p>Returns the context path that addresses this web
      -     * application, e.g. <code>/myapp</code>. This string starts
      -     * with a "/" but does not end with a "/" Note! This will not
      -     * represent any URI reference or query data set for this
      -     * LinkTool.</p>
      -     */
      -    public String getContextPath()
      -    {
      -        return request.getContextPath();
      -    }
      -
      -
      -    /**
      -     * <p>Retrieves the path for the current request regardless of
      -     * whether this is a direct request or an include by the
      -     * RequestDispatcher. Note! This will not
      -     * represent any URI reference or query data set for this
      -     * LinkTool.</p>
      -     *
      -     * @since VelocityTools 1.3
      -     */
      -    public String getRequestPath()
      -    {
      -        return ServletUtils.getPath(request);
      +        setXHTML(useXhtml);
           }
      -
      -
      -    /**
      -     * Returns the full URI of this template without any query data.
      -     * e.g. <code>http://myserver.net/myapp/stuff/View.vm</code>
      -     * Note! The returned String will not represent any URI reference
      -     * or query data set for this LinkTool. A typical application of
      -     * this method is with the HTML base tag. For example:
      -     * <code>&lt;base href="$link.baseRef"&gt;</code>
      -     */
      -    public String getBaseRef()
      -    {
      -        StringBuffer out = new StringBuffer();
      -        out.append(getContextURL());
      -        out.append(getRequestPath());
      -        return out.toString();
      -    }
      -
      -
      -    /**
      -     * This method returns a new "self-referencing" LinkTool for the current
      -     * request. By default, this is merely a shortcut for calling
      -     * {@link #relative(String uri)} using the result of
      -     * {@link #getRequestPath()}.  However, this tool can be configured
      -     * to return an absolute URI and/or to include the parameters of the
      -     * current request (in addition to any others set so far).
      -     *
      -     * @see #uri(String uri)
      -     * @see #configure(Map params)
      -     * @see #setSelfAbsolute(boolean selfAbsolute)
      -     * @see #setSelfIncludeParameters(boolean selfParams)
      -     * @since VelocityTools 1.3
      -     */
      -    public LinkTool getSelf()
      -    {
      -        // first set the uri per configuration
      -        LinkTool dupe;
      -        if (this.selfAbsolute)
      -        {
      -            dupe = uri(getBaseRef());
      -        }
      -        else
      -        {
      -            dupe = relative(getRequestPath());
      -        }
      -
      -        // then add the params (if so configured)
      -        if (this.selfParams)
      -        {
      -            dupe.params(request.getParameterMap());
      -        }
      -        return dupe;
      -    }
      -
      -
      -    /**
      -     * Returns the full URI reference that's been built with this tool,
      -     * including the query string and anchor, e.g.
      -     * <code>http://myserver.net/myapp/stuff/View.vm?id=42&type=blue#foo</code>.
      -     * Typically, it is not necessary to call this method explicitely.
      -     * Velocity will call the toString() method automatically to obtain
      -     * a representable version of an object.
      -     */
      -    public String toString()
      -    {
      -        StringBuffer out = new StringBuffer();
      -
      -        if (uri != null)
      -        {
      -            out.append(uri);
      -        }
      -
      -        String query = getQueryData();
      -        if (query != null)
      -        {
      -            // Check if URI already contains query data
      -            if ( uri == null || uri.indexOf('?') < 0)
      -            {
      -                // no query data yet, start query data with '?'
      -                out.append('?');
      -            }
      -            else
      -            {
      -                // there is already query data, use data delimiter
      -                out.append(queryDataDelim);
      -            }
      -            out.append(query);
      -        }
      -
      -        if (anchor != null)
      -        {
      -            out.append('#');
      -            out.append(encodeURL(anchor));
      -        }
      -
      -        String str = out.toString();
      -        if (str.length() == 0)
      -        {
      -            // avoid a potential NPE from Tomcat's response.encodeURL impl
      -            return str;
      -        }
      -        else
      -        {
      -            // encode session ID into URL if sessions are used but cookies are
      -            // not supported
      -            return response.encodeURL(str);
      -        }
      -    }
      -
      -
      -    /**
      -     * Use the new URLEncoder.encode() method from java 1.4 if available, else
      -     * use the old deprecated version.  This method uses reflection to find the appropriate
      -     * method; if the reflection operations throw exceptions, this will return the url
      -     * encoded with the old URLEncoder.encode() method.
      -     *
      -     * @return String - the encoded url.
      -     */
      -    public String encodeURL(String url)
      -    {
      -        /* first try encoding with new 1.4 method */
      -        if (encode != null)
      -        {
      -            try
      -            {
      -                Object[] args =
      -                    new Object[] { url, this.response.getCharacterEncoding() };
      -                return (String)encode.invoke(null, args);
      -            }
      -            catch (IllegalAccessException e)
      -            {
      -                // don't keep trying if we get one of these
      -                encode = null;
      -
      -                LOG.debug("LinkTool : Can't access JDK 1.4 encode method."
      -                          + " Using deprecated version from now on.", e);
      -            }
      -            catch (InvocationTargetException e)
      -            {
      -                LOG.debug("LinkTool : Error using JDK 1.4 encode method."
      -                          + " Using deprecated version.", e);
      -            }
      -        }
      -        return URLEncoder.encode(url);
      -    }
      -
      -
      -
      -    // --------------------------------------------- Internal Class -----------
      -
      -    /**
      -     * Internal util class to handle representation and
      -     * encoding of key/value pairs in the query string
      -     */
      -    protected final class QueryPair
      -    {
      -
      -        private final String key;
      -        private final Object value;
      -
      -
      -        /**
      -         * Construct a new query pair.
      -         *
      -         * @param key query pair
      -         * @param value query value
      -         */
      -        public QueryPair(String key, Object value)
      -        {
      -            this.key = key;
      -            this.value = value;
      -        }
      -
      -        /**
      -         * Return the URL-encoded query string.
      -         */
      -        public String toString()
      -        {
      -            StringBuffer out = new StringBuffer();
      -            if (value == null)
      -            {
      -                out.append(encodeURL(key));
      -                out.append('=');
      -                /* Interpret null as "no value" */
      -            }
      -            else if (value instanceof List)
      -            {
      -                appendAsArray(out, key, ((List)value).toArray());
      -            }
      -            else if (value instanceof Object[])
      -            {
      -                appendAsArray(out, key, (Object[])value);
      -            }
      -            else
      -            {
      -                out.append(encodeURL(key));
      -                out.append('=');
      -                out.append(encodeURL(String.valueOf(value)));
      -            }
      -            return out.toString();
      -        }
      -
      -        /* Utility method to avoid logic duplication in toString() */
      -        private void appendAsArray(StringBuffer out, String key, Object[] arr)
      -        {
      -            String encKey = encodeURL(key);
      -            for (int i=0; i < arr.length; i++)
      -            {
      -                out.append(encKey);
      -                out.append('=');
      -                if (arr[i] != null)
      -                {
      -                    out.append(encodeURL(String.valueOf(arr[i])));
      -                }
      -                if (i+1 < arr.length)
      -                {
      -                    out.append(queryDataDelim);
      -                }
      -            }
      -        }
      -
      -    }
      -
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ParameterParser.java Mon Jun  4 17:24:29 2007
      @@ -19,144 +19,19 @@
        * under the License.
        */
       
      -import java.util.Map;
      -import javax.servlet.ServletRequest;
      -import org.apache.velocity.tools.config.DefaultKey;
      -import org.apache.velocity.tools.config.ValidScope;
      -import org.apache.velocity.tools.generic.ValueParser;
       import org.apache.velocity.tools.view.ViewContext;
       
       /**
      - * <p>Utility class for easy parsing of {@link ServletRequest} parameters.</p>
      - * <p><pre>
      - * Template example(s):
      - *   $params.foo                ->  bar
      - *   $params.getNumber('baz')   ->  12.6
      - *   $params.getInt('baz')      ->  12
      - *   $params.getNumbers('baz')  ->  [12.6]
      - *
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;params&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.ParameterParser&lt;/class&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * <p>When used as a view tool, this should only be used in the request scope.
      - * This class is, however, quite useful in your application's controller, filter,
      - * or action code as well as in templates.</p>
      - *
      - * @author Nathan Bubna
      - * @version $Revision$ $Date$
      + * Use {@link org.apache.velocity.tools.view.ParameterTool}
        */
      -@DefaultKey("params")
      -@ValidScope("request")
      -public class ParameterParser extends ValueParser
      +@Deprecated
      +public class ParameterParser extends org.apache.velocity.tools.view.ParameterTool
       {
      -    private ServletRequest request;
      -
      -    /**
      -     * Constructs a new instance
      -     */
      -    public ParameterParser()
      -    {}
      -
      -    /**
      -     * Constructs a new instance using the specified request.
      -     *
      -     * @param request the {@link ServletRequest} to be parsed
      -     */
      -    public ParameterParser(ServletRequest request)
      -    {
      -        setRequest(request);
      -    }
      -
           @Deprecated
           public void init(Object obj)
           {
      -        //Does nothing
      -    }
      -
      -    /**
      -     * Sets the current {@link ServletRequest}
      -     *
      -     * @param request the {@link ServletRequest} to be parsed
      -     */
      -    public void setRequest(ServletRequest request)
      -    {
      -        this.request = request;
      -    }
      -
      -    /**
      -     * Returns the current {@link ServletRequest} for this instance.
      -     *
      -     * @return the current {@link ServletRequest}
      -     * @throws UnsupportedOperationException if the request is null
      -     */
      -    protected ServletRequest getRequest()
      -    {
      -        if (request == null)
      -        {
      -            throw new UnsupportedOperationException("Request is null. ParameterParser must be initialized first!");
      +        if (obj instanceof ViewContext) {
      +            setRequest(((ViewContext)obj).getRequest());
               }
      -        return request;
      -    }
      -
      -    /**
      -     * Overrides ValueParser.getString(String key) to retrieve the
      -     * String from the ServletRequest instead of an arbitrary Map.
      -     *
      -     * @param key the parameter's key
      -     * @return parameter matching the specified key or
      -     *         <code>null</code> if there is no matching
      -     *         parameter
      -     */
      -    public String getString(String key)
      -    {
      -        return getRequest().getParameter(key);
           }
      -
      -
      -    /**
      -     * Overrides ValueParser.getString(String key) to retrieve
      -     * Strings from the ServletRequest instead of an arbitrary Map.
      -     *
      -     * @param key the key for the desired parameter
      -     * @return an array of String objects containing all of the values
      -     *         the given request parameter has, or <code>null</code>
      -     *         if the parameter does not exist
      -     */
      -    public String[] getStrings(String key)
      -    {
      -        return getRequest().getParameterValues(key);
      -    }
      -
      -    /**
      -     * Overrides ValueParser.setSource(Map source) to throw an
      -     * UnsupportedOperationException, because this class uses
      -     * a servlet request as its source, not a Map.
      -     */
      -    protected void setSource(Map source)
      -    {
      -        throw new UnsupportedOperationException();
      -    }
      -
      -    /**
      -     * Overrides ValueParser.getSource() to return the result
      -     * of getRequest().getParameterMap().
      -     */
      -    protected Map getSource()
      -    {
      -        return getRequest().getParameterMap();
      -    }
      -
      -    /**
      -     * Returns the map of all parameters available for the current request.
      -     */
      -    public Map getAll()
      -    {
      -        return getSource();
      -    }
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewRenderTool.java Mon Jun  4 17:24:29 2007
      @@ -20,72 +20,14 @@
        */
       
       import org.apache.velocity.context.Context;
      -import org.apache.velocity.tools.generic.RenderTool;
      -import org.apache.velocity.tools.view.ViewContext;
      -import org.apache.velocity.tools.config.InvalidScope;
       
       /**
      - * This tool expose methods to evaluate the given
      - * strings as VTL (Velocity Template Language)
      - * and automatically using the current context.
      - * <br />
      - * <pre>
      - * Example of eval():
      - *      Input
      - *      -----
      - *      #set( $list = [1,2,3] )
      - *      #set( $object = '$list' )
      - *      #set( $method = 'size()' )
      - *      $render.eval("${object}.$method")
      - *
      - *      Output
      - *      ------
      - *      3
      - *
      - * Example of recurse():
      - *      Input
      - *      -----
      - *      #macro( say_hi )hello world!#end
      - *      #set( $foo = '#say_hi()' )
      - *      #set( $bar = '$foo' )
      - *      $render.recurse('$bar')
      - *
      - *      Output
      - *      ------
      - *      hello world!
      - *
      - *
      - * Toolbox configuration:
      - * &lt;tool&gt;
      - *   &lt;key&gt;render&lt;/key&gt;
      - *   &lt;scope&gt;request&lt;/scope&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.ViewRenderTool&lt;/class&gt;
      - *   &lt;parameter name="parse.depth" value="10"/&gt;
      - * &lt;/tool&gt;
      - * </pre>
      - *
      - * <p>Ok, so these examples are really lame.  But, it seems like
      - * someone out there is always asking how to do stuff like this
      - * and we always tell them to write a tool.  Now we can just tell
      - * them to use this tool.</p>
      - *
      - * <p>This tool is NOT meant to be used in either application or
      - * session scopes of a servlet environment.</p>
      - *
      - * @author Nathan Bubna
      - * @version $Revision$ $Date$
      + * Use {@link org.apache.velocity.view.ViewRenderTool}
        */
      -@InvalidScope({"application","session"})
      -public class ViewRenderTool extends RenderTool
      +@Deprecated
      +public class ViewRenderTool extends
      +    org.apache.velocity.tools.view.ViewRenderTool
       {
      -    private Context context;
      -
      -    /**
      -     * Constructs a new instance
      -     */
      -    public ViewRenderTool()
      -    {}
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -94,50 +36,4 @@
                   setVelocityContext((Context)obj);
               }
           }
      -
      -    /**
      -     * Sets the current {@link Context}. This is required
      -     * for this tool to operate and will throw a NullPointerException
      -     * if this is not set or is set to {@code null}.
      -     */
      -    public void setVelocityContext(Context context)
      -    {
      -        if (context == null)
      -        {
      -            throw new NullPointerException("context must not be null");
      -        }
      -        this.context = context;
      -    }
      -
      -    /**
      -     * <p>Evaluates a String containing VTL using the current context,
      -     * and returns the result as a String.  If this fails, then
      -     * <code>null</code> will be returned.  This evaluation is not
      -     * recursive.</p>
      -     *
      -     * @param vtl the code to be evaluated
      -     * @return the evaluated code as a String
      -     */
      -    public String eval(String vtl) throws Exception
      -    {
      -        return eval(context, vtl);
      -    }
      -
      -
      -    /**
      -     * <p>Recursively evaluates a String containing VTL using the
      -     * current context, and returns the result as a String. It
      -     * will continue to re-evaluate the output of the last
      -     * evaluation until an evaluation returns the same code
      -     * that was fed into it.</p>
      -     *
      -     * @param vtl the code to be evaluated
      -     * @return the evaluated code as a String
      -     */
      -    public String recurse(String vtl) throws Exception
      -    {
      -        return recurse(context, vtl);
      -    }
      -
      -
       }

      Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java
      URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java?view=diff&rev=544331&r1=544330&r2=544331
      ==============================================================================
      --- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java (original)
      +++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ViewResourceTool.java Mon Jun  4 17:24:29 2007
      @@ -19,53 +19,15 @@
        * under the License.
        */
       
      -import javax.servlet.http.HttpServletRequest;
      -import org.apache.velocity.tools.config.InvalidScope;
      -import org.apache.velocity.tools.generic.ResourceTool;
       import org.apache.velocity.tools.view.ViewContext;
       
       /**
      - * <p>Tool for accessing ResourceBundles and formatting messages therein.</p>
      - * <p><pre>
      - * Template example(s):
      - *   $text.foo                      ->  bar
      - *   $text.hello.world              ->  Hello World!
      - *   #set( $otherText = $text.bundle('otherBundle') )
      - *   $otherText.foo                 ->  woogie
      - *   $otherText.bar                 ->  The args are {0} and {1}.
      - *   $otherText.bar.insert(4)       ->  The args are 4 and {1}.
      - *   $otherText.bar.insert(4,true)  ->  The args are 4 and true.
      - *
      - * Toolbox configuration example:
      - * &lt;tool&gt;
      - *   &lt;key&gt;text&lt;/key&gt;
      - *   &lt;class&gt;org.apache.velocity.tools.view.tools.ViewResourceTool&lt;/class&gt;
      - *   &lt;parameter name="bundles" value="resources,com.foo.moreResources"/&gt;
      - * &lt;/tool&gt;
      - * </pre></p>
      - *
      - * <p>This comes in very handy when internationalizing templates.
      - *    Note that the default resource bundle baseName is "resources", and
      - *    the default locale is the result of HttpServletRequest.getLocale().
      - *    The default bundle baseName can be overridden as shown above.
      - * </p>
      - * <p>Also, be aware that very few performance considerations have been made
      - *    in this initial version.  It should do fine, but if you have performance
      - *    issues, please report them to dev@velocity.apache.org, so we can make
      - *    improvements.
      - * </p>
      - *
      - * <p>This tool is NOT meant to be used in either application or
      - * session scopes of a servlet environment.</p>
      - *
      - * @author Nathan Bubna
      - * @version $Revision$ $Date: 2006-11-27 10:49:37 -0800 (Mon, 27 Nov 2006) $
      - * @since VelocityTools 1.3
      + * Use {@link org.apache.velocity.tools.view.ViewResourceTool}
        */
      -@InvalidScope({"application","session"})
      -public class ViewResourceTool extends ResourceTool
      +@Deprecated
      +public class ViewResourceTool extends
      +    org.apache.velocity.tools.view.ViewResourceTool
       {
      -
           @Deprecated
           public void init(Object obj)
           {
      @@ -74,18 +36,4 @@
                   setRequest(((ViewContext)obj).getRequest());
               }
           }
      -
      -    /**
      -     * Sets the current {@link ServletRequest}
      -     *
      -     * @param request the {@link ServletRequest} to retrieve the default Locale from
      -     */
      -    public void setRequest(HttpServletRequest request)
      -    {
      -        if (request != null)
      -        {
      -            setDefaultLocale(request.getLocale());
      -        }
      -    }
      -
       }





      -- 
      No virus found in this incoming message.
      Checked by AVG Free Edition. 
      Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47




  ------------------------------------------------------------------------------


    No virus found in this incoming message.
    Checked by AVG Free Edition. 
    Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 3/6/2007 12:47



------------------------------------------------------------------------------


  No virus found in this incoming message.
  Checked by AVG Free Edition. 
  Version: 7.5.472 / Virus Database: 269.8.9/834 - Release Date: 5/6/2007 14:38

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message