com.atlassian.confluence.content.render.xhtml
Class DefaultConversionContext

java.lang.Object
  extended by com.atlassian.confluence.content.render.xhtml.DefaultConversionContext
All Implemented Interfaces:
ConversionContext

public class DefaultConversionContext
extends Object
implements ConversionContext

A non-thread safe implementation of the ConversionContext suitable for use in the single threaded XHTML output process.


Constructor Summary
DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext)
           
 
Method Summary
 void checkTimeout()
          Check the timeout and throw an XhtmlTimeoutException if the timeout is expired.
 boolean equals(Object o)
           
 ContentTree getContentTree()
          If multiple items are being converted in this 'context' then the complete tree of ContentNodes will be retrieved via this method.
 ContentEntityObject getEntity()
          Get the current ContentEntityObject for this context.
 String getOutputType()
           
 PageContext getPageContext()
           This method should be considered almost deprecated.
 Object getProperty(String name)
          Return a property from the context.
 String getPropertyAsString(String name)
          Returns the property for this key as a String.
 com.atlassian.renderer.RenderContext getRenderContext()
          Deprecated. Used getPageContext() instead.
 String getSpaceKey()
          The spacekey for the current context if applicable or null otherwise.
 com.atlassian.util.concurrent.Timeout getTimeout()
          The Timeout object for this Conversion.
 int hashCode()
           
 boolean hasProperty(String name)
          Returns true if the property with the specified key has been set.
 Object removeProperty(String name)
          Removes the property references by the key from the conversion context and returns it.
 void setContentTree(ContentTree contentTree)
           
 void setProperty(String name, Object value)
          Sets the property specified by name in the conversion context.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConversionContext

public DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext)
Method Detail

getRenderContext

@Deprecated
public com.atlassian.renderer.RenderContext getRenderContext()
Deprecated. Used getPageContext() instead.


getPageContext

public PageContext getPageContext()
Description copied from interface: ConversionContext

This method should be considered almost deprecated.

At the moment a ConversionContext implementation will always be wrapping at least a RenderContext and as long as this is actually a PageContext then it will be returned by this method. However, at some point in the future ConversionContext will be decoupled from the old v2 RenderContext and this method will be removed.

Specified by:
getPageContext in interface ConversionContext
Returns:
the underlying PageContext wrapped by the ConversionContext.
See Also:
DefaultConversionContext

removeProperty

public Object removeProperty(String name)
Description copied from interface: ConversionContext
Removes the property references by the key from the conversion context and returns it.

Specified by:
removeProperty in interface ConversionContext
Parameters:
name - The unique key of the property. See ConversionContextPropertyName for common names.
Returns:
The property from the conversion context.

setProperty

public void setProperty(String name,
                        Object value)
Description copied from interface: ConversionContext
Sets the property specified by name in the conversion context.

Specified by:
setProperty in interface ConversionContext
Parameters:
name - A unique key for this property. See ConversionContextPropertyName for common names.
value - The value of the property.

getProperty

public Object getProperty(String name)
Description copied from interface: ConversionContext
Return a property from the context.

Specified by:
getProperty in interface ConversionContext
Parameters:
name - of the property. See ConversionContextPropertyName for common names.
Returns:
a property from the context.

getPropertyAsString

public String getPropertyAsString(String name)
Description copied from interface: ConversionContext
Returns the property for this key as a String. toString() will be called if this is not the java.lang.String class. null will be returned if this property does not exist.

Specified by:
getPropertyAsString in interface ConversionContext
Parameters:
name - The key for the property
Returns:
The String value of the property or null if the property does not exist.

hasProperty

public boolean hasProperty(String name)
Description copied from interface: ConversionContext
Returns true if the property with the specified key has been set.

Specified by:
hasProperty in interface ConversionContext
Parameters:
name - The name of the property
Returns:
True if the property exists in this context.

getContentTree

public ContentTree getContentTree()
Description copied from interface: ConversionContext
If multiple items are being converted in this 'context' then the complete tree of ContentNodes will be retrieved via this method. If only a single item is being converted in the context then a ContentTree containing a single ContentNode will be returned.

Specified by:
getContentTree in interface ConversionContext
Returns:
a ContentTree representing all the items being converted in this context. An empty ContentTree may be returned if there is no explicit content being converted in this context.

setContentTree

public void setContentTree(ContentTree contentTree)

getOutputType

public String getOutputType()
Specified by:
getOutputType in interface ConversionContext
Returns:
one of the Strings returned by ConversionContextOutputType.value() which indicates the target output type for the conversion.

getTimeout

public com.atlassian.util.concurrent.Timeout getTimeout()
Description copied from interface: ConversionContext
The Timeout object for this Conversion. This can be checked to see if conversion should be terminated using Timeout.isExpired(), or how much longer conversion should be allowed to run using Timeout.getTime(), Timeout.getUnit().

Specified by:
getTimeout in interface ConversionContext
Returns:
the timeout to perform the conversion.

checkTimeout

public void checkTimeout()
                  throws XhtmlTimeoutException
Description copied from interface: ConversionContext
Check the timeout and throw an XhtmlTimeoutException if the timeout is expired. Use ConversionContext.getTimeout() and Timeout.isExpired() to check the timeout without throwing an exception.

Specified by:
checkTimeout in interface ConversionContext
Throws:
XhtmlTimeoutException - if the conversion has exceeded its time limit.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getEntity

public ContentEntityObject getEntity()
Description copied from interface: ConversionContext
Get the current ContentEntityObject for this context.

Specified by:
getEntity in interface ConversionContext
Returns:
The ContentEntityObject for this context.

getSpaceKey

public String getSpaceKey()
Description copied from interface: ConversionContext
The spacekey for the current context if applicable or null otherwise.

Specified by:
getSpaceKey in interface ConversionContext
Returns:
The spacekey or null.


Copyright © 2003-2012 Atlassian. All Rights Reserved.