Package com.composum.sling.core.util
Class ValueEmbeddingWriter
- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- com.composum.sling.core.util.ValueEmbeddingWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class ValueEmbeddingWriter extends FilterWriter
a filter writer implementation to embed values from a value map for written placeholders
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ValueEmbeddingWriter.TextWriter
protected class
ValueEmbeddingWriter.ValueWriter
-
Field Summary
Fields Modifier and Type Field Description protected boolean
keepUnresolvable
protected Locale
locale
protected ResourceBundle
resourceBundle
protected Class<?>
resourceContext
protected org.apache.sling.api.resource.ValueMap
values
protected Writer
wrappedWriter
protected Stack<com.composum.sling.core.util.ValueEmbeddingWriter.TokenWriter>
writerStack
-
Fields inherited from class java.io.FilterWriter
out
-
-
Constructor Summary
Constructors Constructor Description ValueEmbeddingWriter(@NotNull Writer writer, @NotNull Map<String,Object> values)
Creates a tag filtering reader to filter out the tags configured as sets of tag namesValueEmbeddingWriter(@NotNull Writer writer, @NotNull Map<String,Object> values, @Nullable Locale locale, @Nullable Class<?> resourceContext)
Creates a tag filtering reader to filter out the tags configured as sets of tag namesValueEmbeddingWriter(@NotNull Writer writer, @NotNull Map<String,Object> values, @Nullable Locale locale, @Nullable Class<?> resourceContext, @Nullable ResourceBundle resourceBundle)
Creates a tag filtering reader to filter out the tags configured as sets of tag names
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
boolean
isKeepUnresolvable(boolean... decision)
void
pass(char[] cbuf, int off, int len)
void
pass(int chr)
void
pass(String str)
void
pass(String str, int off, int len)
void
write(char[] cbuf, int off, int len)
uses the single token read() method to fill the buffervoid
write(int token)
void
write(String str, int off, int len)
-
Methods inherited from class java.io.FilterWriter
close
-
-
-
-
Field Detail
-
wrappedWriter
protected final Writer wrappedWriter
-
values
protected final org.apache.sling.api.resource.ValueMap values
-
locale
protected final Locale locale
-
resourceContext
protected final Class<?> resourceContext
-
resourceBundle
protected final ResourceBundle resourceBundle
-
keepUnresolvable
protected boolean keepUnresolvable
-
writerStack
protected final Stack<com.composum.sling.core.util.ValueEmbeddingWriter.TokenWriter> writerStack
-
-
Constructor Detail
-
ValueEmbeddingWriter
public ValueEmbeddingWriter(@NotNull @NotNull Writer writer, @NotNull @NotNull Map<String,Object> values)
Creates a tag filtering reader to filter out the tags configured as sets of tag names- Parameters:
writer
- the writer to filtervalues
- the set of available placeholders
-
ValueEmbeddingWriter
public ValueEmbeddingWriter(@NotNull @NotNull Writer writer, @NotNull @NotNull Map<String,Object> values, @Nullable @Nullable Locale locale, @Nullable @Nullable Class<?> resourceContext)
Creates a tag filtering reader to filter out the tags configured as sets of tag names- Parameters:
writer
- the writer to filtervalues
- the set of available placeholderslocale
- the locale to use for value formattingresourceContext
- the context class for resource loading
-
ValueEmbeddingWriter
public ValueEmbeddingWriter(@NotNull @NotNull Writer writer, @NotNull @NotNull Map<String,Object> values, @Nullable @Nullable Locale locale, @Nullable @Nullable Class<?> resourceContext, @Nullable @Nullable ResourceBundle resourceBundle)
Creates a tag filtering reader to filter out the tags configured as sets of tag names- Parameters:
writer
- the writer to filtervalues
- the set of available placeholderslocale
- the locale to use for value formattingresourceContext
- the context class for resource loadingresourceBundle
- the translations bundle (switches translation on)
-
-
Method Detail
-
isKeepUnresolvable
public boolean isKeepUnresolvable(boolean... decision)
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterWriter
- Throws:
IOException
-
write
public void write(int token) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException
uses the single token read() method to fill the buffer- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
pass
public void pass(String str) throws IOException
- Throws:
IOException
-
pass
public void pass(String str, int off, int len) throws IOException
- Throws:
IOException
-
pass
public void pass(char[] cbuf, int off, int len) throws IOException
- Throws:
IOException
-
pass
public void pass(int chr) throws IOException
- Throws:
IOException
-
-