public class DefaultConversionContext extends Object implements ConversionContext
Unless explicitly set the 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 |
addMarshallerMetricsConsumer(MarshallerMetricsConsumer consumer)
Adds a consumer of
MarshallerMetrics
that is associated with the current render. |
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.
|
Set<MarshallerMetricsConsumer> |
getMarshallerMetricsConsumers()
Returns the consumers of
MarshallerMetrics
that are associated with the current render. |
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.
|
com.google.common.collect.ImmutableMap<String,Object> |
immutableProperties()
The properties returned in this map are guaranteed to be immutable, they are not guaranteed
to all be present.
|
boolean |
isAsyncRenderSafe() |
boolean |
isDiffOrEmail()
Check if the current context is
ConversionContextOutputType.DIFF
or ConversionContextOutputType.EMAIL |
boolean |
removeMarshallerMetricsConsumer(MarshallerMetricsConsumer consumer)
Removes a consumer of
MarshallerMetrics
that is associated with the current render. |
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 - public com.google.common.collect.ImmutableMap<String,Object> immutableProperties()
@Deprecated public com.atlassian.renderer.RenderContext getRenderContext()
getPageContext() instead.public PageContext getPageContext()
ConversionContextThis 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 ConversionContextDefaultConversionContextpublic Object removeProperty(String name)
ConversionContextremoveProperty in interface ConversionContextname - The unique key of the property. See ConversionContextPropertyName for common names.public void setProperty(String name, Object value)
ConversionContextsetProperty in interface ConversionContextname - A unique key for this property. See ConversionContextPropertyName for common names.value - The value of the property.public Object getProperty(String name)
ConversionContextgetProperty in interface ConversionContextname - of the property. See ConversionContextPropertyName for common names.public Object getProperty(String name, Object defaultValue)
ConversionContextgetProperty in interface ConversionContextname - the name of the propertydefaultValue - the default value to return if the property is not found.public String getPropertyAsString(String name)
ConversionContexttoString() will be called if this is not the java.lang.String class.
null will be returned if this property does not exist.
getPropertyAsString in interface ConversionContextname - The key for the propertypublic boolean hasProperty(String name)
ConversionContexthasProperty in interface ConversionContextname - The name of the propertypublic ContentTree getContentTree()
ConversionContextgetContentTree in interface ConversionContextpublic void setContentTree(ContentTree contentTree)
public String getOutputDeviceType()
ConversionContextConversionContext.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 ConversionContextConversionContextOutputDeviceType.DESKTOP
but plugins that have their own renderer could use other types@Nonnull public String getOutputType()
getOutputType in interface ConversionContextConversionContextOutputType.value() which indicates the target output type
for the conversion.public boolean isAsyncRenderSafe()
isAsyncRenderSafe in interface ConversionContextpublic void disableAsyncRenderSafe()
disableAsyncRenderSafe in interface ConversionContextpublic com.atlassian.util.concurrent.Timeout getTimeout()
ConversionContextTimeout.isExpired(), or how much longer conversion should be allowed to
run using Timeout.getTime(), Timeout.getUnit().getTimeout in interface ConversionContextpublic void checkTimeout()
throws XhtmlTimeoutException
ConversionContextConversionContext.getTimeout() and Timeout.isExpired() to check the timeout without
throwing an exception.checkTimeout in interface ConversionContextXhtmlTimeoutException - if the conversion has exceeded its time limit.public boolean isDiffOrEmail()
ConversionContextConversionContextOutputType.DIFF
or ConversionContextOutputType.EMAILisDiffOrEmail in interface ConversionContextpublic void addMarshallerMetricsConsumer(MarshallerMetricsConsumer consumer)
ConversionContextMarshallerMetrics
that is associated with the current render. These consumers are used instead of event listeners because their
scope of interest is limited to a particular thread.addMarshallerMetricsConsumer in interface ConversionContextpublic boolean removeMarshallerMetricsConsumer(MarshallerMetricsConsumer consumer)
ConversionContextMarshallerMetrics
that is associated with the current render.removeMarshallerMetricsConsumer in interface ConversionContextpublic Set<MarshallerMetricsConsumer> getMarshallerMetricsConsumers()
ConversionContextMarshallerMetrics
that are associated with the current render. These consumers are used instead of event listeners because their
scope of interest is limited to a particular thread.getMarshallerMetricsConsumers in interface ConversionContextpublic ContentEntityObject getEntity()
ConversionContextgetEntity in interface ConversionContextpublic String getSpaceKey()
ConversionContextgetSpaceKey in interface ConversionContextCopyright © 2003–2016 Atlassian. All rights reserved.