ReplaceTokens

Extends \BaseParamFilterReader Implements \ChainableReader

Replaces tokens in the original input with user-supplied values.

Example:

;
  

Or:


  
  
  
author

Yannick Lecaillez

author

hans lellelid, hans@velum.net

version

$Id: ae4146ab218b4aeb4b7cfc46338f074d1e70b14b $

access

public

see
package

phing.filters

Methods

__construct

__construct(\Reader $in = null) 
inherited

Arguments

$in

\Reader

Initializes tokens and loads the replacee-replacer hashtable.

_initialize() 

This method is only called when this filter is used through a tag in build file.

Creates a new ReplaceTokens using the passed in Reader for instantiation.

chain(\Reader $reader) : object

Arguments

$reader

\Reader

Response

object

A new filter based on this configuration, but filtering

    the specified reader

Close stream.

close() 
inherited abstract
throws

if there is an error closing stream

Adds a token element to the map of tokens to replace.

createToken() : object

Response

object

The token added to the map of replacements.

          Must not be <code>null</code>.

Adds a token source to the sources of this filter.

createTokensource() : object

Response

object

A Reference to the source just added.

Returns whether the end of file has been reached with input stream.

eof() : boolean
inherited

Response

boolean

Returns the "begin token" character.

getBeginToken() : string

Response

string

The character used to denote the beginning of a token.

Returns the "end token" character.

getEndToken() : \the

Response

\the

character used to denote the beginning of a token

Returns the initialized status.

getInitialized() : boolean
inherited

Response

boolean

whether or not the filter is initialized

getParameters

getParameters() 
inherited

Returns the project this filter is part of.

getProject() : object
inherited

Response

object

The project this filter is part of

Returns the filename, url, etc. that is being read from.

getResource() : string
inherited abstract

This is critical for, e.g., ExpatParser's ability to know the filename that is throwing an ExpatParserException, etc.

Response

string

Returns the map of tokens which will be replaced.

getTokens() : array

; used by ReplaceTokens::chain()

Response

array

A map (String->String) of token keys to replacement values.

Returns the token sources used by this filter; used by ReplaceTokens::chain()

getTokensources() : array

Response

array

Convenience method to support logging in filters.

log(string $msg, integer $level = \Project::MSG_INFO) 
inherited

Arguments

$msg

string

Message to log.

$level

integer

Priority level.

If supported, places a "marker" (like a bookmark) at current stream position.

mark() 
inherited

A subsequent call to reset() will move stream position back to last marker (if supported).

Whether marking is supported.

markSupported() : boolean
inherited

Response

boolean

Read data from source.

read(integer $len = null) 
inherited abstract

If length is specified, then only that number of chars is read, otherwise stream is read until EOF.

Arguments

$len

integer

Reads a line of text ending with '\n' (or until the end of the stream).

readLine() : \the
inherited

The returned String retains the '\n'.

throws

if the underlying reader throws one during

                   reading

Response

\the

line read, or null if the end of the stream has already been reached

Is stream ready for reading.

ready() : boolean
inherited

Response

boolean

Performs lookup on key and returns appropriate replacement string.

replaceTokenCallback(array $matches) : string
access

private

Arguments

$matches

array

Array of 1 el containing key to search for.

Response

string

Text with which to replace key or value of key if none is found.

Reset the current position in stream to beginning or last mark (if supported).

reset() 
inherited

Sets the "begin token" character.

setBeginToken(string $beginToken) 

Arguments

$beginToken

string

the character used to denote the beginning of a token.

Sets the "end token" character.

setEndToken(string $endToken) 

Arguments

$endToken

string

the character used to denote the end of a token

Sets the initialized status.

setInitialized(boolean $initialized) 
inherited

Arguments

$initialized

boolean

Whether or not the filter is initialized.

setParameters

setParameters( $parameters) 
inherited

Arguments

$parameters

Sets the project to work with.

setProject(object $project) 
inherited

Arguments

$project

object

The project this filter is part of.

           Should not be <code>null</code>.

setReader

setReader(\Reader $in) 
inherited

Arguments

$in

\Reader

Sets the map of tokens to replace.

setTokens( $tokens) 

; used by ReplaceTokens::chain()

Arguments

$tokens

Sets the tokensources to use; used by ReplaceTokens::chain()

setTokensources( $sources) 

Arguments

$sources

Move stream position relative to current pos.

skip(integer $n) 
inherited

Arguments

$n

integer

Constants

Default "begin token" character.

DEFAULT_BEGIN_TOKEN
var

Default "end token" character.

DEFAULT_END_TOKEN
var

Properties

[Deprecated] Data that must be read from, if not null.

_queuedData : string
var

Type(s)

string

Array to hold the replacee-replacer pairs (String to String).

_tokens : array
var

Type(s)

array

Array to hold the token sources that make tokens from different sources available

_tokensources : array
var

Type(s)

array

Array holding all tokens given directly to the Filter and those passed via a TokenSource.

_alltokens : array
var

Type(s)

array

Character marking the beginning of a token.

_beginToken : string
var

Type(s)

string

Character marking the end of a token.

_endToken : string
var

Type(s)

string

The passed in parameter array.

_parameters : 
inherited

Type(s)

Have the parameters passed been interpreted?

initialized : 
inherited

Type(s)

The Phing project this filter is part of.

project : 
inherited

Type(s)

in

in : \Reader
inherited
var

Type(s)

\Reader