Package aQute.lib.env
Class Env
- java.lang.Object
-
- aQute.libg.reporter.ReporterAdapter
-
- aQute.lib.env.Env
-
- Direct Known Subclasses:
AbstractConsoleApp
public class Env extends ReporterAdapter implements Replacer, Domain
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
-
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.Filebase(package private) Envparent(package private) booleanprepared(package private) java.util.Propertiesproperties(package private) ReplacerAdapterreplacer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(java.util.Map<java.lang.String,java.lang.String> map)voidaddAll(java.util.Properties map)voidaddProperties(java.io.File file, java.util.regex.Pattern matching)voidaddProperty(java.lang.String key, java.lang.String value)voidaddTarget(java.lang.Object domain)protected booleanclear()<T> Tconfig(java.lang.Class<?> front)<T> Tconfig(java.lang.Class<?> front, java.lang.String prefix)This method returns an interface that can be used to get and set the properties in a type safe way (as well as describing any semantics of these properties).java.io.FilegetBase()java.io.FilegetDir(java.lang.String file, java.lang.String notfound)java.io.FilegetFile(java.lang.String file)java.io.FilegetFile(java.lang.String file, java.lang.String notfound)Return a file relative to the base.HeadergetHeader(java.lang.String header)HeadergetHeader(java.lang.String header, java.lang.String deflt)java.util.Map<java.lang.String,java.lang.String>getMap()DomaingetParent()protected java.util.PropertiesgetProperties()java.lang.StringgetProperty(java.lang.String key)java.lang.StringgetProperty(java.lang.String key, java.lang.String deflt)protected booleanisPrepared()booleanisTrue(java.lang.String v)(package private) java.lang.StringmangleMethodName(java.lang.String prefix, java.lang.String string)protected booleanprepare()java.lang.Stringprocess(java.lang.String line)voidputAll(java.util.Map<java.lang.String,java.lang.String> map)voidputAll(java.util.Properties map)voidremoveProperty(java.lang.String key)voidremoveTarget(java.lang.Object domain)voidsetBase(java.io.File file)voidsetProperties(java.io.File file)voidsetProperties(java.net.URI uri)voidsetProperty(java.lang.String key, java.lang.String value)-
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
-
-
-
-
Field Detail
-
properties
final java.util.Properties properties
-
replacer
final ReplacerAdapter replacer
-
parent
final Env parent
-
base
java.io.File base
-
prepared
boolean prepared
-
-
Method Detail
-
process
public java.lang.String process(java.lang.String line)
-
getMap
public java.util.Map<java.lang.String,java.lang.String> getMap()
-
getProperty
public java.lang.String getProperty(java.lang.String key)
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String deflt)
-
setProperty
public void setProperty(java.lang.String key, java.lang.String value)
-
addProperty
public void addProperty(java.lang.String key, java.lang.String value)
-
removeProperty
public void removeProperty(java.lang.String key)
-
putAll
public void putAll(java.util.Map<java.lang.String,java.lang.String> map)
-
putAll
public void putAll(java.util.Properties map)
-
addAll
public void addAll(java.util.Map<java.lang.String,java.lang.String> map)
-
addAll
public void addAll(java.util.Properties map)
-
setProperties
public void setProperties(java.io.File file) throws java.lang.Exception- Throws:
java.lang.Exception
-
addProperties
public void addProperties(java.io.File file, java.util.regex.Pattern matching) throws java.lang.Exception- Throws:
java.lang.Exception
-
setProperties
public void setProperties(java.net.URI uri) throws java.lang.Exception- Throws:
java.lang.Exception
-
getHeader
public Header getHeader(java.lang.String header)
-
getHeader
public Header getHeader(java.lang.String header, java.lang.String deflt)
-
getBase
public java.io.File getBase()
-
setBase
public void setBase(java.io.File file)
-
getFile
public java.io.File getFile(java.lang.String file)
-
addTarget
public void addTarget(java.lang.Object domain)
-
removeTarget
public void removeTarget(java.lang.Object domain)
-
prepare
protected boolean prepare() throws java.lang.Exception- Throws:
java.lang.Exception
-
isPrepared
protected boolean isPrepared()
-
clear
protected boolean clear()
-
getProperties
protected java.util.Properties getProperties()
-
getFile
public java.io.File getFile(java.lang.String file, java.lang.String notfound)Return a file relative to the base.
-
getDir
public java.io.File getDir(java.lang.String file, java.lang.String notfound)
-
config
public <T> T config(java.lang.Class<?> front, java.lang.String prefix)This method returns an interface that can be used to get and set the properties in a type safe way (as well as describing any semantics of these properties). The interface must have get and/or set methods. The name is mangled to change _ to . and to remove $ (which is used to mask keywords like new). If _ and $ are in there twice, one remains. The set methods return the proxy object itself so you can use it in a builder style. The values are always stored as strings (and can use macros). The result is converted to the desired type. Arguments in the set methods are always converted to strings using the toString methods. Example:interface MyConfig { int level(); MyConfig level(int level); Pattern pattern(); MyConfig pattern(String p); } Env env = ... MyConfig c = env.config(MyConfig.class, "myconfig.");- Parameters:
front- the fronting interfaceprefix- the prefix in the properties- Returns:
- an interface that can be used to get and set properties
-
config
public <T> T config(java.lang.Class<?> front)
-
mangleMethodName
java.lang.String mangleMethodName(java.lang.String prefix, java.lang.String string)
-
isTrue
public boolean isTrue(java.lang.String v)
-
-