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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringTake a list and convert this to the arguments(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringstatic final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringstatic final String(package private) static final StringMap a value from a list to a new value, providing the value and the index(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final StringMap a value from a list to a new value(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringstatic final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Pattern[](package private) static final StringReturn the first list where items from the second list are removed.(package private) static final String(package private) static final String(package private) static final String(package private) static final StringReturn the first list where items not in the second list are removed.(package private) static final Stringstatic final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringtoclassname ;.class ( , .class ) * (package private) static final Stringtoclassname ;.class ( , .class ) * (package private) static final String(package private) static final String(package private) static final String(package private) static final StringReturn a unique list where the duplicates are removed.(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Pattern[](package private) static final String(package private) static final Stringprivate static final Patternprivate static final DateTimeFormatter(package private) Processorprivate static final Patternprivate static final Stringprivate static final Patternprivate static final StringParse the key as a command.(package private) booleanbooleanprivate static final Stringprivate static final Stringprivate static final Patternprivate static final StringModify a version to set a version policy.private static final Stringprivate static final Stringprivate booleanprivate static final Stringprivate static final Pattern(package private) static final Randomprivate static final PatternSchortcut for version policy(package private) Reporterprivate static final Stringprivate static final Pattern(package private) Object[]private static final Patternprivate static final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription__testdebug(String[] args) Test macro to have exceptions, only active wheninTestis active.Get the Base64 encoding of a file._basenameext(String[] args) _bndversion(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) intint_fmodified(String[] args) intbooleanbooleanbooleanint_lastindexof(String[] args) int_long2date(String[] args) booleanint_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) int_version_cleanup(String[] args) _versionmask(String[] args) private voidprivate Stringprivate StringdoCommands(String[] args, Macro.Link source) booleandoCondition(String arg) (package private) Stringprivate longGet 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 StringgetMacro(String key, Macro.Link link) private StringgetMacro(String key, List<String> args2, Macro.Link link, char begin, char end) static Propertiesstatic chargetTerminator(char c) (package private) booleanisLocalTarget(String string) booleanbooleanprivate String(package private) intprocess(CharSequence org, int index, char begin, char end, StringBuilder result, Macro.Link link, boolean inMacro) (package private) Stringprocess(CharSequence line, Macro.Link link) private StringprocessWithArgs(String template, String[] args, Macro.Link next) replace(String key, Macro.Link link) private Stringreplace(String key, List<String> args, Macro.Link link, char begin, char end) private StringbooleansetNosystem(boolean nosystem) system_internal(boolean allowFail, String[] args) System command.private StringtoString(double eval) private Stringstatic voidverifyCommand(String[] args, String help, Pattern[] patterns, int low, int high) (package private) static String
-
Field Details
-
NULLVALUE
- See Also:
-
LITERALVALUE
- See Also:
-
NUMERIC_P
-
domain
Processor domain -
reporter
Reporter reporter -
targets
Object[] targets -
flattening
boolean flattening -
nosystem
private boolean nosystem -
inTest
public boolean inTest -
macrosByClass
-
ESCAPING
Parse the key as a command. A command consist of parameters separated by ':'.- See Also:
-
SEMICOLON
- See Also:
-
ESCAPED_SEMICOLON
- See Also:
-
SEMICOLON_P
-
ESCAPED_SEMICOLON_P
-
_uniqHelp
Return a unique list where the duplicates are removed.- See Also:
-
_removeallHelp
Return the first list where items from the second list are removed.- See Also:
-
_retainallHelp
Return the first list where items not in the second list are removed.- See Also:
-
_filterHelp
- See Also:
-
_sortHelp
- See Also:
-
_nsortHelp
- See Also:
-
_joinHelp
- See Also:
-
_sjoinHelp
- See Also:
-
_ifHelp
- See Also:
-
DATE_TOSTRING
-
_nowHelp
- See Also:
-
_fmodifiedHelp
- See Also:
-
_defHelp
- See Also:
-
_listHelp
- See Also:
-
_replaceHelp
- See Also:
-
_replacelistHelp
- See Also:
-
_replacestringHelp
- See Also:
-
ANY
-
ERROR_P
-
WARNING_P
-
_toclassnameHelp
toclassname ;.class ( , .class ) * - See Also:
-
_toclasspathHelp
toclassname ;.class ( , .class ) * - See Also:
-
_lsrHelp
- See Also:
-
_lsaHelp
- See Also:
-
MASK_M
Modify a version to set a version policy. The policy is a mask that is mapped to a version.+ increment - decrement = maintain s only pos=3 (qualifier). If qualifer == SNAPSHOT, return m.m.m-SNAPSHOT else m.m.m.q s only pos=3 (qualifier). If qualifer == SNAPSHOT, return m.m.m-SNAPSHOT else m.m.m ˜ discard ==+ = maintain major, minor, increment micro, discard qualifier ˜˜˜= = just get the qualifier version="[${version;==;${@}},${version;=+;${@}})"- See Also:
-
MASK_Q
- See Also:
-
MASK_STRING
- See Also:
-
VERSION_MASK
-
_versionmaskHelp
- See Also:
-
_versionHelp
- See Also:
-
_versionPattern
-
RANGE_MASK
Schortcut for version policy-provide-policy : ${policy;[==,=+)} -consume-policy : ${policy;[==,+)} -
_rangeHelp
- See Also:
-
_rangePattern
-
LOCALTARGET_NAME
- See Also:
-
LOCALTARGET_P
-
_systemHelp
- See Also:
-
_system_allow_failHelp
- See Also:
-
_envHelp
- See Also:
-
_catHelp
- See Also:
-
_base64Help
- See Also:
-
_digestHelp
- See Also:
-
_fileHelp
- See Also:
-
_osfileHelp
- See Also:
-
_sizeHelp
- See Also:
-
_startswithHelp
- See Also:
-
_endswithHelp
- See Also:
-
_extensionHelp
- See Also:
-
_basenameextHelp
- See Also:
-
_bndversionHelp
- See Also:
-
_stemHelp
- See Also:
-
_substringHelp
- See Also:
-
_randHelp
- See Also:
-
random
-
_lengthHelp
- See Also:
-
_getHelp
- See Also:
-
_sublistHelp
- See Also:
-
_firstHelp
- See Also:
-
_lastHelp
- See Also:
-
_maxHelp
- See Also:
-
_minHelp
- See Also:
-
_nmaxHelp
- See Also:
-
_nminHelp
- See Also:
-
_vmaxHelp
- See Also:
-
_vminHelp
- See Also:
-
_sumHelp
- See Also:
-
_averageHelp
- See Also:
-
_reverseHelp
- See Also:
-
_indexofHelp
- See Also:
-
_lastindexofHelp
- See Also:
-
_findHelp
- See Also:
-
_findlastHelp
- See Also:
-
_splitHelp
- See Also:
-
_jsHelp
- See Also:
-
_toupperHelp
- See Also:
-
_tolowerHelp
- See Also:
-
_compareHelp
- See Also:
-
_ncompareHelp
- See Also:
-
_vcompareHelp
- See Also:
-
_matchesHelp
- See Also:
-
_substHelp
- See Also:
-
_trimHelp
- See Also:
-
_formatHelp
- See Also:
-
_isemptyHelp
- See Also:
-
_isnumberHelp
- See Also:
-
_isHelp
- See Also:
-
_mapHelp
Map a value from a list to a new value- See Also:
-
_foreachHelp
Map a value from a list to a new value, providing the value and the index- See Also:
-
_applyHelp
Take a list and convert this to the arguments- See Also:
-
_globHelp
- See Also:
-
_templateHelp
- See Also:
-
_decoratedHelp
- See Also:
-
_fileuriHelp
- See Also:
-
_version_cleanupHelp
- See Also:
-
-
Constructor Details
-
Macro
-
-
Method Details
-
process
-
process
-
process
int process(CharSequence org, int index, char begin, char end, StringBuilder result, Macro.Link link, boolean inMacro) -
getTerminator
public static char getTerminator(char c) -
getMacro
-
getMacro
-
processWithArgs
-
replace
-
replace
-
doCommands
-
doCommand
-
_uniq
-
_removeall
-
_retainall
-
_pathseparator
-
_separator
-
_filter
-
_select
-
_filterout
-
_reject
-
filter
-
_sort
-
_nsort
-
_join
-
_sjoin
- Throws:
Exception
-
_if
- Throws:
Exception
-
isTruthy
- Throws:
Exception
-
_now
-
_fmodified
- Throws:
Exception
-
_long2date
-
_literal
-
_def
-
_list
-
_replace
-
_replacelist
-
replace0
-
_replacestring
-
_warning
- Throws:
Exception
-
_error
- Throws:
Exception
-
_toclassname
-
_toclasspath
-
_dir
-
_basename
-
_isfile
-
_isdir
-
_tstamp
-
getBuildNow
private long getBuildNow() -
_lsr
-
_lsa
-
ls
-
_currenttime
-
_version
-
_versionmask
-
version
-
_range
-
isLocalTarget
-
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:
NoSuchAlgorithmExceptionIOException
-
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
-
_bndversion
- Throws:
Exception
-
_stem
- Throws:
Exception
-
_substring
- Throws:
Exception
-
_rand
- Throws:
Exception
-
_length
- Throws:
Exception
-
_get
- Throws:
Exception
-
_sublist
- Throws:
Exception
-
toList
-
_first
- Throws:
Exception
-
_last
- Throws:
Exception
-
_max
- Throws:
Exception
-
_min
- Throws:
Exception
-
_nmax
- Throws:
Exception
-
_nmin
- Throws:
Exception
-
_vmax
- Throws:
Exception
-
_vmin
- 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
-
toString
-
toString
-
_toupper
- Throws:
Exception
-
_tolower
- Throws:
Exception
-
_compare
- Throws:
Exception
-
_ncompare
- Throws:
Exception
-
_vcompare
- 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 -
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 wheninTestis active.- Parameters:
args- currently only 'exception'- Returns:
- nothing of valeue
- Throws:
ClassNotFoundExceptionThrowable
-
_fileuri
- Throws:
Exception
-
_version_cleanup
-