cmlenz 01/09/18 06:31:23
Added: src/taglib/common/org/apache/slide/taglib/tag
DomainTagSupport.java NamespaceTagSupport.java
NodeTagSupport.java PropertyTagSupport.java
RevisionTagSupport.java
Log:
Initial commit of the abstract tag-support classes for the forthcoming
tag library
Revision Changes Path
1.1
jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/DomainTagSupport.java
Index: DomainTagSupport.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/DomainTagSupport.java,v
1.1 2001/09/18 13:31:23 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/09/18 13:31:23 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.taglib.tag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.slide.taglib.bean.DomainBean;
/**
* Abstract foundation for tags that represent the Slide domain, and expose
* a {@link org.apache.slide.taglib.bean.DomainBean DomainBean} as scripting
* variable.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
* @version $Revision: 1.1 $
*/
public abstract class DomainTagSupport
extends TagSupport {
// ----------------------------------------------------- Instance Variables
/**
* The bean that encapsulates the Slide domain.
*/
protected DomainBean domain;
/**
* Name of the PageContext attribute under which the bean should be stored.
*/
protected String attrName;
// ----------------------------------------------------------- Construction
/**
* Initialize inherited and local state.
*/
public DomainTagSupport() {
super();
init();
}
// ------------------------------------------------------------ Tag Methods
/**
* Called by the JSP Engine when opening this tag.
*
* @throws JspException never thrown
*/
public int doStartTag()
throws JspException {
super.doStartTag();
if (domain != null) {
if (attrName != null) {
pageContext.setAttribute(attrName, domain);
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
/**
* Called by the JSP Engine when closing of this tag.
*
* @throws JspException never thrown
*/
public int doEndTag()
throws JspException {
super.doEndTag();
if (attrName != null) {
pageContext.removeAttribute(attrName);
}
return EVAL_PAGE;
}
/**
* Releases any resources we may have (or inherit).
*/
public void release() {
super.release();
init();
}
// --------------------------------------------------------- Public Methods
/**
* Returns the bean that represents the Slide domain.
*
* @return the DomainBean
*/
public DomainBean getDomain() {
return domain;
}
// -------------------------------------------------------- Private Methods
/**
* Reset internal state.
*/
private void init() {
domain = null;
attrName = null;
}
}
1.1
jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/NamespaceTagSupport.java
Index: NamespaceTagSupport.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/NamespaceTagSupport.java,v
1.1 2001/09/18 13:31:23 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/09/18 13:31:23 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.taglib.tag;
import javax.servlet.ServletContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.slide.taglib.bean.DomainBean;
import org.apache.slide.taglib.bean.NamespaceBean;
/**
* Abstract foundation for tags that serve to select a namespace of the Slide
* domain, and expose a
* {@link org.apache.slide.taglib.bean.NamespaceBean NamespaceBean} as
* scripting variable.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
* @version $Revision: 1.1 $
*/
public abstract class NamespaceTagSupport
extends TagSupport {
// ----------------------------------------------------- Instance Variables
/**
* The associated bean that represents the namespace chosen by the
* namespace tag, and that will optionally be put in the PageContext
* attributes.
*/
protected NamespaceBean namespace;
/**
* Value of 'name' tag attribute, which specifies the name of the
* namespace to choose.
*/
protected String name;
/**
* Name of the PageContext attribute under which the bean should be stored.
*/
protected String attrName;
// ----------------------------------------------------------- Construction
/**
* Initialize inherited and local state.
*/
public NamespaceTagSupport() {
super();
init();
}
// ------------------------------------------------------------ Tag Methods
/**
* Called by the JSP Engine when opening this tag.
*
* @throws JspException If this tag isn't nested inside a NodeTag or a
* NodeWrapper iteration
*/
public int doStartTag()
throws JspException {
if (namespace != null) {
if (attrName != null) {
pageContext.setAttribute(attrName, namespace);
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
/**
* Called by the JSP Engine when closing of this tag.
*
* @throws JspException Not thrown
*/
public int doEndTag()
throws JspException {
if (attrName != null) {
pageContext.removeAttribute(attrName);
}
return EVAL_PAGE;
}
/**
* Releases any resources we may have (or inherit).
*/
public void release() {
super.release();
init();
}
// ------------------------------------------------------------- Properties
/**
* Returns the 'name' attribute.
*
* @return the value of the 'name' attribute
*/
public String getName() {
return name;
}
/**
* Sets the 'name' attribute.
*
* @param name the attribute value
*/
public void setName(String name) {
this.name = name;
}
// --------------------------------------------------------- Public Methods
/**
* Returns the NamespaceBean.
*
* @return the namespace bean
*/
public NamespaceBean getNamespace() {
return namespace;
}
// ------------------------------------------------------ Protected Methods
/**
* Convenience method to support subclasses in retrieving the chosen
* namespace, and wrapping it in a
* {@link org.apache.slide.taglib.bean.NamespaceBean NamespaceBean}.
*
* @param domain the bean representing the domain
* @param name the name of the namespace
*/
protected NamespaceBean getNamespace(DomainBean domain, String name) {
NamespaceBean bean = null;
if (name == null) {
// look for a 'namespace' context parameter, and use its value
// as namespace name if present
ServletContext context = pageContext.getServletContext();
name = context.getInitParameter("namespace");
}
if (name == null) {
// use the default namespace
name = domain.getDefaultNamespaceName();
}
if (name != null) {
bean = domain.getNamespace(name);
}
return bean;
}
// -------------------------------------------------------- Private Methods
/**
* Reset internal state.
*/
private void init() {
namespace = null;
name = null;
attrName = null;
}
}
1.1
jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/NodeTagSupport.java
Index: NodeTagSupport.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/NodeTagSupport.java,v
1.1 2001/09/18 13:31:23 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/09/18 13:31:23 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.taglib.tag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.slide.common.SlideException;
import org.apache.slide.taglib.bean.NamespaceBean;
import org.apache.slide.taglib.bean.NodeBean;
/**
* Abstract foundation for tags that serve to select a particular
* <code>ObjectNode</code> in a Slide namespace (identified by the node's URI),
* and expose a corresponding
* {@link org.apache.slide.taglib.bean.NodeBean NodeBean} as scripting
* variable.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
* @version $Revision: 1.1 $
*/
public abstract class NodeTagSupport
extends TagSupport {
// ----------------------------------------------------- Instance Variables
/**
* The associated bean that will be put in the PageContext attributes.
*/
protected NodeBean node;
/**
* Value of 'uri' attribute.
*/
protected String uri;
/**
* Value of 'resolveLinks' attribute.
*/
protected String resolveLinks;
/**
* Name of the PageContext attribute under which the bean should be stored.
*/
protected String attrName;
// ----------------------------------------------------------- Construction
/**
* Initialize inherited and local state.
*/
public NodeTagSupport() {
super();
init();
}
// ------------------------------------------------------------ Tag Methods
/**
* Called by the JSP Engine when opening this tag.
*
* @throws JspException not thrown
*/
public int doStartTag()
throws JspException {
super.doStartTag();
if (node != null) {
if (attrName != null) {
pageContext.setAttribute(attrName, node);
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
/**
* Called by the JSP Engine when closing of this tag.
*
* @throws JspException not thrown
*/
public int doEndTag()
throws JspException {
super.doEndTag();
if (attrName != null) {
pageContext.removeAttribute(attrName);
}
return EVAL_PAGE;
}
/**
* Releases any resources we may have (or inherit).
*/
public void release() {
super.release();
init();
}
// ------------------------------------------------------------- Properties
/**
* Returns the 'resolveLinks' attribute.
*
* @return value of the 'resolveLinks' attribute
*/
public String getResolveLinks() {
return resolveLinks;
}
/**
* Sets the 'resolveLinks' attribute.
*
* @param resolveLinks the attribute value
*/
public void setResolveLinks(String resolveLinks) {
this.resolveLinks = resolveLinks;
}
/**
* Returns the 'uri' attribute.
*
* @return value of the 'uri' attribute
*/
public String getUri() {
return uri;
}
/**
* Sets the 'uri' attribute.
*
* @param uri the attribute value
*/
public void setUri(String uri) {
this.uri = uri;
}
// --------------------------------------------------------- Public Methods
/**
* Returns the bean representing the node selected by this tag.
*
* @return the NodeBean
*/
public NodeBean getNode() {
return node;
}
// ------------------------------------------------------ Protected Methods
/**
* Convenience method to support subclasses in retrieving the chosen node
* from the namespace, and wrapping it in a
* {@link org.apache.slide.taglib.bean.NodeBean NodeBean}.
*
* @param namespace the bean that represents the selected namespace
* @param uri the URI of the node to retrieve
* @param resolveLinks whether to resolve links when retrieving the node
*/
protected NodeBean getNode(
NamespaceBean namespace,
String uri,
boolean resolveLinks) {
NodeBean bean = null;
if ((namespace != null) && (uri != null)) {
try {
bean = namespace.getNode(uri, resolveLinks);
} catch (SlideException e) {
// ignore for now
}
}
return bean;
}
// -------------------------------------------------------- Private Methods
/**
* Reset internal state.
*/
private void init() {
node = null;
uri = null;
resolveLinks = null;
attrName = null;
}
}
1.1
jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/PropertyTagSupport.java
Index: PropertyTagSupport.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/PropertyTagSupport.java,v
1.1 2001/09/18 13:31:23 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/09/18 13:31:23 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.taglib.tag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.slide.common.SlideException;
import org.apache.slide.taglib.bean.PropertyBean;
import org.apache.slide.taglib.bean.RevisionBean;
/**
* Abstract foundation for tags that serve to select a particular property of
* a revision, and expose a corresponding
* {@link org.apache.slide.taglib.bean.PropertyBean PropertyBean} as scripting
* variable.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
* @version $Revision: 1.1 $
**/
public abstract class PropertyTagSupport
extends TagSupport {
// ----------------------------------------------------- Instance Variables
/**
* The associated bean that will be put in the PageContext attributes.
**/
protected PropertyBean property;
/**
* Value of 'namespace' attribute.
**/
protected String namespace;
/**
* Value of 'name' attribute.
**/
protected String name;
/**
* Name of the PageContext attribute under which the bean is stored.
**/
protected String attrName;
// ----------------------------------------------------------- Construction
/**
* Initialize inherited and local state.
**/
public PropertyTagSupport() {
super();
init();
}
// ------------------------------------------------------------ Tag Methods
/**
* Called by the JSP Engine when opening this tag.
*
* @throws JspException not thrown
**/
public int doStartTag()
throws JspException {
super.doStartTag();
if (property != null) {
if (attrName != null) {
pageContext.setAttribute(attrName, property);
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
/**
* Called by the JSP Engine when closing of this tag.
*
* @throws JspException not thrown
**/
public int doEndTag()
throws JspException {
super.doEndTag();
if (attrName != null) {
pageContext.removeAttribute(attrName);
}
return EVAL_PAGE;
}
/**
* Releases any resources we may have (or inherit).
**/
public void release() {
super.release();
init();
}
// ------------------------------------------------------------- Properties
/**
* Returns the 'namespace' attribute.
*
* @return the attribute value
**/
public String getNamespace() {
return namespace;
}
/**
* Sets the 'namespace' attribute.
*
* @param namespace the attribute value
**/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Returns the 'name' attribute.
*
* @return the attribute value
**/
public String getName() {
return name;
}
/**
* Sets the 'name' attribute.
*
* @param branch the attribute value
**/
public void setName(String name) {
this.name = name;
}
// --------------------------------------------------------- Public Methods
/**
* Returns the PropertyBean.
*
* @return the property bean
**/
public PropertyBean getProperty() {
return property;
}
// ------------------------------------------------------ Protected Methods
/**
* Convenience method to support subclasses in getting the chosen property
* from a revision, and wrapping it in a
* {@link org.apache.slide.taglib.bean.PropertyBean PropertyBean}.
*
* @param revision the revision of which the property should be retrieved
* @param name the (local) name of the property
* @param namespace the namespace of the property, or <code>null</code> to
* use the default namespace ("DAV:")
**/
protected PropertyBean getProperty(
RevisionBean revision,
String name,
String namespace) {
PropertyBean bean = null;
if (revision != null) {
bean = revision.getProperty(name, namespace);
}
return bean;
}
// -------------------------------------------------------- Private Methods
/**
* Reset internal state.
*/
private void init() {
property = null;
namespace = null;
name = null;
attrName = null;
}
}
1.1
jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/RevisionTagSupport.java
Index: RevisionTagSupport.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/taglib/common/org/apache/slide/taglib/tag/RevisionTagSupport.java,v
1.1 2001/09/18 13:31:23 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/09/18 13:31:23 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.taglib.tag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.slide.common.SlideException;
import org.apache.slide.content.NodeRevisionNumber;
import org.apache.slide.taglib.bean.NodeBean;
import org.apache.slide.taglib.bean.RevisionBean;
/**
* Abstract foundation for tags that serve to select a revision of an object,
* and expose a corresponding
* {@link org.apache.slide.taglib.bean.RevisionBean RevisionBean} as scripting
* variable.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
* @version $Revision: 1.1 $
*/
public abstract class RevisionTagSupport
extends TagSupport {
// ----------------------------------------------------- Instance Variables
/**
* The associated bean that will be put in the PageContext attributes.
*/
protected RevisionBean revision;
/**
* Value of 'number' attribute.
*/
protected String number;
/**
* Value of 'branch' attribute.
*/
protected String branch;
/**
* Name of the PageContext attribute under which the bean is stored.
*/
protected String attrName;
// ----------------------------------------------------------- Construction
/**
* Initialize inherited and local state.
*/
public RevisionTagSupport() {
super();
init();
}
// ------------------------------------------------------------ Tag Methods
/**
* Called by the JSP Engine when opening this tag.
*
* @throws JspException If this tag isn't nested inside a NodeTag or a
* NodeWrapper iteration
*/
public int doStartTag()
throws JspException {
super.doStartTag();
if (revision != null) {
if (attrName != null) {
pageContext.setAttribute(attrName, revision);
}
return EVAL_BODY_INCLUDE;
}
return SKIP_BODY;
}
/**
* Called by the JSP Engine when closing of this tag.
*
* @throws JspException Not thrown
*/
public int doEndTag()
throws JspException {
super.doEndTag();
if (attrName != null) {
pageContext.removeAttribute(attrName);
}
return EVAL_PAGE;
}
/**
* Releases any resources we may have (or inherit).
*/
public void release() {
super.release();
init();
}
// ------------------------------------------------------------- Properties
/**
* Returns the 'number' attribute.
*
* @return the attribute value
*/
public String getNumber() {
return number;
}
/**
* Sets the 'number' attribute.
*
* @param number the attribute value
*/
public void setNumber(String number) {
this.number = number;
}
/**
* Returns the 'branch' attribute.
*
* @return the attribute value
*/
public String getBranch() {
return branch;
}
/**
* Sets the 'branch' attribute.
*
* @param branch the attribute value
*/
public void setBranch(String branch) {
this.branch = branch;
}
// --------------------------------------------------------- Public Methods
/**
* Returns the RevisionBean.
*
* @return the revision bean
*/
public RevisionBean getRevision() {
return revision;
}
// ------------------------------------------------------ Protected Methods
/**
* Convenience method to support subclasses in getting a specific revision
* of a node, and wrapping it in a
* {@link org.apache.slide.taglib.bean.RevisionBean RevisionBean}.
*
* <p>Either specify the <code>number</code> or the <code>branch</code>
* argument. If both are specified, the <code>number</code> argument takes
* precedence.</p>
*
* @param node the node of which the revision should be retrieved
* @param number version number of the revision to retrieve
* @param branch name of the branch of which to retrieve the latest
* revision
*/
protected RevisionBean getRevision(
NodeBean node,
NodeRevisionNumber number,
String branch) {
RevisionBean bean = null;
if (number != null) {
bean = node.getRevision(number);
} else if ((branch != null) && (branch.length() > 0)) {
bean = node.getRevision(branch);
} else {
bean = node.getLatestRevision();
}
return bean;
}
// -------------------------------------------------------- Private Methods
/**
* Reset internal state.
*/
private void init() {
revision = null;
number = null;
branch = null;
attrName = null;
}
}