public class DefaultConversionContext extends Object implements ConversionContext
getOutputDeviceType()
will
return ConversionContextOutputDeviceType.DESKTOP
.IS_VALIDATING_COMMENT
Constructor and Description |
---|
DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext) |
DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext,
String outputDeviceType)
Create a DefaultConversionContext for the specified output device type.
|
Modifier and Type | Method and Description |
---|---|
void |
checkTimeout()
Check the timeout and throw an XhtmlTimeoutException if the timeout is expired.
|
void |
disableAsyncRenderSafe()
Mark the content rendered in this context as non-async-render-safe
|
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 |
getOutputDeviceType()
Note, that if you want your code to be compatible with versions of Confluence older then 4.3.2 then you can
instead call
ConversionContext.getPropertyAsString(String) with the parameter "output-device-type". |
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.
|
com.atlassian.renderer.RenderContext |
getRenderContext()
Deprecated.
since 4.0. 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.
|
boolean |
isAsyncRenderSafe() |
boolean |
isDiffOrEmail()
Check if the current context is
ConversionContextOutputType.DIFF
or ConversionContextOutputType.EMAIL |
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.
|
public DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext)
public DefaultConversionContext(com.atlassian.renderer.RenderContext renderContext, String outputDeviceType)
renderContext
- outputDeviceType
- @Deprecated public com.atlassian.renderer.RenderContext getRenderContext()
getPageContext()
instead.public PageContext getPageContext()
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.
getPageContext
in interface ConversionContext
DefaultConversionContext
public Object removeProperty(String name)
ConversionContext
removeProperty
in interface ConversionContext
name
- The unique key of the property. See ConversionContextPropertyName
for common names.public void setProperty(String name, Object value)
ConversionContext
setProperty
in interface ConversionContext
name
- A unique key for this property. See ConversionContextPropertyName
for common names.value
- The value of the property.public Object getProperty(String name)
ConversionContext
getProperty
in interface ConversionContext
name
- of the property. See ConversionContextPropertyName
for common names.public Object getProperty(String name, Object defaultValue)
ConversionContext
getProperty
in interface ConversionContext
name
- the name of the propertydefaultValue
- the default value to return if the property is not found.public String getPropertyAsString(String name)
ConversionContext
getPropertyAsString
in interface ConversionContext
name
- The key for the propertypublic boolean hasProperty(String name)
ConversionContext
hasProperty
in interface ConversionContext
name
- The name of the propertypublic ContentTree getContentTree()
ConversionContext
getContentTree
in interface ConversionContext
public void setContentTree(ContentTree contentTree)
public String getOutputDeviceType()
ConversionContext
ConversionContext.getPropertyAsString(String)
with the parameter "output-device-type". For example, if you
are a plugin developer writing a macro that can target different device types such as mobile, you can
retain a common code base for your mobile and non-mobile implementations by avoiding this method and
calling getPropertyAsString("output-device-type")instead.
getOutputDeviceType
in interface ConversionContext
ConversionContextOutputDeviceType.DESKTOP
but plugins that have their own renderer could use other types@Nonnull public String getOutputType()
getOutputType
in interface ConversionContext
ConversionContextOutputType.value()
which indicates the target output type
for the conversion.public boolean isAsyncRenderSafe()
isAsyncRenderSafe
in interface ConversionContext
public void disableAsyncRenderSafe()
disableAsyncRenderSafe
in interface ConversionContext
public com.atlassian.util.concurrent.Timeout getTimeout()
ConversionContext
Timeout.isExpired()
, or how much longer conversion should be allowed to
run using Timeout.getTime()
, Timeout.getUnit()
.getTimeout
in interface ConversionContext
public void checkTimeout() throws XhtmlTimeoutException
ConversionContext
ConversionContext.getTimeout()
and Timeout.isExpired()
to check the timeout without
throwing an exception.checkTimeout
in interface ConversionContext
XhtmlTimeoutException
- if the conversion has exceeded its time limit.public boolean isDiffOrEmail()
ConversionContext
ConversionContextOutputType.DIFF
or ConversionContextOutputType.EMAIL
isDiffOrEmail
in interface ConversionContext
public ContentEntityObject getEntity()
ConversionContext
getEntity
in interface ConversionContext
public String getSpaceKey()
ConversionContext
getSpaceKey
in interface ConversionContext
Copyright © 2003–2015 Atlassian. All rights reserved.