You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/01/08 05:27:30 UTC
cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/interaction/src/java/org/apache/commons/jelly/tags/interaction package.html InteractionTagLibrary.java AskTag.java
dion 2003/01/07 20:27:30
Added: jelly/jelly-tags/interaction .cvsignore project.xml
maven.xml project.properties
jelly/jelly-tags/interaction/src/java/org/apache/commons/jelly/tags/interaction
package.html InteractionTagLibrary.java AskTag.java
Log:
Move interaction out of the core
Revision Changes Path
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/.cvsignore
Index: .cvsignore
===================================================================
maven.log
target
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [
<!-- see file for description -->
<!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
]>
<project>
<extend>../tag-project.xml</extend>
<id>commons-jelly-tags-interaction</id>
<name>commons-jelly-tags-interaction</name>
<package>org.apache.commons.jelly.tags.interaction</package>
<description>
This is a Jelly interface to the user.
</description>
<shortDescription>Commons Jelly Interaction Tag Library</shortDescription>
<siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/tags/interaction</siteDirectory>
<distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/interaction</distributionDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/interaction/</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/interaction/</url>
</repository>
<dependencies>
&commonDeps;
<!-- START for compilation -->
<dependency>
<id>commons-jelly</id>
<version>SNAPSHOT</version>
</dependency>
</dependencies>
</project>
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/maven.xml
Index: maven.xml
===================================================================
<project default="java:jar">
</project>
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/project.properties
Index: project.properties
===================================================================
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
maven.junit.fork=true
maven.compile.deprecation = on
# Installation dir
maven.dist.install.dir = /usr/local/jelly
maven.checkstyle.properties=../tag-checkstyle.properties
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/src/java/org/apache/commons/jelly/tags/interaction/package.html
Index: package.html
===================================================================
<html>
<head>
</head>
<body>
<p>A simple interaction tag library so that Jelly scripts can be interactive.
</p>
</body>
</html>
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/src/java/org/apache/commons/jelly/tags/interaction/InteractionTagLibrary.java
Index: InteractionTagLibrary.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.commons.jelly.tags.interaction;
import org.apache.commons.jelly.TagLibrary;
/**
* A TagLibrary to interact with the user.
* @author <a href="mailto:smor@hasgard.net">St�phane MOR</a>
*/
public class InteractionTagLibrary extends TagLibrary {
/**
* Registers all the Tags.
*/
public InteractionTagLibrary() {
registerTag("ask", AskTag.class);
}
}
1.1 jakarta-commons-sandbox/jelly/jelly-tags/interaction/src/java/org/apache/commons/jelly/tags/interaction/AskTag.java
Index: AskTag.java
===================================================================
/**
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* $Id: AskTag.java,v 1.1 2003/01/08 04:27:30 dion Exp $
*/
package org.apache.commons.jelly.tags.interaction;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
/**
* Jelly Tag that asks the user a question, and puts his answer into
* a variable, with the attribute "answer".
* This variable may be reused further as any other Jelly variable.
* @author <a href="mailto:smor@hasgard.net">St�phane Mor</a>
*/
public class AskTag extends TagSupport
{
/** The question to ask to the user */
private String question;
/**
* The variable in which we will stock the user's input.
* This defaults to "interact.answer".
*/
private String answer = "interact.answer";
/** The default value, if the user doesn't answer */
private String defaultInput;
/** The user's input */
private String input = "";
/** The prompt to display before the user input */
private String prompt = ">";
/**
* Sets the question to ask to the user. If a "default" attribute
* is present, it will appear inside [].
* @param question The question to ask to the user
*/
public void setQuestion(String question)
{
this.question = question;
}
/**
* Sets the name of the variable that will hold the answer
* This defaults to "interact.answer".
* @param answer the name of the variable that will hold the answer
*/
public void setAnswer(String answer)
{
this.answer = answer;
}
/**
* Sets the default answer to the question.
* If it is present, it will appear inside [].
* @param default the default answer to the question
*/
public void setDefault(String defaultInput)
{
this.defaultInput = defaultInput;
}
/**
* Sets the prompt that will be displayed before the user's input.
* @param promt the prompt that will be displayed before the user's input.
*/
public void setPrompt(String prompt)
{
this.prompt = prompt;
}
/**
* Perform functionality provided by the tag
* @param output the place to write output
*/
public void doTag(XMLOutput output)
{
if (question != null)
{
if (defaultInput != null)
{
System.out.println(question + " [" + defaultInput + "]");
}
else
{
System.out.println(question);
}
// The prompt should be just before the user's input,
// but it doesn't work ...
//System.out.print(prompt + " ");
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
input = br.readLine();
if (defaultInput != null && input.trim().equals(""))
{
input = defaultInput;
}
} catch (IOException ioe) {
}
context.setVariable(answer, input);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>