Class DefaultConversionContext

    • Constructor Detail

      • DefaultConversionContext

        public DefaultConversionContext​(com.atlassian.renderer.RenderContext renderContext)
      • DefaultConversionContext

        public DefaultConversionContext​(com.atlassian.renderer.RenderContext renderContext,
                                        String outputDeviceType)
        Create a DefaultConversionContext for the specified output device type. Note that any output device type on the supplied RenderContext will be overridden by the provided value.
        Parameters:
        renderContext -
        outputDeviceType -
    • Method Detail

      • immutableProperties

        @Deprecated
        public com.google.common.collect.ImmutableMap<String,​Object> immutableProperties()
        Deprecated.
        since 7.0.1. Use getImmutableProperties()
        The properties returned in this map are guaranteed to be immutable, they are not guaranteed to all be present.
        Returns:
        an immutable map of the immutable properties in the conversion context
      • getImmutableProperties

        public Map<String,​Object> getImmutableProperties()
        The properties returned in this map are guaranteed to be immutable, they are not guaranteed to all be present.
        Returns:
        an immutable map of the immutable properties in the conversion context
        Since:
        7.0.1
      • getProperty

        public Object getProperty​(String name,
                                  Object defaultValue)
        Description copied from interface: ConversionContext
        Return a property from the context or the supplied defaultValue if the property does not exist on the context.
        Specified by:
        getProperty in interface ConversionContext
        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

        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)
      • getOutputDeviceType

        public String getOutputDeviceType()
        Description copied from interface: ConversionContext
        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". 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.
        Specified by:
        getOutputDeviceType in interface ConversionContext
        Returns:
        the output device type. Typically this would be ConversionContextOutputDeviceType.DESKTOP but plugins that have their own renderer could use other types
      • isAsyncRenderSafe

        public boolean isAsyncRenderSafe()
        Specified by:
        isAsyncRenderSafe in interface ConversionContext
        Returns:
        true if the content is safe to render in asynchronously, e.g. dynamically on a page without a page refresh.
      • disableAsyncRenderSafe

        public void disableAsyncRenderSafe()
        Mark the content rendered in this context as non-async-render-safe
        Specified by:
        disableAsyncRenderSafe in interface ConversionContext
      • getTimeout

        @Deprecated
        public com.atlassian.util.concurrent.Timeout getTimeout()
        Deprecated.
        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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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.