Package org.apache.sling.pipes

## Class OutputWriter

- java.lang.Object
- - org.apache.sling.pipes.OutputWriter

    public abstract class OutputWriter
    extends Object

defines how pipe's output get written to a servlet response or output stream

### Field Summary

Fields
`protected boolean` `autoClose`
`protected Map<String,​Object>` `customOutputs`
`protected List<String>` `errors`
`static String` `KEY_ERRORS`
`static String` `KEY_ITEMS`
`static String` `KEY_NB_ERRORS`
`static String` `KEY_SIZE`
`protected long` `max`
`static int` `NB_MAX`
`protected long` `nbErrors`
`protected static String` `NEW_LINE`
`static String` `PARAM_SIZE`
`static String` `PARAM_WRITER`
`static String` `PATH_KEY`
`protected Pipe` `pipe`
`protected long` `size`
`protected Writer` `writer`

### Constructor Summary

Constructors
`OutputWriter()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `autoClose()`
`protected String` `computeValue​(String key)`
`void` `disableAutoClose()`
`abstract void` `ends()` writes the end of the output
`void` `error​(String path)` Write a given error
`Map<String,​Object>` `getCustomOutputs()`
`abstract boolean` `handleRequest​(org.apache.sling.api.SlingHttpServletRequest request)`
`void` `init​(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)` Init the writer, writes beginning of the output
`protected abstract void` `initResponse​(org.apache.sling.api.SlingHttpServletResponse response)` Specifically init the response
`void` `setCustomOutputs​(Map<String,​Object> customOutputs)`
`void` `setMax​(int max)` Setter for max (will put to max if value is negative)
`void` `setPipe​(Pipe pipe)` Setter
`void` `setWriter​(Writer writer)` x Set the writer
`abstract void` `starts()` Init the writer, writes beginning of the output
`String` `toString()`
`void` `write​(org.apache.sling.api.resource.Resource resource)` Write a given resource
`protected abstract void` `writeItem​(org.apache.sling.api.resource.Resource resource)` Write a given resource

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### KEY_SIZE

    public static final String KEY_SIZE

See Also:
  Constant Field Values

#### KEY_ITEMS

    public static final String KEY_ITEMS

See Also:
  Constant Field Values

#### KEY_ERRORS

    public static final String KEY_ERRORS

See Also:
  Constant Field Values

#### KEY_NB_ERRORS

    public static final String KEY_NB_ERRORS

See Also:
  Constant Field Values

#### NEW_LINE

    protected static final String NEW_LINE

See Also:
  Constant Field Values

#### PARAM_SIZE

    public static final String PARAM_SIZE

See Also:
  Constant Field Values

#### NB_MAX

    public static final int NB_MAX

See Also:
  Constant Field Values

#### autoClose

    protected boolean autoClose

#### size

    protected long size

#### nbErrors

    protected long nbErrors

#### max

    protected long max

#### pipe

    protected Pipe pipe

#### writer

    protected Writer writer

#### PATH_KEY

    public static final String PATH_KEY

See Also:
  Constant Field Values

#### PARAM_WRITER

    public static final String PARAM_WRITER

See Also:
  Constant Field Values

#### customOutputs

    protected Map<String,​Object> customOutputs

#### errors

    protected List<String> errors

### Constructor Detail

#### OutputWriter

    public OutputWriter()

### Method Detail

#### handleRequest

    public abstract boolean handleRequest​(org.apache.sling.api.SlingHttpServletRequest request)

Parameters:
  `request` - current request
Returns:
  true if this writer handles that request

#### init

    public void init​(org.apache.sling.api.SlingHttpServletRequest request,
                     org.apache.sling.api.SlingHttpServletResponse response)
              throws IOException

Init the writer, writes beginning of the output

Parameters:
  `request` - request from which writer will output
  `response` - response on which writer will output
Throws:
  `IOException` - error handling streams

#### setCustomOutputs

    public void setCustomOutputs​(Map<String,​Object> customOutputs)

Parameters:
  `customOutputs` - custom outputs

#### initResponse

    protected abstract void initResponse​(org.apache.sling.api.SlingHttpServletResponse response)

Specifically init the response

Parameters:
  `response` - response on which to write

#### starts

    public abstract void starts()

Init the writer, writes beginning of the output

#### setMax

    public void setMax​(int max)

Setter for max (will put to max if value is negative)

Parameters:
  `max` - positive max value to set

#### setWriter

    public void setWriter​(Writer writer)

x Set the writer

Parameters:
  `writer` - writer on which to write output

#### write

    public void write​(org.apache.sling.api.resource.Resource resource)

Write a given resource

Parameters:
  `resource` - resource that will be written

#### error

    public void error​(String path)

Write a given error

Parameters:
  `path` - resource that lead to the error

#### writeItem

    protected abstract void writeItem​(org.apache.sling.api.resource.Resource resource)

Write a given resource

Parameters:
  `resource` - resource that will be written

#### ends

    public abstract void ends()

writes the end of the output

#### autoClose

    public boolean autoClose()

Returns:
  true if to be closed internally by the plumber

#### disableAutoClose

    public void disableAutoClose()

#### setPipe

    public void setPipe​(Pipe pipe)

Setter

Parameters:
  `pipe` - pipe this writer should be associated with

#### computeValue

    protected String computeValue​(String key)

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### getCustomOutputs

    public Map<String,​Object> getCustomOutputs()