aQute.lib.env
Class Env

java.lang.Object
  extended by aQute.libg.reporter.ReporterAdapter
      extended by aQute.lib.env.Env
All Implemented Interfaces:
Domain, Replacer, Report, Reporter, Runnable
Direct Known Subclasses:
AbstractConsoleApp

public class Env
extends ReporterAdapter
implements Replacer, Domain


Nested Class Summary
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
 
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
 
Constructor Summary
Env()
           
Env(Env env)
           
Env(Properties properties, Env parent, File base)
           
 
Method Summary
 void addAll(Map<String,String> map)
           
 void addAll(Properties map)
           
 void addProperties(File file, Pattern matching)
           
 void addProperty(String key, String value)
           
 void addTarget(Object domain)
           
protected  boolean clear()
           
<T> T
config(Class<?> front)
           
<T> T
config(Class<?> front, 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).
 File getBase()
           
 File getDir(String file, String notfound)
           
 File getFile(String file)
           
 File getFile(String file, String notfound)
          Return a file relative to the base.
 Header getHeader(String header)
           
 Header getHeader(String header, String deflt)
           
 Map<String,String> getMap()
           
 Domain getParent()
           
protected  Properties getProperties()
           
 String getProperty(String key)
           
 String getProperty(String key, String deflt)
           
protected  boolean isPrepared()
           
 boolean isTrue(String v)
           
protected  boolean prepare()
           
 String process(String line)
           
 void putAll(Map<String,String> map)
           
 void putAll(Properties map)
           
 void removeProperty(String key)
           
 void removeTarget(Object domain)
           
 void setBase(File file)
           
 void setProperties(File file)
           
 void setProperties(URI uri)
           
 void setProperty(String key, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Env

public Env()

Env

public Env(Properties properties,
           Env parent,
           File base)

Env

public Env(Env env)
Method Detail

process

public String process(String line)
Specified by:
process in interface Replacer

getMap

public Map<String,String> getMap()
Specified by:
getMap in interface Domain

getParent

public Domain getParent()
Specified by:
getParent in interface Domain

getProperty

public String getProperty(String key)

getProperty

public String getProperty(String key,
                          String deflt)

setProperty

public void setProperty(String key,
                        String value)

addProperty

public void addProperty(String key,
                        String value)

removeProperty

public void removeProperty(String key)

putAll

public void putAll(Map<String,String> map)

putAll

public void putAll(Properties map)

addAll

public void addAll(Map<String,String> map)

addAll

public void addAll(Properties map)

setProperties

public void setProperties(File file)
                   throws Exception
Throws:
Exception

addProperties

public void addProperties(File file,
                          Pattern matching)
                   throws Exception
Throws:
Exception

setProperties

public void setProperties(URI uri)
                   throws Exception
Throws:
Exception

getHeader

public Header getHeader(String header)

getHeader

public Header getHeader(String header,
                        String deflt)

getBase

public File getBase()

setBase

public void setBase(File file)

getFile

public File getFile(String file)

addTarget

public void addTarget(Object domain)

removeTarget

public void removeTarget(Object domain)

prepare

protected boolean prepare()
                   throws Exception
Throws:
Exception

isPrepared

protected boolean isPrepared()

clear

protected boolean clear()

getProperties

protected Properties getProperties()

getFile

public File getFile(String file,
                    String notfound)
Return a file relative to the base.


getDir

public File getDir(String file,
                   String notfound)

config

public <T> T config(Class<?> front,
                    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 interface
prefix - the prefix in the properties
Returns:
an interface that can be used to get and set properties

config

public <T> T config(Class<?> front)

isTrue

public boolean isTrue(String v)


Copyright © 2014 aQute SARL. All rights reserved.