Package aQute.bnd.osgi
Class Macro
java.lang.Object
aQute.bnd.osgi.Macro
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription__testdebug
(String[] args) Test macro to have exceptions, only active wheninTest
is active.Get the Base64 encoding of a file._basenameext
(String[] args) Format bytesGet the contents of a file.int
_currenttime
(String[] args) _decorated
(String[] args) Return the merged and decorated value of a macroGet a digest of a file._extension
(String[] args) _filterout
(String[] args) int
int
_fmodified
(String[] args) int
boolean
boolean
boolean
int
_lastindexof
(String[] args) int
_long2date
(String[] args) boolean
int
_pathseparator
(String[] args) long
_removeall
(String[] args) _replacelist
(String[] args) _replacestring
(String[] args) _retainall
(String[] args) _separator
(String[] args) int
_startswith
(String[] args) _substring
(String[] args) _system_allow_fail
(String[] args) Take a macro name that maps to a Parameters and expand its entries using a template._toclassname
(String[] args) _toclasspath
(String[] args) _version_cleanup
(String[] args) _versionmask
(String[] args) boolean
doCondition
(String arg) Get all the commands availableTake all the properties and translate them to actual values.getFlattenedProperties
(boolean ignoreInstructions) Take all the properties and translate them to actual values.protected String
static Properties
static char
getTerminator
(char c) boolean
boolean
boolean
setNosystem
(boolean nosystem) system_internal
(boolean allowFail, String[] args) System command.static void
verifyCommand
(String[] args, String help, Pattern[] patterns, int low, int high)
-
Field Details
-
inTest
public boolean inTest -
_nowHelp
- See Also:
-
_fmodifiedHelp
- See Also:
-
_fileHelp
- See Also:
-
_sizeHelp
- See Also:
-
-
Constructor Details
-
Macro
-
-
Method Details
-
process
-
getTerminator
public static char getTerminator(char c) -
getMacro
-
replace
-
_uniq
-
_removeall
-
_retainall
-
_pathseparator
-
_separator
-
_filter
-
_select
-
_filterout
-
_reject
-
_sort
-
_nsort
-
_join
-
_sjoin
- Throws:
Exception
-
_if
- Throws:
Exception
-
isTruthy
- Throws:
Exception
-
_now
-
_fmodified
- Throws:
Exception
-
_long2date
-
_literal
-
_def
-
_list
-
_replace
-
_replacelist
-
_replacestring
-
_warning
- Throws:
Exception
-
_error
- Throws:
Exception
-
_toclassname
-
_toclasspath
-
_dir
-
_basename
-
_isfile
-
_isdir
-
_tstamp
-
_lsr
-
_lsa
-
_currenttime
-
_version
-
_versionmask
-
_range
-
system_internal
System command. Execute a command and insert the result.- Throws:
Exception
-
_system
- Throws:
Exception
-
_system_allow_fail
- Throws:
Exception
-
_env
-
_cat
Get the contents of a file.- Throws:
IOException
-
_base64
Get the Base64 encoding of a file.- Throws:
IOException
-
_digest
Get a digest of a file.- Throws:
NoSuchAlgorithmException
IOException
-
verifyCommand
-
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
- Property names starting with an underscore ('_') are ignored. These are reserved for properties that cause an unwanted side effect when expanded unnecessary
- Property names starting with a minus sign ('-') are not expanded to maintain readability
- Returns:
- A new Properties with the flattened values
-
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.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
-
_path
-
_size
-
getParent
-
process
-
isNosystem
public boolean isNosystem() -
setNosystem
public boolean setNosystem(boolean nosystem) -
_unescape
-
_startswith
- Throws:
Exception
-
_endswith
- Throws:
Exception
-
_extension
- Throws:
Exception
-
_basenameext
- Throws:
Exception
-
_stem
- Throws:
Exception
-
_substring
- Throws:
Exception
-
_rand
- Throws:
Exception
-
_length
- Throws:
Exception
-
_get
- Throws:
Exception
-
_sublist
- Throws:
Exception
-
_first
- Throws:
Exception
-
_last
- Throws:
Exception
-
_max
- Throws:
Exception
-
_min
- Throws:
Exception
-
_nmax
- Throws:
Exception
-
_nmin
- Throws:
Exception
-
_sum
- Throws:
Exception
-
_average
- Throws:
Exception
-
_reverse
- Throws:
Exception
-
_indexof
- Throws:
Exception
-
_lastindexof
- Throws:
Exception
-
_find
- Throws:
Exception
-
_findlast
- Throws:
Exception
-
_split
- Throws:
Exception
-
_js
- Throws:
Exception
-
_toupper
- Throws:
Exception
-
_tolower
- Throws:
Exception
-
_compare
- Throws:
Exception
-
_ncompare
- Throws:
Exception
-
_matches
- Throws:
Exception
-
_subst
- Throws:
Exception
-
_trim
- Throws:
Exception
-
_format
- Throws:
Exception
-
_isempty
- Throws:
Exception
-
_isnumber
- Throws:
Exception
-
_is
- Throws:
Exception
-
_map
- Throws:
Exception
-
_foreach
- Throws:
Exception
-
_apply
- Throws:
Exception
-
_bytes
Format bytes -
_glob
-
doCondition
- Throws:
Exception
-
getCommands
Get all the commands available- Returns:
- a map with commands and their help
-
_template
Take a macro name that maps to a Parameters and expand its entries using a template. The macro takes a macro name. It will merge and decorate this name before it applies it to the template. Each entry is mapped to the template. The template can use${@}
for the key and${@attribute}
for attributes.It would be nice to take the parameters value directly but this is really hard to do with the quoting. That is why we use a name. It is always possible to have an intermediate macro
- Parameters:
args
- 'template', macro-name of Parameters, template, separator=','- Returns:
- the expanded template.
- Throws:
IOException
-
_decorated
Return the merged and decorated value of a macro- Throws:
Exception
-
__testdebug
Test macro to have exceptions, only active wheninTest
is active.- Parameters:
args
- currently only 'exception'- Returns:
- nothing of valeue
- Throws:
ClassNotFoundException
Throwable
-
_fileuri
- Throws:
Exception
-
_version_cleanup
-