aQute.libg.sed
Class ReplacerAdapter

java.lang.Object
  extended by aQute.libg.reporter.ReporterAdapter
      extended by aQute.libg.sed.ReplacerAdapter
All Implemented Interfaces:
Replacer, Report, Reporter, Runnable

public class ReplacerAdapter
extends ReporterAdapter
implements Replacer

Provide a macro Domain. This Domain can replace variables in strings based on a properties and a domain. The domain can implement functions that start with a "_" and take args[], the names of these functions are available as functions in the macro Domain (without the _). Macros can nest to any depth but may not contain loops. Add POSIX macros: ${#parameter} String length. ${parameter%word} Remove smallest suffix pattern. ${parameter%%word} Remove largest suffix pattern. ${parameter#word} Remove smallest prefix pattern. ${parameter##word} Remove largest prefix pattern.


Nested Class Summary
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
 
Field Summary
static String _fileHelp
           
static String _fmodifiedHelp
           
 
Constructor Summary
ReplacerAdapter(Domain domain)
           
ReplacerAdapter(Map<String,String> domain)
           
 
Method Summary
 String _basename(String[] args)
           
 String _bytes(String[] args)
          Format bytes
 String _cat(String[] args)
          Get the contents of a file.
 String _currenttime(String[] args)
           
 String _def(String[] args)
           
 String _dir(String[] args)
           
 String _env(String[] args)
           
 String _error(String[] args)
           
 String _filter(String[] args)
           
 String _filterout(String[] args)
           
 String _fmodified(String[] args)
           
 long _freeMemory(String[] args)
           
 String _if(String[] args)
           
 String _isdir(String[] args)
           
 String _isfile(String[] args)
           
 String _join(String[] args)
           
 String _literal(String[] args)
           
 String _long2date(String[] args)
           
 String _lsa(String[] args)
           
 String _lsr(String[] args)
          Wildcard a directory.
 long _maxMemory(String[] args)
           
 long _nanoTime(String[] args)
           
 String _now(String[] args)
           
 String _nsort(String[] args)
           
 String _osfile(String[] args)
           
 String _path(String[] args)
           
 String _pathseparator(String[] args)
           
 int _processors(String[] args)
           
 String _random(String[] args)
          Generate a random string, which is guaranteed to be a valid Java identifier (first character is an ASCII letter, subsequent characters are ASCII letters or numbers).
 String _replace(String[] args)
          replace ; ; regex ; replace
 String _separator(String[] args)
           
 String _sort(String[] args)
           
 String _system_allow_fail(String[] args)
           
 String _system(String[] args)
           
 String _toclassname(String[] args)
           
 String _toclasspath(String[] args)
           
 String _tstamp(String[] args)
           
 String _unescape(String[] args)
           
 String _uniq(String[] args)
           
 String _warning(String[] args)
           
 void addTarget(Object target)
           
 int findMacro(CharSequence line, int index)
          Traverses a string to find a macro.
 Map<String,String> getFlattenedProperties()
          Take all the properties and translate them to actual values.
static Properties getParent(Properties p)
           
 String getProcessed(String key)
           
static char getTerminator(char c)
           
 String process(String line)
           
 String process(String line, Domain source)
           
 void removeTarget(Object target)
           
protected  String replace(String key, aQute.libg.sed.ReplacerAdapter.Link link)
           
 void setReporter(Reporter reporter)
           
 String system_internal(boolean allowFail, String[] args)
          System command.
 ReplacerAdapter target(File base)
           
 ReplacerAdapter target(Object target)
           
static void verifyCommand(String[] args, String help, Pattern[] patterns, int low, int high)
           
 
Methods inherited from class aQute.libg.reporter.ReporterAdapter
addErrors, addWarnings, check, error, exception, getErrors, getInfo, getInfo, getLocation, getMessages, getOut, getWarnings, isExceptions, isOk, isPedantic, isPerfect, isTrace, progress, report, run, setExceptions, setPedantic, setTrace, trace, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_fmodifiedHelp

public static final String _fmodifiedHelp
See Also:
Constant Field Values

_fileHelp

public static final String _fileHelp
See Also:
Constant Field Values
Constructor Detail

ReplacerAdapter

public ReplacerAdapter(Domain domain)

ReplacerAdapter

public ReplacerAdapter(Map<String,String> domain)
Method Detail

target

public ReplacerAdapter target(Object target)

target

public ReplacerAdapter target(File base)

process

public String process(String line,
                      Domain source)

findMacro

public int findMacro(CharSequence line,
                     int index)
Traverses a string to find a macro. It can handle nested brackets.

Parameters:
line - The line with the macro
index - Points to the character after the '$'
Returns:
the end position

getTerminator

public static char getTerminator(char c)

getProcessed

public String getProcessed(String key)

replace

protected String replace(String key,
                         aQute.libg.sed.ReplacerAdapter.Link link)

_uniq

public String _uniq(String[] args)

_pathseparator

public String _pathseparator(String[] args)

_separator

public String _separator(String[] args)

_filter

public String _filter(String[] args)

_filterout

public String _filterout(String[] args)

_sort

public String _sort(String[] args)

_nsort

public String _nsort(String[] args)

_join

public String _join(String[] args)

_if

public String _if(String[] args)

_now

public String _now(String[] args)

_fmodified

public String _fmodified(String[] args)
                  throws Exception
Throws:
Exception

_long2date

public String _long2date(String[] args)

_literal

public String _literal(String[] args)

_def

public String _def(String[] args)

_replace

public String _replace(String[] args)
replace ; ; regex ; replace

Parameters:
args -
Returns:

_warning

public String _warning(String[] args)

_error

public String _error(String[] args)

_toclassname

public String _toclassname(String[] args)

_toclasspath

public String _toclasspath(String[] args)

_dir

public String _dir(String[] args)

_basename

public String _basename(String[] args)

_isfile

public String _isfile(String[] args)

_isdir

public String _isdir(String[] args)

_tstamp

public String _tstamp(String[] args)

_lsr

public String _lsr(String[] args)
Wildcard a directory. The lists can contain Instruction that are matched against the given directory ${lsr;;(;)*} ${lsa;;(;)*}


_lsa

public String _lsa(String[] args)

_currenttime

public String _currenttime(String[] args)

system_internal

public String system_internal(boolean allowFail,
                              String[] args)
                       throws Exception
System command. Execute a command and insert the result.

Parameters:
args -
help -
patterns -
low -
high -
Throws:
Exception

_system

public String _system(String[] args)
               throws Exception
Throws:
Exception

_system_allow_fail

public String _system_allow_fail(String[] args)
                          throws Exception
Throws:
Exception

_env

public String _env(String[] args)

_cat

public String _cat(String[] args)
            throws IOException
Get the contents of a file.

Parameters:
in -
Returns:
Throws:
IOException

verifyCommand

public static void verifyCommand(String[] args,
                                 String help,
                                 Pattern[] patterns,
                                 int low,
                                 int high)

getFlattenedProperties

public Map<String,String> getFlattenedProperties()
Take all the properties and translate them to actual values. This method takes the set properties and traverse them over all entries, including the default properties for that properties. The values no longer contain macros.

Returns:
A new Properties with the flattened values

_osfile

public String _osfile(String[] args)

_path

public String _path(String[] args)

getParent

public static Properties getParent(Properties p)

process

public String process(String line)
Specified by:
process in interface Replacer

_random

public String _random(String[] args)
Generate a random string, which is guaranteed to be a valid Java identifier (first character is an ASCII letter, subsequent characters are ASCII letters or numbers). Takes an optional parameter for the length of string to generate; default is 8 characters.


setReporter

public void setReporter(Reporter reporter)

_processors

public int _processors(String[] args)

_maxMemory

public long _maxMemory(String[] args)

_freeMemory

public long _freeMemory(String[] args)

_nanoTime

public long _nanoTime(String[] args)

addTarget

public void addTarget(Object target)

removeTarget

public void removeTarget(Object target)

_unescape

public String _unescape(String[] args)

_bytes

public String _bytes(String[] args)
Format bytes



Copyright © 2014 aQute SARL. All rights reserved.