org.progeeks.meta.xml
Class XmlMetaObjectRenderer

java.lang.Object
  extended by org.progeeks.meta.xml.AbstractXmlPropertyRenderer
      extended by org.progeeks.meta.xml.XmlMetaObjectRenderer
All Implemented Interfaces:
XmlPropertyRenderer
Direct Known Subclasses:
GraphXmlRenderer

public class XmlMetaObjectRenderer
extends AbstractXmlPropertyRenderer

Default renderer for generating output for a meta-object.

Version:
$Revision: 1.25 $
Author:
Paul Speed

Constructor Summary
XmlMetaObjectRenderer()
          Creates a renderer that will renderer all the fields of a meta-object.
XmlMetaObjectRenderer(java.util.List fields)
          Creates a renderer that will renderer the specified fields of a meta-object.
 
Method Summary
protected  java.util.List getFields()
           
 boolean getRenderDefaultValues()
          Returns true if this renderer will render the values of properties that are the same as their defined default values.
 boolean getRenderMetaClassAsAttribute()
          Set to true to render a more generic outer tag with the meta-class name as an attribute.
protected  boolean isRenderedAsAttribute(PropertyInfo info, java.lang.Object value, RendererProxy rp)
          Called to determine if a specific property value should be rendered as an attribute or a nested element.
 void render(java.lang.Object value, PropertyType type, boolean forceWrap, XmlRenderContext context)
          Renders the specified Mutator's value to the specified writer.
protected  void renderNestedElement(MetaObject obj, java.lang.String property, java.lang.Object value, RendererProxy rp, XmlRenderContext context)
           
protected  boolean renderProperty(MetaClass mClass, PropertyInfo info, java.lang.Object value)
          Called to determine if the specified property should be rendered or not.
 void setRenderDefaultValues(boolean flag)
          Set to true for default property values to be rendered with the rest of the properties.
 void setRenderMetaClassAsAttribute(boolean flag)
          Set to true to render a more generic outer tag with the meta-class name as an attribute.
protected  void writeAttributes(MetaObject obj, java.util.Collection properties, java.util.Map proxies, XmlRenderContext context)
           
protected  void writeElements(MetaObject obj, java.util.Collection properties, java.util.Map proxies, XmlRenderContext context)
           
 
Methods inherited from class org.progeeks.meta.xml.AbstractXmlPropertyRenderer
canRenderAsAttribute, findEm, getAsAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlMetaObjectRenderer

public XmlMetaObjectRenderer()
Creates a renderer that will renderer all the fields of a meta-object.


XmlMetaObjectRenderer

public XmlMetaObjectRenderer(java.util.List fields)
Creates a renderer that will renderer the specified fields of a meta-object.

Method Detail

setRenderMetaClassAsAttribute

public void setRenderMetaClassAsAttribute(boolean flag)
Set to true to render a more generic outer tag with the meta-class name as an attribute. This is to better support XML that contains meta-classes that contain characters illegal for tags.


getRenderMetaClassAsAttribute

public boolean getRenderMetaClassAsAttribute()
Set to true to render a more generic outer tag with the meta-class name as an attribute. This is to better support XML that contains meta-classes that contain characters illegal for tags.


setRenderDefaultValues

public void setRenderDefaultValues(boolean flag)
Set to true for default property values to be rendered with the rest of the properties. Default values are defined by the PropertyInfo for the property. Defaults to true.


getRenderDefaultValues

public boolean getRenderDefaultValues()
Returns true if this renderer will render the values of properties that are the same as their defined default values. Defaults to true and renders all renderable properties.


getFields

protected java.util.List getFields()

renderProperty

protected boolean renderProperty(MetaClass mClass,
                                 PropertyInfo info,
                                 java.lang.Object value)
Called to determine if the specified property should be rendered or not. Subclasses can override to provide their own behavior. The default implementation adheres to the renderDefaults flag to determine if default values should be rendered or not as specified by their PropertyInfo definitions.


isRenderedAsAttribute

protected boolean isRenderedAsAttribute(PropertyInfo info,
                                        java.lang.Object value,
                                        RendererProxy rp)
Called to determine if a specific property value should be rendered as an attribute or a nested element. Default implementation returns rp.canRenderAsAttribute().


writeAttributes

protected void writeAttributes(MetaObject obj,
                               java.util.Collection properties,
                               java.util.Map proxies,
                               XmlRenderContext context)

renderNestedElement

protected void renderNestedElement(MetaObject obj,
                                   java.lang.String property,
                                   java.lang.Object value,
                                   RendererProxy rp,
                                   XmlRenderContext context)

writeElements

protected void writeElements(MetaObject obj,
                             java.util.Collection properties,
                             java.util.Map proxies,
                             XmlRenderContext context)

render

public void render(java.lang.Object value,
                   PropertyType type,
                   boolean forceWrap,
                   XmlRenderContext context)
Renders the specified Mutator's value to the specified writer.

Specified by:
render in interface XmlPropertyRenderer
Specified by:
render in class AbstractXmlPropertyRenderer
Parameters:
value - The value to be rendered.
type - The specific type that was used to lookup this renderer.
forceWrap - Set to true if the renderer should wrap the value in its own style of start/end tags. False indicates that the renderer can optionally leave them out. This is usually used by renderers that support types that can be defined as strings directly.
context - Contains the rendering output information for this session.


Copyright © 2002-2003 Paul Speed. All Rights Reserved.