org.sonar.api.utils
Class System2

java.lang.Object
  extended by org.sonar.api.utils.System2

public class System2
extends Object

Proxy over System. It aims to improve testability of classes that interact with low-level system methods, for example :

 public class MyClass {
   private final System2 system;

   public MyClass(System2 s) {
     this.system = s;
   }

   public long xxx() {
     return system.now();
   }
 }

Since:
4.2

Field Summary
static System2 INSTANCE
           
 
Constructor Summary
System2()
           
 
Method Summary
 String envVariable(String key)
          Shortcut for System.getenv(String)
 Map<String,String> envVariables()
          Shortcut for System.getenv()
 boolean isOsWindows()
          True if this is MS Windows.
 long now()
          Shortcut for System.currentTimeMillis()
 void println(String obj)
           
 Properties properties()
          Shortcut for System.getProperties()
 String property(String key)
          Shortcut for System.getProperty(String)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final System2 INSTANCE
Constructor Detail

System2

public System2()
Method Detail

now

public long now()
Shortcut for System.currentTimeMillis()


properties

public Properties properties()
Shortcut for System.getProperties()


property

@CheckForNull
public String property(String key)
Shortcut for System.getProperty(String)


envVariables

public Map<String,String> envVariables()
Shortcut for System.getenv()


envVariable

@CheckForNull
public String envVariable(String key)
Shortcut for System.getenv(String)


isOsWindows

public boolean isOsWindows()
True if this is MS Windows.


println

public void println(String obj)


Copyright © 2009-2014 SonarSource. All Rights Reserved.