aQute.bnd.osgi
Class Macro

java.lang.Object
  extended by aQute.bnd.osgi.Macro

public class Macro
extends Object

Provide a macro processor. This processor 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 processor (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.


Field Summary
static String _fileHelp
           
static String _fmodifiedHelp
           
static String _nowHelp
           
static String _sizeHelp
           
 
Constructor Summary
Macro(Processor domain, Object... targets)
           
 
Method Summary
 String _apply(String[] args)
           
 String _average(String[] args)
           
 String _basename(String[] args)
           
 String _bytes(String[] args)
          Format bytes
 String _cat(String[] args)
          Get the contents of a file.
 int _compare(String[] args)
           
 String _currenttime(String[] args)
           
 String _def(String[] args)
           
 String _dir(String[] args)
           
 String _endswith(String[] args)
           
 String _env(String[] args)
           
 String _error(String[] args)
           
 String _extension(String[] args)
           
 String _filter(String[] args)
           
 String _filterout(String[] args)
           
 int _find(String[] args)
           
 int _findlast(String[] args)
           
 String _first(String[] args)
           
 String _fmodified(String[] args)
           
 String _foreach(String[] args)
           
 String _format(String[] args)
           
 String _get(String[] args)
           
 String _if(String[] args)
           
 int _indexof(String[] args)
           
 boolean _is(String[] args)
           
 String _isdir(String[] args)
           
 boolean _isempty(String[] args)
           
 String _isfile(String[] args)
           
 boolean _isnumber(String[] args)
           
 String _join(String[] args)
           
 Object _js(String[] args)
           
 String _last(String[] args)
           
 int _lastindexof(String[] args)
           
 int _length(String[] args)
           
 String _literal(String[] args)
           
 String _long2date(String[] args)
           
 String _lsa(String[] args)
           
 String _lsr(String[] args)
          Wildcard a directory.
 String _map(String[] args)
           
 boolean _matches(String[] args)
           
 String _max(String[] args)
           
 String _min(String[] args)
           
 int _ncompare(String[] args)
           
 String _nmax(String[] args)
           
 String _nmin(String[] args)
           
 Object _now(String[] args)
           
 String _nsort(String[] args)
           
 String _osfile(String[] args)
           
 String _path(String[] args)
           
 String _pathseparator(String[] args)
           
 long _rand(String[] args)
           
 String _range(String[] args)
           
 String _reject(String[] args)
           
 String _replace(String[] args)
          replace ; ; regex ; replace
 String _reverse(String[] args)
           
 String _select(String[] args)
           
 String _separator(String[] args)
           
 int _size(String[] args)
           
 String _sjoin(String[] args)
           
 String _sort(String[] args)
           
 String _split(String[] args)
           
 String _startswith(String[] args)
           
 String _sublist(String[] args)
           
 StringBuffer _subst(String[] args)
           
 String _substring(String[] args)
           
 String _sum(String[] args)
           
 String _system_allow_fail(String[] args)
           
 String _system(String[] args)
           
 String _toclassname(String[] args)
           
 String _toclasspath(String[] args)
           
 String _tolower(String[] args)
           
 String _toupper(String[] args)
           
 String _trim(String[] args)
           
 String _tstamp(String[] args)
           
 String _unescape(String[] args)
           
 String _uniq(String[] args)
           
 String _version(String[] args)
           
 String _warning(String[] args)
           
 Properties getFlattenedProperties()
          Take all the properties and translate them to actual values.
 Properties getFlattenedProperties(boolean ignoreInstructions)
          Take all the properties and translate them to actual values.
protected  String getMacro(String key, aQute.bnd.osgi.Macro.Link link)
           
static Properties getParent(Properties p)
           
static char getTerminator(char c)
           
 boolean isNosystem()
           
 String process(String line)
           
 String process(String line, Processor source)
           
 String replace(String key, aQute.bnd.osgi.Macro.Link link)
           
 boolean setNosystem(boolean nosystem)
           
 String system_internal(boolean allowFail, String[] args)
          System command.
static void verifyCommand(String[] args, String help, Pattern[] patterns, int low, int high)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nowHelp

public static final String _nowHelp
See Also:
Constant Field Values

_fmodifiedHelp

public static final String _fmodifiedHelp
See Also:
Constant Field Values

_fileHelp

public static final String _fileHelp
See Also:
Constant Field Values

_sizeHelp

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

Macro

public Macro(Processor domain,
             Object... targets)
Method Detail

process

public String process(String line,
                      Processor source)

getTerminator

public static char getTerminator(char c)

getMacro

protected String getMacro(String key,
                          aQute.bnd.osgi.Macro.Link link)

replace

public String replace(String key,
                      aQute.bnd.osgi.Macro.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)

_select

public String _select(String[] args)

_filterout

public String _filterout(String[] args)

_reject

public String _reject(String[] args)

_sort

public String _sort(String[] args)

_nsort

public String _nsort(String[] args)

_join

public String _join(String[] args)

_sjoin

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

_if

public String _if(String[] args)

_now

public Object _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)

_version

public String _version(String[] args)

_range

public String _range(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 Properties 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.

There are some rules

Returns:
A new Properties with the flattened values

getFlattenedProperties

public Properties getFlattenedProperties(boolean ignoreInstructions)
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.

Property names starting with an underscore ('_') are ignored. These are reserved for properties that cause an unwanted side effect when expanded unnecessary

Returns:
A new Properties with the flattened values

_osfile

public String _osfile(String[] args)

_path

public String _path(String[] args)

_size

public int _size(String[] args)

getParent

public static Properties getParent(Properties p)

process

public String process(String line)

isNosystem

public boolean isNosystem()

setNosystem

public boolean setNosystem(boolean nosystem)

_unescape

public String _unescape(String[] args)

_startswith

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

_endswith

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

_extension

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

_substring

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

_rand

public long _rand(String[] args)
           throws Exception
Throws:
Exception

_length

public int _length(String[] args)
            throws Exception
Throws:
Exception

_get

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

_sublist

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

_first

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

_last

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

_max

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

_min

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

_nmax

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

_nmin

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

_sum

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

_average

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

_reverse

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

_indexof

public int _indexof(String[] args)
             throws Exception
Throws:
Exception

_lastindexof

public int _lastindexof(String[] args)
                 throws Exception
Throws:
Exception

_find

public int _find(String[] args)
          throws Exception
Throws:
Exception

_findlast

public int _findlast(String[] args)
              throws Exception
Throws:
Exception

_split

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

_js

public Object _js(String[] args)
           throws Exception
Throws:
Exception

_toupper

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

_tolower

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

_compare

public int _compare(String[] args)
             throws Exception
Throws:
Exception

_ncompare

public int _ncompare(String[] args)
              throws Exception
Throws:
Exception

_matches

public boolean _matches(String[] args)
                 throws Exception
Throws:
Exception

_subst

public StringBuffer _subst(String[] args)
                    throws Exception
Throws:
Exception

_trim

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

_format

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

_isempty

public boolean _isempty(String[] args)
                 throws Exception
Throws:
Exception

_isnumber

public boolean _isnumber(String[] args)
                  throws Exception
Throws:
Exception

_is

public boolean _is(String[] args)
            throws Exception
Throws:
Exception

_map

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

_foreach

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

_apply

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

_bytes

public String _bytes(String[] args)
Format bytes



Copyright © 2014 aQute SARL. All rights reserved.