org.progeeks.meta.xml
Class XmlRenderContext

java.lang.Object
  extended by org.progeeks.meta.xml.XmlRenderContext

public class XmlRenderContext
extends java.lang.Object

Contains the session specific information during a single rendering engine write call, including the XmlPrintWriter, a reference to the engine, an object cache, etc..

Version:
$Revision: 1.16 $
Author:
Paul Speed

Constructor Summary
XmlRenderContext(XmlRenderingEngine engine, XmlPrintWriter out, MetaKit metaKit)
           
 
Method Summary
 MetaObject createMetaObjectWrapper(java.lang.Object obj)
          Auto-wraps the specified object if possible or just returns null if not.
 XmlRenderingEngine getEngine()
          Returns the engine from which this context is operating.
 MetaForm getMetaForm(MetaClass type, MetaFormFlavor flavor)
          Returns the MetaForm for the specified meta-class and flavor.
 MetaKit getMetaKit()
          Returns the meta-kit to use when auto-resolving regular objects to meta-objects for rendering.
 java.lang.String getObjectId(java.lang.Object object)
          Returns the ID for the specified object if it has been stored in the object cache or null if it hasn't.
 XmlPropertyRenderer getRenderer(PropertyType type, java.lang.Object value)
          Deprecated. Use the getRendererProxy() method instead.
 RendererProxy getRendererProxy(PropertyType type, java.lang.Object value)
          Delegates to the rendering engine to retrieve a renderer for the specified type and object.
 XmlPrintWriter getWriter()
          Returns the XmlPrintWriter to which renderers should be writing.
 java.lang.String registerObject(java.lang.Object object)
          Registers the specified object with the object cache using a generated ID.
 void registerObject(java.lang.String id, java.lang.Object object)
          Registers the specified object with the object cache using the specified ID.
 void renderMetaObject(MetaObject obj, boolean registerObject)
          Looks up the appropriate renderers and generates XML output for the specified meta-object using this context's internal settings.
 void renderObject(java.lang.Object obj, boolean forceWrap, boolean registerObject)
          Renders the specified object to XML using some heuristics based on type, the current meta-kit, registered meta-classes, etc. to attempt to find the best renderer using this context's internal settings.
 void renderTypedObject(java.lang.Object obj, PropertyType type, boolean forceWrap, boolean registerObject)
          Looks up the appropriate renderers and generates XML output for the specified object using a renderer associated with the specified PropertyType using this context's internal settings.
 java.lang.String transformClassName(java.lang.String name)
          Performs any necessary transformations on the specified class name and then returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRenderContext

public XmlRenderContext(XmlRenderingEngine engine,
                        XmlPrintWriter out,
                        MetaKit metaKit)
Method Detail

getEngine

public XmlRenderingEngine getEngine()
Returns the engine from which this context is operating.


getWriter

public XmlPrintWriter getWriter()
Returns the XmlPrintWriter to which renderers should be writing.


getMetaKit

public MetaKit getMetaKit()
Returns the meta-kit to use when auto-resolving regular objects to meta-objects for rendering.


getMetaForm

public MetaForm getMetaForm(MetaClass type,
                            MetaFormFlavor flavor)
Returns the MetaForm for the specified meta-class and flavor. If flavor is null then it defaults to the XmlRenderingEngine.XML_FORM flavor.


transformClassName

public java.lang.String transformClassName(java.lang.String name)
Performs any necessary transformations on the specified class name and then returns it. Renderers are not required to call this method but most of the standard ones do.


createMetaObjectWrapper

public MetaObject createMetaObjectWrapper(java.lang.Object obj)
Auto-wraps the specified object if possible or just returns null if not. If the object is already a meta-object then it is just returned directly. Auto-wrapping uses the current meta-kit to see if the object can be wrapped in a MetaObject for more accurate processing. If the meta-kit is null then this method will always return null unless the object is already a meta-object.


getRenderer

public XmlPropertyRenderer getRenderer(PropertyType type,
                                       java.lang.Object value)
Deprecated. Use the getRendererProxy() method instead.

Delegates to the rendering engine to retrieve a renderer for the specified type and object. If the object value is in this context's object map then a special reference renderer will be returned instead of the object's standard renderer.


getRendererProxy

public RendererProxy getRendererProxy(PropertyType type,
                                      java.lang.Object value)
Delegates to the rendering engine to retrieve a renderer for the specified type and object. If the object value is in this context's object map then a special reference renderer will be returned instead of the object's standard renderer.


renderMetaObject

public void renderMetaObject(MetaObject obj,
                             boolean registerObject)
Looks up the appropriate renderers and generates XML output for the specified meta-object using this context's internal settings.

Parameters:
obj - The meta-object to render.
registerObject - Set to true if the object should be added to the registry and the appropriate xml.oid attribute emitted. The object will only be registered if it is not already in the registry.

renderTypedObject

public void renderTypedObject(java.lang.Object obj,
                              PropertyType type,
                              boolean forceWrap,
                              boolean registerObject)
Looks up the appropriate renderers and generates XML output for the specified object using a renderer associated with the specified PropertyType using this context's internal settings.

Parameters:
obj - The object to render.
type - The type of the object used for renderer lookups.
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.
registerObject - Set to true if the object should be added to the registry and the appropriate xml.oid attribute emitted. The object will only be registered if it is not already in the registry.

renderObject

public void renderObject(java.lang.Object obj,
                         boolean forceWrap,
                         boolean registerObject)
Renders the specified object to XML using some heuristics based on type, the current meta-kit, registered meta-classes, etc. to attempt to find the best renderer using this context's internal settings. First this method uses the configured meta-kit to attempt to resolve the object to an appropriate MetaClass. If this is successful then the object will be wrapped and rendered as such. Otherwise, the class of the object is used in a ClassPropertyType to look up an appropriate renderer. It is important to note that more specific PropertyTypes will therefore not come into play.

Parameters:
obj - The object to render.
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.
registerObject - Set to true if the object should be added to the registry and the appropriate xml.oid attribute emitted. The object will only be registered if it is not already in the registry.

registerObject

public void registerObject(java.lang.String id,
                           java.lang.Object object)
Registers the specified object with the object cache using the specified ID.


registerObject

public java.lang.String registerObject(java.lang.Object object)
Registers the specified object with the object cache using a generated ID. The ID is then returned to the caller.


getObjectId

public java.lang.String getObjectId(java.lang.Object object)
Returns the ID for the specified object if it has been stored in the object cache or null if it hasn't.



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