com.atlassian.confluence.content.render.xhtml
Interface ConversionContext

All Known Implementing Classes:
DefaultConversionContext

public interface ConversionContext

Since:
4.0

Field Summary
static String IS_VALIDATING_COMMENT
          This property will be set when validating a comment.
 
Method Summary
 void checkTimeout()
          Check the timeout and throw an XhtmlTimeoutException if the timeout is expired.
 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.
 Object getProperty(String name, Object defaultValue)
          Return a property from the context or the supplied defaultValue if the property does not exist on the context.
 String getPropertyAsString(String name)
          Returns the property for this key as a String.
 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.
 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 setProperty(String name, Object value)
          Sets the property specified by name in the conversion context.
 

Field Detail

IS_VALIDATING_COMMENT

static final String IS_VALIDATING_COMMENT
This property will be set when validating a comment.

Since:
4.3
Method Detail

setProperty

void setProperty(String name,
                 Object value)
Sets the property specified by name in the conversion context.

Parameters:
name - A unique key for this property. See ConversionContextPropertyName for common names.
value - The value of the property.

getPageContext

PageContext getPageContext()

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.

Returns:
the underlying PageContext wrapped by the ConversionContext.
See Also:
DefaultConversionContext

removeProperty

Object removeProperty(String name)
Removes the property references by the key from the conversion context and returns it.

Parameters:
name - The unique key of the property. See ConversionContextPropertyName for common names.
Returns:
The property from the conversion context.

getProperty

Object getProperty(String name)
Return a property from the context.

Parameters:
name - of the property. See ConversionContextPropertyName for common names.
Returns:
a property from the context.

getProperty

Object getProperty(String name,
                   Object defaultValue)
Return a property from the context or the supplied defaultValue if the property does not exist on the context.

Parameters:
name - the name of the property
defaultValue - the default value to return if the property is not found.
Returns:
the value of the found property or the default value if not found.

getPropertyAsString

String getPropertyAsString(String name)
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.

Parameters:
name - The key for the property
Returns:
The String value of the property or null if the property does not exist.

hasProperty

boolean hasProperty(String name)
Returns true if the property with the specified key has been set.

Parameters:
name - The name of the property
Returns:
True if the property exists in this context.

getContentTree

ContentTree getContentTree()
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.

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.

getOutputType

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

getEntity

ContentEntityObject getEntity()
Get the current ContentEntityObject for this context.

Returns:
The ContentEntityObject for this context.

getSpaceKey

String getSpaceKey()
The spacekey for the current context if applicable or null otherwise.

Returns:
The spacekey or null.

getTimeout

com.atlassian.util.concurrent.Timeout getTimeout()
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().

Returns:
the timeout to perform the conversion.

checkTimeout

void checkTimeout()
                  throws XhtmlTimeoutException
Check the timeout and throw an XhtmlTimeoutException if the timeout is expired. Use getTimeout() and Timeout.isExpired() to check the timeout without throwing an exception.

Throws:
XhtmlTimeoutException - if the conversion has exceeded its time limit.


Copyright © 2003-2012 Atlassian. All Rights Reserved.