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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(java.util.Map<java.lang.String,java.lang.String> map)
void
addAll(java.util.Properties map)
void
addProperties(java.io.File file, java.util.regex.Pattern matching)
void
addProperty(java.lang.String key, java.lang.String value)
void
addTarget(java.lang.Object domain)
protected boolean
clear()
<T> T
config(java.lang.Class<?> front)
<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).java.io.File
getBase()
java.io.File
getDir(java.lang.String file, java.lang.String notfound)
java.io.File
getFile(java.lang.String file)
java.io.File
getFile(java.lang.String file, java.lang.String notfound)
Return a file relative to the base.Header
getHeader(java.lang.String header)
Header
getHeader(java.lang.String header, java.lang.String deflt)
java.util.Map<java.lang.String,java.lang.String>
getMap()
Domain
getParent()
protected java.util.Properties
getProperties()
java.lang.String
getProperty(java.lang.String key)
java.lang.String
getProperty(java.lang.String key, java.lang.String deflt)
protected boolean
isPrepared()
boolean
isTrue(java.lang.String v)
protected boolean
prepare()
java.lang.String
process(java.lang.String line)
void
putAll(java.util.Map<java.lang.String,java.lang.String> map)
void
putAll(java.util.Properties map)
void
removeProperty(java.lang.String key)
void
removeTarget(java.lang.Object domain)
void
setBase(java.io.File file)
void
setProperties(java.io.File file)
void
setProperties(java.net.URI uri)
void
setProperty(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
-
-
-
-
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)
-
isTrue
public boolean isTrue(java.lang.String v)
-
-