1 23 24 29 30 package com.sun.appserv.management.util.misc; 31 32 import java.util.Properties ; 33 import java.io.File ; 34 import java.io.FileInputStream ; 35 import java.io.IOException ; 36 37 40 public class PropertiesStringSource extends StringSourceBase implements StringSource 41 { 42 final Properties mProperties; 43 44 public 45 PropertiesStringSource( final Properties props, StringSource delegate ) 46 { 47 super( delegate ); 48 assert( props != null ); 49 mProperties = props; 50 } 51 52 static private Properties 53 propsFromFile( final File propsFile ) 54 throws IOException 55 { 56 final Properties props = new Properties (); 57 props.load( new FileInputStream ( propsFile ) ); 58 return( props ); 59 } 60 61 public 62 PropertiesStringSource( final File propsFile, StringSource delegate ) 63 throws IOException 64 { 65 this( propsFromFile( propsFile ), delegate ); 66 } 67 68 public String 69 getString( String id, String defaultValue ) 70 { 71 final String result = mProperties.getProperty( id, defaultValue ); 72 return( result ); 73 } 74 75 public final static String STRINGS_NAME = "strings"; 76 77 }; 78 79 80 81 | Popular Tags |