Class Streamables
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.Streamables
-
public class Streamables extends Object
Convenience class for common operations to construct or convertStreamable
instances.
-
-
Constructor Summary
Constructors Constructor Description Streamables()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Streamable
combine(Streamable... streamables)
Combine a series of streamable instances into a single result.static Streamable
combine(Iterable<Streamable> streamables)
Combine a series of streamable instances into a single result.static Streamable
empty()
Create an empty streamable that will do nothing when itswriteTo()
method is called.static Streamable
from(XmlStreamWriterTemplate template, XmlStreamWriterCallback callback)
Create a streamable that will produce the result of executing the provide callback within the template.static Streamable
from(String source)
Produce a streamable from a string.static Streamable
withCharacterCounting(Streamable delegate, com.atlassian.fugue.Effect<Long> characterCountCallback)
Deprecated.since 7.0.1.static Streamable
withCountingCharacters(Streamable delegate, Consumer<Long> characterCountCallback)
Produces a Streamable which counts the number of characters written to another Streamable's writer.static String
writeToString(Streamable streamable)
Write the contents of a streamable to a string.
-
-
-
Method Detail
-
from
public static Streamable from(String source)
Produce a streamable from a string. This is the least memory-efficient way to get data into a stream, but may be useful for very simple code.- Parameters:
source
- the string that needs to be streamed- Returns:
- the streamable version of the provided string
-
combine
public static Streamable combine(Streamable... streamables)
Combine a series of streamable instances into a single result.- Parameters:
streamables
- the streamables that are to be combined.- Returns:
- a single streamable that is the equivalent of processing each provided streamable in order
-
combine
public static Streamable combine(Iterable<Streamable> streamables)
Combine a series of streamable instances into a single result.- Parameters:
streamables
- the streamables that are to be combined.- Returns:
- a single streamable that is the equivalent of processing each provided streamable in order
-
from
public static Streamable from(XmlStreamWriterTemplate template, XmlStreamWriterCallback callback)
Create a streamable that will produce the result of executing the provide callback within the template. Execution of the callback may be postponed until the streamable'swriteTo
method is called.- Parameters:
template
- the template in which to execute the callbackcallback
- the callback to execute- Returns:
- a streamable that will produce the result of executing the callback
-
empty
public static Streamable empty()
Create an empty streamable that will do nothing when itswriteTo()
method is called.- Returns:
- an empty streamable
-
writeToString
public static String writeToString(Streamable streamable)
Write the contents of a streamable to a string. For efficiency, this should be done as little and as late as possible in the rendering pipeline.- Parameters:
streamable
- the streamable to write- Returns:
- a string containing the contents of the streamable.
-
withCharacterCounting
@Deprecated public static Streamable withCharacterCounting(Streamable delegate, com.atlassian.fugue.Effect<Long> characterCountCallback)
Deprecated.since 7.0.1. UsewithCountingCharacters(Streamable, Consumer)
Produces a Streamable which counts the number of characters written to another Streamable's writer.- Parameters:
delegate
- The streamable to be wrappedcharacterCountCallback
- The callback for receiving the character count- Returns:
- A Streamable wrapper
- Since:
- 5.8
-
withCountingCharacters
public static Streamable withCountingCharacters(Streamable delegate, Consumer<Long> characterCountCallback)
Produces a Streamable which counts the number of characters written to another Streamable's writer.- Parameters:
delegate
- The streamable to be wrappedcharacterCountCallback
- The callback for receiving the character count- Returns:
- A Streamable wrapper
- Since:
- 7.0.1
-
-