View Javadoc

1   package org.glassbox;
2   
3   import java.io.InputStream;
4   import java.io.IOException;
5   
6   /***
7      Builds an instance of <code>SimpleThemeProperties</code>
8      from the specified resource file.
9      @author Tilman Linden
10   */
11  public class SimpleThemeBuilder implements ThemeBuilder {
12      private InputStream _in;
13  
14      public SimpleThemeBuilder(InputStream resourcefile) {
15  	_in = resourcefile;
16      }
17  
18      public ThemeProperties build() throws IOException {
19  	try {
20  	    SimpleThemeProperties properties = new SimpleThemeProperties();
21  	    ThemeParser parser = new ThemeParser(_in);
22  	    while (parser.hasNext()) {
23  		ThemeParser.ThemeProperty property = (ThemeParser.ThemeProperty)parser.next();
24  		properties.setProperty(property.getKey(), property.getValue());
25  	    }
26  	    return properties;
27  	} catch (Exception x) {
28  	    IOException ix = new IOException("Error building ThemeProperties: "+x.getMessage());
29  	    ix.initCause(x);
30  	    throw ix;
31  	}
32      }
33  }