| ActionResult.java |
/*
PCS - A Framework For Java Web Applications
Copyright (C) 2002 Patrick Carl, patrick.carl@web.de
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: ActionResult.java,v 1.3 2003/01/19 23:41:36 pcs_org Exp $
*/
package de.spieleck.pcs.action;
import java.io.StringReader;
import java.util.Hashtable;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
/**
* This class represents the result of a performed Action.
* An ActionResult consists of an XML representation and additional
* properties carried in a Hashtable
* @see Action
* @author Patrick Carl
*/
public class ActionResult {
private String xml;
private Hashtable parameters;
/** Holds value of property source. */
private Source source;
/** Holds value of property styleSheet. */
private String styleSheet;
/** Creates a new instance of ActionResult */
public ActionResult() {
setXml(null);
setParameters(new Hashtable());
}
/**
* Creates an instance of ActionResult with the given properties
* @param xml a XML-Source representing the ActionResult
* @param parameters the additional parameters of the ActionResult
* as a Hashtable
* @param styleSheetKey key to lookup stylesheet for transformation
*/
public ActionResult(String xml, Hashtable parameters){
setXml(xml);
setParameters(parameters);
}
/**
* creates an ActionResult with the given values
*/
public ActionResult(String xml, Hashtable parameters, String styleSheet){
this(xml, parameters);
setStyleSheet(styleSheet);
}
/**
* creates an ActionResult with the given values
*/
public ActionResult(Source source, Hashtable parameters){
setSource(source);
setParameters(parameters);
}
/**
* creates an ActionResult with the given values
*/
public ActionResult(Source source, Hashtable parameters, String styleSheet){
this(source, parameters);
setStyleSheet(styleSheet);
}
/**
* convenience method for setting the ActionResult's XML data with an
* StreamSource using the given String as input
* @since 1.1
*/
public void setXml(String xml) {
this.xml = xml;
if(xml != null)
setSource(new StreamSource(new StringReader(xml)));
else
setSource(null);
}
/**
* returns the xml data of the ActionResult as a String
* @deprecated use getSource() instead
* @since 1.1
*/
public String getXml() {
return xml;
}
/**
* returns the parameters of this ActionResult as a Hashtable
*/
public Hashtable getParameters() {
return parameters;
}
/**
* sets the parameters of this ActionResult
*/
public void setParameters(Hashtable parameters) {
this.parameters = parameters;
}
/** Getter for property source.
* @return Value of property source.
*
*/
public Source getSource() {
return this.source;
}
/** Setter for property source.
* @param source New value of property source.
*
*/
public void setSource(Source source) {
this.source = source;
}
/** returns the name of the stylesheet to be used with this ActionResult, can be
* used for variable stylesheets (e.g. display the Results in a table overview or
* in detail) and to overwrite the stylesheet setting of the service
* @see de.spieleck.pcs.http.Service
* @see de.spieleck.pcs.view.View
* @return Value of property styleSheet.
*/
public String getStyleSheet() {
return this.styleSheet;
}
/** sets the name of the stylesheet to be used with this ActionResult
* @param styleSheet New value of property styleSheet.
*
*/
public void setStyleSheet(String styleSheet) {
this.styleSheet = styleSheet;
}
}| ActionResult.java |