Package org.apache.sling.pipes

## Class BasePipe

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

All Implemented Interfaces:
  `Pipe`

Direct Known Subclasses:
  `AbstractInputStreamPipe`, `AbstractSlingQueryPipe`, `SuperPipe`

    public class BasePipe
    extends Object
    implements Pipe

provides generic utilities for a pipe, is also a dummy pipe (outputs its input, without changing anything)

### Field Summary

Fields
`protected String` `afterHook`
`protected String` `beforeHook`
`protected List<BindingProvider>` `bindingProviders`
`protected PipeBindings` `bindings`
`protected String` `distributionAgent`
`static String` `DRYRUN_EXPR`
`static String` `DRYRUN_KEY`
`static Iterator<org.apache.sling.api.resource.Resource>` `EMPTY_ITERATOR` Empty resource iterator
`protected static List<String>` `IGNORED_NODES`
`protected static List<String>` `IGNORED_PROPERTIES`
`protected SuperPipe` `parent`
`protected Plumber` `plumber`
`static String` `PN_AFTERHOOK`
`static String` `PN_BEFOREHOOK`
`static String` `PN_STATUS`
`static String` `PN_STATUS_MODIFIED`
`protected org.apache.sling.api.resource.ValueMap` `properties`
`static String` `READ_ONLY`
`protected org.apache.sling.api.resource.ResourceResolver` `resolver`
`protected org.apache.sling.api.resource.Resource` `resource`
`static String` `RESOURCE_TYPE`
`static String` `RT_PREFIX`
`static String` `SLASH`
`static String` `STATUS_FINISHED`
`static String` `STATUS_STARTED`

### Fields inherited from interface org.apache.sling.pipes.Pipe

`NN_CONF, PN_DISTRIBUTION_AGENT, PN_EXPR, PN_NAME, PN_PATH`

### Constructor Summary

Constructors
`BasePipe​(@NotNull Plumber plumber, @NotNull org.apache.sling.api.resource.Resource resource, @Nullable PipeBindings upperBindings)` Pipe Constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `after()` to be executed before output is retrieved
`void` `before()` to be executed before output is retrieved
`protected Iterator<org.apache.sling.api.resource.Resource>` `computeOutput()`
`PipeBindings` `getBindings()` returns the pipe's bindings
`protected String` `getComputedPath()`
`org.apache.sling.api.resource.Resource` `getConfiguration()` Get configuration node
`String` `getDistributionAgent()` Get Distribution agent
`String` `getExpr()` Get pipe's expression, instanciated or not
`@Nullable org.apache.sling.api.resource.Resource` `getInput()` Get pipe current's resource *before* next execution, meaning either the configured resource, either previous' pipe output resource
`String` `getName()` Return the name of that pipe
`Iterator<org.apache.sling.api.resource.Resource>` `getOutput()` default execution, just returns current resource
`Object` `getOutputBinding()` returns the binding output used in container pipe's expression
`SuperPipe` `getParent()`
`String` `getPath()` Get pipe's path, instanciated or not
`protected Pipe` `getPreviousPipe()` Retrieves previous pipe if contained by a parent, or referrer's
`protected org.apache.sling.api.resource.Resource` `getPreviousResource()`
`String` `getRawExpression()`
`protected String` `getRawPath()`
`org.apache.sling.api.resource.Resource` `getResource()` get the pipe configuration resource
`boolean` `isDryRun()` returns true if that pipe is set not to write content
`protected boolean` `isRootPath​(String path)`
`boolean` `modifiesContent()` returns true if that pipe modifies content during its execution
`protected void` `provideAdditionalBindings()` will execute in parallel binding providers if any, and updated Pipe bindings with returned values
`void` `setParent​(SuperPipe parent)` sets the parent pipe this pipe is referred by
`String` `toString()`

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

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

### Field Detail

#### SLASH

    public static final String SLASH

See Also:
  Constant Field Values

#### RT_PREFIX

    public static final String RT_PREFIX

See Also:
  Constant Field Values

#### RESOURCE_TYPE

    public static final String RESOURCE_TYPE

See Also:
  Constant Field Values

#### DRYRUN_KEY

    public static final String DRYRUN_KEY

See Also:
  Constant Field Values

#### DRYRUN_EXPR

    public static final String DRYRUN_EXPR

See Also:
  Constant Field Values

#### READ_ONLY

    public static final String READ_ONLY

See Also:
  Constant Field Values

#### PN_STATUS

    public static final String PN_STATUS

See Also:
  Constant Field Values

#### PN_STATUS_MODIFIED

    public static final String PN_STATUS_MODIFIED

See Also:
  Constant Field Values

#### PN_BEFOREHOOK

    public static final String PN_BEFOREHOOK

See Also:
  Constant Field Values

#### PN_AFTERHOOK

    public static final String PN_AFTERHOOK

See Also:
  Constant Field Values

#### STATUS_STARTED

    public static final String STATUS_STARTED

See Also:
  Constant Field Values

#### STATUS_FINISHED

    public static final String STATUS_FINISHED

See Also:
  Constant Field Values

#### resolver

    protected org.apache.sling.api.resource.ResourceResolver resolver

#### properties

    protected org.apache.sling.api.resource.ValueMap properties

#### resource

    protected org.apache.sling.api.resource.Resource resource

#### parent

    protected SuperPipe parent

#### distributionAgent

    protected String distributionAgent

#### bindings

    protected PipeBindings bindings

#### bindingProviders

    protected List<BindingProvider> bindingProviders

#### beforeHook

    protected String beforeHook

#### afterHook

    protected String afterHook

#### IGNORED_PROPERTIES

    protected static final List<String> IGNORED_PROPERTIES

#### IGNORED_NODES

    protected static final List<String> IGNORED_NODES

#### plumber

    protected Plumber plumber

#### EMPTY_ITERATOR

    public static final Iterator<org.apache.sling.api.resource.Resource> EMPTY_ITERATOR

Empty resource iterator

### Constructor Detail

#### BasePipe

    public BasePipe​(@NotNull
                    @NotNull Plumber plumber,
                    @NotNull
                    @NotNull org.apache.sling.api.resource.Resource resource,
                    @Nullable
                    @Nullable PipeBindings upperBindings)

Pipe Constructor

Parameters:
  `plumber` - plumber
  `resource` - configuration resource
  `upperBindings` - already set bindings, can be null

### Method Detail

#### getParent

    public SuperPipe getParent()

Specified by:
  `getParent` in interface `Pipe`
Returns:
  pipe's parent (can be null)

#### setParent

    public void setParent​(SuperPipe parent)

Description copied from interface: `Pipe`
sets the parent pipe this pipe is referred by

Specified by:
  `setParent` in interface `Pipe`
Parameters:
  `parent` - referrer that refers to this instance

#### getResource

    public org.apache.sling.api.resource.Resource getResource()

Description copied from interface: `Pipe`
get the pipe configuration resource

Specified by:
  `getResource` in interface `Pipe`
Returns:
  Pipe configruation root resource

#### isDryRun

    public boolean isDryRun()

Description copied from interface: `Pipe`
returns true if that pipe is set not to write content

Specified by:
  `isDryRun` in interface `Pipe`
Returns:
  true if dry run, false otherwise

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### modifiesContent

    public boolean modifiesContent()

Description copied from interface: `Pipe`
returns true if that pipe modifies content during its execution

Specified by:
  `modifiesContent` in interface `Pipe`
Returns:
  true for write / false for read

#### getName

    public String getName()

Description copied from interface: `Pipe`
Return the name of that pipe

Specified by:
  `getName` in interface `Pipe`
Returns:
  name of the pipe

#### getRawExpression

    public String getRawExpression()

Returns:
  configured expression (not computed)

#### getExpr

    public String getExpr()

Get pipe's expression, instanciated or not

Returns:
  configured expression

#### getRawPath

    protected String getRawPath()

Returns:
  configured input path (not computed)

#### getPath

    public String getPath()

Get pipe's path, instanciated or not

Returns:
  configured path (can be empty)

#### getComputedPath

    protected String getComputedPath()

Returns:
  computed path: getPath, with relative path taken in account

#### isRootPath

    protected boolean isRootPath​(String path)

Parameters:
  `path` - path to be checked
Returns:
  true if path is root (aka not relative)

#### getPreviousPipe

    protected Pipe getPreviousPipe()

Retrieves previous pipe if contained by a parent, or referrer's

Returns:
  pipe before this one or the referrer's can be null in case there is no parent

#### getPreviousResource

    protected org.apache.sling.api.resource.Resource getPreviousResource()

Returns:
  previous pipe's output if in a container, null otherwise

#### getInput

    @Nullable
    public @Nullable org.apache.sling.api.resource.Resource getInput()

Description copied from interface: `Pipe`
Get pipe current's resource *before* next execution, meaning either the configured resource, either previous' pipe output resource

Specified by:
  `getInput` in interface `Pipe`
Returns:
  input, configured or previous pipe

#### getOutputBinding

    public Object getOutputBinding()

Description copied from interface: `Pipe`
returns the binding output used in container pipe's expression

Specified by:
  `getOutputBinding` in interface `Pipe`
Returns:
  object, either value map or something else, that will be used in nashorn for computing expressions

#### getBindings

    public PipeBindings getBindings()

Description copied from interface: `Pipe`
returns the pipe's bindings

Specified by:
  `getBindings` in interface `Pipe`
Returns:
  PipeBindings instance containing all bindings of that pipe

#### provideAdditionalBindings

    protected void provideAdditionalBindings()
                                      throws InterruptedException,
                                             ExecutionException

will execute in parallel binding providers if any, and updated Pipe bindings with returned values

Throws:
  `InterruptedException` - can happen while a binding provider is executed
  `ExecutionException` - can happen when a binding provider is executed

#### getOutput

    public Iterator<org.apache.sling.api.resource.Resource> getOutput()

default execution, just returns current resource

Specified by:
  `getOutput` in interface `Pipe`
Returns:
  output of this pipe, which is here the input resource

#### before

    public void before()

Description copied from interface: `Pipe`
to be executed before output is retrieved

Specified by:
  `before` in interface `Pipe`

#### after

    public void after()

Description copied from interface: `Pipe`
to be executed before output is retrieved

Specified by:
  `after` in interface `Pipe`

#### computeOutput

    protected Iterator<org.apache.sling.api.resource.Resource> computeOutput()

Returns:
  outputs of the pipe, as an iterator of resources

#### getConfiguration

    public org.apache.sling.api.resource.Resource getConfiguration()

Get configuration node

Returns:
  configuration node if any

#### getDistributionAgent

    public String getDistributionAgent()

Description copied from interface: `Pipe`
Get Distribution agent

Specified by:
  `getDistributionAgent` in interface `Pipe`
Returns:
  configured distribution agent