Package aQute.lib.env

Class Env

All Implemented Interfaces:
Domain, Replacer, Report, Reporter, Runnable
Direct Known Subclasses:
AbstractConsoleApp

public class Env extends ReporterAdapter implements Replacer, Domain
  • Field Details

  • Constructor Details

    • Env

      public Env()
    • Env

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

      public Env(Env env)
  • Method Details

    • 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)
    • mangleMethodName

      String mangleMethodName(String prefix, String string)
    • isTrue

      public boolean isTrue(String v)