1 package org.tanukisoftware.wrapper; 2 3 27 28 34 public final class WrapperSystemPropertyUtil 35 { 36 39 47 public static boolean getBooleanProperty( String name, boolean defaultValue ) 48 { 49 String val = System.getProperty( name ); 50 if ( val != null ) 51 { 52 if ( val.equalsIgnoreCase( "TRUE" ) ) 53 { 54 return true; 55 } 56 } 57 return false; 58 } 59 60 68 public static int getIntProperty( String name, int defaultValue ) 69 { 70 String val = System.getProperty( name ); 71 if ( val != null ) 72 { 73 try 74 { 75 return Integer.parseInt( val ); 76 } 77 catch ( NumberFormatException e ) 78 { 79 return defaultValue; 80 } 81 } 82 else 83 { 84 return defaultValue; 85 } 86 } 87 88 96 public static long getLongProperty( String name, long defaultValue ) 97 { 98 String val = System.getProperty( name ); 99 if ( val != null ) 100 { 101 try 102 { 103 return Long.parseLong( val ); 104 } 105 catch ( NumberFormatException e ) 106 { 107 return defaultValue; 108 } 109 } 110 else 111 { 112 return defaultValue; 113 } 114 } 115 116 119 122 private WrapperSystemPropertyUtil() 123 { 124 } 125 } 126 127 | Popular Tags |