dgraham 2003/07/01 19:13:53 Modified: src/share/org/apache/struts/tiles DirectStringAttribute.java PathAttribute.java DefinitionNameAttribute.java DefinitionAttribute.java src/share/org/apache/struts/taglib/tiles DefinitionTag.java PutListTag.java src/share/org/apache/struts/tiles/xmlDefinition XmlAttribute.java Log: Formatted to Struts standard in preparation for UntyppedAttribute to UntypedAttribute change. Revision Changes Path 1.3 +10 -12 jakarta-struts/src/share/org/apache/struts/tiles/DirectStringAttribute.java Index: DirectStringAttribute.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DirectStringAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DirectStringAttribute.java 5 Jan 2003 01:24:48 -0000 1.2 +++ DirectStringAttribute.java 2 Jul 2003 02:13:53 -0000 1.3 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,18 +59,16 @@ * */ - package org.apache.struts.tiles; - /** - * Component attribute. - * Such attribute value represent a path used to include a JSP. - */ +/** + * Component attribute. + * Such attribute value represent a path used to include a JSP. + */ public class DirectStringAttribute extends UntyppedAttribute { - public DirectStringAttribute( String value ) - { - super(value); + public DirectStringAttribute(String value) { + super(value); } } 1.4 +10 -12 jakarta-struts/src/share/org/apache/struts/tiles/PathAttribute.java Index: PathAttribute.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/PathAttribute.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PathAttribute.java 27 Feb 2003 19:20:51 -0000 1.3 +++ PathAttribute.java 2 Jul 2003 02:13:53 -0000 1.4 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,18 +59,16 @@ * */ - package org.apache.struts.tiles; - /** - * Component attribute. - * Attribute value represents a path used to include a JSP. - */ +/** + * Component attribute. + * Attribute value represents a path used to include a JSP. + */ public class PathAttribute extends UntyppedAttribute { - public PathAttribute( String value ) - { - super(value); + public PathAttribute(String value) { + super(value); } } 1.3 +13 -15 jakarta-struts/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java Index: DefinitionNameAttribute.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefinitionNameAttribute.java 5 Jan 2003 01:24:48 -0000 1.2 +++ DefinitionNameAttribute.java 2 Jul 2003 02:13:53 -0000 1.3 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,28 +59,26 @@ * */ - package org.apache.struts.tiles; - /** - * Component attribute. - * Such attribute value represent an instance name. - */ +/** + * Component attribute. + * Such attribute value represent an instance name. + */ public class DefinitionNameAttribute extends UntyppedAttribute { + /** * Constructor. */ - public DefinitionNameAttribute( String value ) - { - super( value); + public DefinitionNameAttribute(String value) { + super(value); } /** * Constructor. */ - public DefinitionNameAttribute( String value ,String role) - { - super(value, role); + public DefinitionNameAttribute(String value, String role) { + super(value, role); } } 1.3 +10 -12 jakarta-struts/src/share/org/apache/struts/tiles/DefinitionAttribute.java Index: DefinitionAttribute.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefinitionAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefinitionAttribute.java 5 Jan 2003 01:24:48 -0000 1.2 +++ DefinitionAttribute.java 2 Jul 2003 02:13:53 -0000 1.3 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,18 +59,16 @@ * */ - package org.apache.struts.tiles; - /** - * Attribute representing a Component Definition. - * This attribute definition contains a Component definition. - */ +/** + * Attribute representing a Component Definition. + * This attribute definition contains a Component definition. + */ public class DefinitionAttribute extends UntyppedAttribute { - public DefinitionAttribute( String value ) - { - super( value); + public DefinitionAttribute(String value) { + super(value); } } 1.7 +121 -137 jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java Index: DefinitionTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefinitionTag.java 27 Feb 2003 19:18:55 -0000 1.6 +++ DefinitionTag.java 2 Jul 2003 02:13:53 -0000 1.7 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,7 +59,6 @@ * */ - package org.apache.struts.taglib.tiles; import javax.servlet.jsp.JspException; @@ -77,64 +76,60 @@ * @author Cedric Dumoulin * @version $Revision$ $Date$ */ -public class DefinitionTag extends DefinitionTagSupport implements PutTagParent, PutListTagParent -{ - /** Commons Logging instance. */ - //protected static Log log = LogFactory.getLog(DefinitionTag.class); +public class DefinitionTag + extends DefinitionTagSupport + implements PutTagParent, PutListTagParent { /* JSP Tag attributes */ /** * Definition identifier. */ - private String id; + private String id = null; /** * Scope into which definition will be saved. */ - private String scope; + private String scope = null; /** * Extends attribute value. */ - private String extendsDefinition; + private String extendsDefinition = null; /* Internal properties */ /** * Template definition */ - private ComponentDefinition definition; + private ComponentDefinition definition = null; /** * Reset member values for reuse. This method calls super.release(), * which invokes TagSupport.release(), which typically does nothing. */ - public void release() - { - super.release(); - id = null; - page = null; - scope = null; - role = null; - extendsDefinition = null; + public void release() { + super.release(); + id = null; + page = null; + scope = null; + role = null; + extendsDefinition = null; } /** * Release internal references. */ - protected void releaseInternal() - { - definition = null; + protected void releaseInternal() { + definition = null; } - /** + /** * This method is a convenience for other tags for * putting content into the tile definition. * Content is already typed by caller. */ - public void putAttribute(String name, Object content) - { - definition.putAttribute(name, content); - } + public void putAttribute(String name, Object content) { + definition.putAttribute(name, content); + } /** * Process nested ≶put> tag. @@ -143,29 +138,25 @@ * If role is defined, nested attribute is wrapped into an untyped definition * containing attribute value and role. */ - public void processNestedTag(PutTag nestedTag) throws JspException - { - // Get real value and check role - // If role is set, add it in attribute definition if any. - // If no attribute definition, create untyped one and set role. - Object attributeValue = nestedTag.getRealValue(); - AttributeDefinition def; - - if( nestedTag.getRole() != null ) - { - try - { - def = ((AttributeDefinition)attributeValue); + public void processNestedTag(PutTag nestedTag) throws JspException { + // Get real value and check role + // If role is set, add it in attribute definition if any. + // If no attribute definition, create untyped one and set role. + Object attributeValue = nestedTag.getRealValue(); + AttributeDefinition def; + + if (nestedTag.getRole() != null) { + try { + def = ((AttributeDefinition) attributeValue); + } catch (ClassCastException ex) { + def = new UntyppedAttribute(attributeValue); + } + def.setRole(nestedTag.getRole()); + attributeValue = def; } - catch( ClassCastException ex ) - { - def = new UntyppedAttribute( attributeValue ); - } - def.setRole(nestedTag.getRole()); - attributeValue = def; - } // end if - // now add attribute to enclosing parent (i.e. : this object) - putAttribute( nestedTag.getName(), attributeValue); + + // now add attribute to enclosing parent (i.e. : this object) + putAttribute(nestedTag.getName(), attributeValue); } /** @@ -175,119 +166,112 @@ * If role is defined, nested attribute is wrapped into an untyped definition * containing attribute value and role. */ - public void processNestedTag(PutListTag nestedTag) throws JspException - { - // Get real value and check role - // If role is set, add it in attribute definition if any. - // If no attribute definition, create untyped one and set role. - Object attributeValue = nestedTag.getList(); - - if( nestedTag.getRole() != null ) - { - AttributeDefinition def = new UntyppedAttribute( attributeValue ); - def.setRole(nestedTag.getRole()); - attributeValue = def; - } // end if - // Check if a name is defined - if( nestedTag.getName() == null) - throw new JspException( "Error - PutList : attribute name is not defined. It is mandatory as the list is added to a 'definition'." ); - // now add attribute to enclosing parent (i.e. : this object). - putAttribute(nestedTag.getName(), attributeValue); + public void processNestedTag(PutListTag nestedTag) throws JspException { + // Get real value and check role + // If role is set, add it in attribute definition if any. + // If no attribute definition, create untyped one and set role. + Object attributeValue = nestedTag.getList(); + + if (nestedTag.getRole() != null) { + AttributeDefinition def = new UntyppedAttribute(attributeValue); + def.setRole(nestedTag.getRole()); + attributeValue = def; + } + + // Check if a name is defined + if (nestedTag.getName() == null) { + throw new JspException("Error - PutList : attribute name is not defined. It is mandatory as the list is added to a 'definition'."); + } + + // now add attribute to enclosing parent (i.e. : this object). + putAttribute(nestedTag.getName(), attributeValue); } /** * Get the ID. * @return ID */ - public String getId() - { - return id; + public String getId() { + return id; } /** * Set the ID. * @param id New ID. */ - public void setId(String id) - { - this.id = id; + public void setId(String id) { + this.id = id; } /** * Get the scope. * @return Scope. */ - public String getScope() - { - return scope; + public String getScope() { + return scope; } /** * Set the scope. * @param aScope Scope. */ - public void setScope(String aScope) - { - scope = aScope; - } - - /** - * Set <code>extends</code> (parent) definition name. - * @param definitionName Name of parent definition. - */ - public void setExtends(String definitionName) - { - this.extendsDefinition = definitionName; - } - - /** - * Get <code>extends</code> (parent) definition name. - * @return Name of parent definition. - */ - public String getExtends() - { - return extendsDefinition; - } - - /** - * Process the start tag by creating a new definition. - * @throws JspException On errors processing tag. - */ - public int doStartTag() throws JspException - { - // Do we extend a definition ? - if( extendsDefinition != null && !extendsDefinition.equals("") ) - { - ComponentDefinition parentDef = TagUtils.getComponentDefinition( extendsDefinition, pageContext ); - //if(log.isDebugEnabled()) - //log.debug( "parent definition=" + parentDef ); - definition = new ComponentDefinition( parentDef ); - } // end if - else - definition = new ComponentDefinition(); - - // Set definitions attributes - if( page != null ) - definition.setTemplate(page); - if( role != null ) - definition.setRole(role); - - //if(log.isDebugEnabled()) - //log.debug( "definition=" + definition ); - return EVAL_BODY_INCLUDE; - } + public void setScope(String aScope) { + scope = aScope; + } + + /** + * Set <code>extends</code> (parent) definition name. + * @param definitionName Name of parent definition. + */ + public void setExtends(String definitionName) { + this.extendsDefinition = definitionName; + } - /** + /** + * Get <code>extends</code> (parent) definition name. + * @return Name of parent definition. + */ + public String getExtends() { + return extendsDefinition; + } + + /** + * Process the start tag by creating a new definition. + * @throws JspException On errors processing tag. + */ + public int doStartTag() throws JspException { + // Do we extend a definition ? + if (extendsDefinition != null && !extendsDefinition.equals("")) { + ComponentDefinition parentDef = + TagUtils.getComponentDefinition(extendsDefinition, pageContext); + + definition = new ComponentDefinition(parentDef); + + } else { + definition = new ComponentDefinition(); + } + + // Set definitions attributes + if (page != null) { + definition.setTemplate(page); + } + + if (role != null) { + definition.setRole(role); + } + + return EVAL_BODY_INCLUDE; + } + + /** * Process the end tag by putting the definition in appropriate context. * @throws JspException On errors processing tag. */ - public int doEndTag() throws JspException - { - TagUtils.setAttribute( pageContext, id, definition, scope); - - releaseInternal(); - return EVAL_PAGE; - } + public int doEndTag() throws JspException { + TagUtils.setAttribute(pageContext, id, definition, scope); + releaseInternal(); + return EVAL_PAGE; + } } 1.5 +112 -117 jakarta-struts/src/share/org/apache/struts/taglib/tiles/PutListTag.java Index: PutListTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/PutListTag.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PutListTag.java 27 Feb 2003 19:18:55 -0000 1.4 +++ PutListTag.java 2 Jul 2003 02:13:53 -0000 1.5 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,7 +59,6 @@ * */ - package org.apache.struts.taglib.tiles; import java.util.ArrayList; @@ -71,32 +70,39 @@ import org.apache.struts.tiles.AttributeDefinition; import org.apache.struts.tiles.UntyppedAttribute; +/** + * PutList tag implementation. + */ +public class PutListTag + extends TagSupport + implements ComponentConstants, AddTagParent, PutListTagParent { + + /** + * Name of this attribute. + */ + private String attributeName = null; + + /** + * The list itself. + */ + private List list = null; + + /** + * Role attribute. + */ + private String role = null; - /** - * PutList tag implementation. - */ -public class PutListTag extends TagSupport implements ComponentConstants, AddTagParent, PutListTagParent { - - - /** Name of this attribute. */ - private String attributeName = null; - /** The list itself. */ - private List list = null; - /** Role attribute. */ - private String role = null; - - /** - * Default constructor. - */ - public PutListTag() { - super(); - } + /** + * Default constructor. + */ + public PutListTag() { + super(); + } /** * Release all allocated resources. */ public void release() { - super.release(); attributeName = null; role = null; @@ -105,60 +111,56 @@ /** * Release all internal resources. */ - protected void releaseInternal() - { - list = null; - } + protected void releaseInternal() { + list = null; + } /** * Set property. */ - public void setName(String name) - { - this.attributeName = name; - } + public void setName(String name) { + this.attributeName = name; + } /** * Get property. */ - public String getName() - { - return attributeName; - } + public String getName() { + return attributeName; + } /** * Set role attribute. * @param role The role the user must be in to store content. */ - public void setRole(String role) - { - this.role = role; - } + public void setRole(String role) { + this.role = role; + } /** * Get role attribute. */ - public String getRole() - { - return role; - } + public String getRole() { + return role; + } /** * Get list defined in tag. */ - public List getList() - { - return list; - } + public List getList() { + return list; + } /** * Set property. */ - public void addElement(Object value){ - if(list==null) - list = new ArrayList(); - list.add(value); - } + public void addElement(Object value) { + if (list == null) { + list = new ArrayList(); + } + + list.add(value); + } /** * Process nested ≶putList> tag. @@ -167,21 +169,20 @@ * If role is defined, nested attribute is wrapped into an untypped definition * containing attribute value and role. */ - public void processNestedTag(PutListTag nestedTag) throws JspException - { - // Get real value and check role - // If role is set, add it in attribute definition if any. - // If no attribute definition, create untyped one, and set role. - Object attributeValue = nestedTag.getList(); - - if( nestedTag.getRole() != null ) - { - AttributeDefinition def = new UntyppedAttribute( attributeValue ); - def.setRole(nestedTag.getRole()); - attributeValue = def; - } // end if - // now add attribute to enclosing parent (i.e. : this object) - addElement(attributeValue); + public void processNestedTag(PutListTag nestedTag) throws JspException { + // Get real value and check role + // If role is set, add it in attribute definition if any. + // If no attribute definition, create untyped one, and set role. + Object attributeValue = nestedTag.getList(); + + if (nestedTag.getRole() != null) { + AttributeDefinition def = new UntyppedAttribute(attributeValue); + def.setRole(nestedTag.getRole()); + attributeValue = def; + } + + // now add attribute to enclosing parent (i.e. : this object) + addElement(attributeValue); } /** @@ -191,70 +192,64 @@ * If role is defined, nested attribute is wrapped into an untypped definition * containing attribute value and role. */ - public void processNestedTag(AddTag nestedTag) throws JspException - { - // Get real value and check role - // If role is set, add it in attribute definition if any. - // If no attribute definition, create untyped one, and set role. - Object attributeValue = nestedTag.getRealValue(); - AttributeDefinition def; - - if( nestedTag.getRole() != null ) - { - try - { - def = ((AttributeDefinition)attributeValue); - } - catch( ClassCastException ex ) - { - def = new UntyppedAttribute( attributeValue ); + public void processNestedTag(AddTag nestedTag) throws JspException { + // Get real value and check role + // If role is set, add it in attribute definition if any. + // If no attribute definition, create untyped one, and set role. + Object attributeValue = nestedTag.getRealValue(); + AttributeDefinition def; + + if (nestedTag.getRole() != null) { + try { + def = ((AttributeDefinition) attributeValue); + } catch (ClassCastException ex) { + def = new UntyppedAttribute(attributeValue); + } + def.setRole(nestedTag.getRole()); + attributeValue = def; } - def.setRole(nestedTag.getRole()); - attributeValue = def; - } // end if - // now add attribute to enclosing parent (i.e. : this object) - addElement(attributeValue); + + // now add attribute to enclosing parent (i.e. : this object) + addElement(attributeValue); } /** * Do start tag. */ - public int doStartTag() throws JspException - { - return EVAL_BODY_INCLUDE; + public int doStartTag() throws JspException { + return EVAL_BODY_INCLUDE; } /** * Do end tag. */ - public int doEndTag() throws JspException - { - PutListTagParent enclosingParent = findEnclosingParent(); - enclosingParent.processNestedTag( this ); - // Clear list to avoid reuse - releaseInternal(); - return EVAL_PAGE; - } + public int doEndTag() throws JspException { + PutListTagParent enclosingParent = findEnclosingParent(); + enclosingParent.processNestedTag(this); + // Clear list to avoid reuse + releaseInternal(); + return EVAL_PAGE; + } /** * Find enclosing parent tag accepting this tag. * @throws JspException If we can't find an appropriate enclosing tag. */ - protected PutListTagParent findEnclosingParent() throws JspException { - try - { - PutListTagParent parent = (PutListTagParent)findAncestorWithClass(this,PutListTagParent.class); - if( parent == null ) - { - throw new JspException( "Error - tag putList : enclosing tag doesn't accept 'putList' tag." ); + protected PutListTagParent findEnclosingParent() throws JspException { + try { + PutListTagParent parent = + (PutListTagParent) findAncestorWithClass(this, + PutListTagParent.class); + + if (parent == null) { + throw new JspException("Error - tag putList : enclosing tag doesn't accept 'putList' tag."); + } + + return parent; + + } catch (ClassCastException ex) { + throw new JspException("Error - tag putList : enclosing tag doesn't accept 'putList' tag."); } - return parent; - } - catch( ClassCastException ex ) - { - throw new JspException( "Error - tag putList : enclosing tag doesn't accept 'putList' tag." ); - } - } - + } } 1.3 +200 -216 jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java Index: XmlAttribute.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XmlAttribute.java 10 Oct 2002 16:32:26 -0000 1.2 +++ XmlAttribute.java 2 Jul 2003 02:13:53 -0000 1.3 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,241 +59,225 @@ * */ - package org.apache.struts.tiles.xmlDefinition; +import org.apache.struts.tiles.DefinitionNameAttribute; import org.apache.struts.tiles.DirectStringAttribute; import org.apache.struts.tiles.PathAttribute; -import org.apache.struts.tiles.DefinitionNameAttribute; import org.apache.struts.tiles.UntyppedAttribute; /** - * A property key-value pair. - * This class is used to read configuration files. + * A property key-value pair. This class is used to read configuration files. */ -public class XmlAttribute -{ +public class XmlAttribute { + + /** + * Attribute name or key. + */ + private String name = null; + + /** + * Attribute value. + * Value read from description file. + */ + private Object value = null; - /** - * Attribute name or key. - */ - private String name; - - /** - * Attribute value. - * Value read from description file. - */ - private Object value; - - /** - * Attribute value. - */ - private String direct=null; - /** - * Attribute value. - */ - private String valueType=null; - /** - * Attribute value. - */ - private String role=null; - - /** - * Real attribute value. - * Real value is the value after processing of valueType. - * I.e. if a type is defined, realValue contains wrapper for this type. - */ - private Object realValue; + /** + * Attribute value. + */ + private String direct = null; + + /** + * Attribute value. + */ + private String valueType = null; + + /** + * Attribute value. + */ + private String role = null; + + /** + * Real attribute value. + * Real value is the value after processing of valueType. + * I.e. if a type is defined, realValue contains wrapper for this type. + */ + private Object realValue = null; /** * Constructor. */ - public XmlAttribute() - { + public XmlAttribute() { + super(); } /** * Constructor. */ - public XmlAttribute( String name, Object value) - { - this.name = name; - this.value = value; - } - - /** - * Access method for the name property. - * - * @return the current value of the name property - */ - public String getName() - { - return name; - } - - /** - * @return void - * Sets the value of the name property. - * - * @param aName the new value of the name property - */ - public void setRole(String role) - { - this.role = role; - } - - /** - * Access method for the name property. - * - * @return the current value of the name property - */ - public String getRole() - { - return role; - } - - /** - * @return void - * Sets the value of the name property. - * - * @param aName the new value of the name property - */ - public void setName(String aName) - { - name = aName; - } - - /** - * Another access method for the name property. - * - * @return the current value of the name property - */ - public String getAttribute() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param aName the new value of the name property - */ - public void setAttribute(String aName) - { - name = aName; - } - - /** - * Access method for the value property. - * Return the value or a QualifiedAttribute containing the value - * if 'direct' is set. - * - * @return the current value of the value property - */ - public Object getValue() - { - // Compatibility with JSP Template - if( realValue ==null ) - realValue = computeRealValue(); - return realValue; - } - - /** - * Sets the value of the value property. - * - * @param aValue the new value of the value property - */ - public void setValue(Object aValue) - { - realValue=null; - value = aValue; - } - - /** - * Sets the value of the value property. - * - * @param aValue the new value of the value property - */ - public void setContent(Object aValue) - { - setValue(aValue); - } - /** - * Sets the value of the value property. - * - * @param aValue the new value of the value property - */ - public void setBody(String body) - { - if( body.length() == 0 ) - return; - setValue(body); - } - /** - * Sets the value of the value property. - * - * @param aValue the new value of the value property - */ - public void setDirect(String value) - { - this.direct = value; - } - /** - * Sets the value of the value property. - * - * @param aValue the new value of the value property - */ - public void setType(String value) - { - this.valueType = value; + public XmlAttribute(String name, Object value) { + this.name = name; + this.value = value; + } + + /** + * Access method for the name property. + * + * @return The current value of the name property. + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param aName the new value of the name property + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Access method for the name property. + * + * @return The current value of the name property. + */ + public String getRole() { + return role; + } + + /** + * Sets the value of the name property. + * + * @param aName the new value of the name property. + */ + public void setName(String aName) { + name = aName; + } + + /** + * Another access method for the name property. + * + * @return the current value of the name property + */ + public String getAttribute() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param aName the new value of the name property + */ + public void setAttribute(String aName) { + name = aName; + } + + /** + * Access method for the value property. Return the value or a + * QualifiedAttribute containing the value if 'direct' is set. + * + * @return The current value of the value property. + */ + public Object getValue() { + // Compatibility with JSP Template + if (this.realValue == null) { + this.realValue = this.computeRealValue(); + } + + return this.realValue; + } + + /** + * Sets the value of the value property. + * + * @param aValue the new value of the value property + */ + public void setValue(Object aValue) { + realValue = null; + value = aValue; + } + + /** + * Sets the value of the value property. + * + * @param aValue the new value of the value property + */ + public void setContent(Object aValue) { + setValue(aValue); + } + + /** + * Sets the value of the value property. + * + * @param aValue the new value of the value property + */ + public void setBody(String body) { + if (body.length() == 0) { + return; + } + + setValue(body); + } + + /** + * Sets the value of the value property. + * + * @param aValue the new value of the value property + */ + public void setDirect(String value) { + this.direct = value; + } + + /** + * Sets the value of the value property. + * + * @param aValue the new value of the value property + */ + public void setType(String value) { + this.valueType = value; } /** * Compute real value from attributes setting. */ - protected Object computeRealValue() - { - Object realValue = value; - // Is there a type set ? - // First check direct attribute, and translate it to a valueType. - // Then, evaluate valueType, and create requested typed attribute. - if( direct != null ) - { - if( Boolean.valueOf(direct).booleanValue() == true ) - valueType = "string"; - else - valueType = "path"; - } // end if - if( value != null && valueType!=null /* && !(value instanceof AttributeDefinition) */ ) - { - String strValue = value.toString(); - if( valueType.equalsIgnoreCase( "string" ) ) - { - realValue = new DirectStringAttribute( strValue ); - } - else if( valueType.equalsIgnoreCase( "page" ) ) - { - realValue = new PathAttribute( strValue ); - } - else if( valueType.equalsIgnoreCase( "template" ) ) - { - realValue = new PathAttribute( strValue ); - } - else if( valueType.equalsIgnoreCase( "instance" ) ) - { - realValue = new DefinitionNameAttribute( strValue ); - } // end if - // Set realValue's role value if needed - if( role !=null ) - ((UntyppedAttribute)realValue).setRole( role ); - } // end if - - // Create attribute wrapper to hold role if role is set and no type specified - if( role!=null && value != null && valueType==null ) - { - realValue = new UntyppedAttribute( value.toString(), role ); - } // end if + protected Object computeRealValue() { + Object realValue = value; + // Is there a type set ? + // First check direct attribute, and translate it to a valueType. + // Then, evaluate valueType, and create requested typed attribute. + if (direct != null) { + this.valueType = + Boolean.valueOf(direct).booleanValue() ? "string" : "path"; + } + + if (value != null && valueType != null) { + String strValue = value.toString(); + + if (valueType.equalsIgnoreCase("string")) { + realValue = new DirectStringAttribute(strValue); + + } else if (valueType.equalsIgnoreCase("page")) { + realValue = new PathAttribute(strValue); + + } else if (valueType.equalsIgnoreCase("template")) { + realValue = new PathAttribute(strValue); + + } else if (valueType.equalsIgnoreCase("instance")) { + realValue = new DefinitionNameAttribute(strValue); + } + + // Set realValue's role value if needed + if (role != null) { + ((UntyppedAttribute) realValue).setRole(role); + } + } + + // Create attribute wrapper to hold role if role is set and no type specified + if (role != null && value != null && valueType == null) { + realValue = new UntyppedAttribute(value.toString(), role); + } - return realValue; + return realValue; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]