|
1 |
| package com.agical.rdoc.core.converter.impl; |
|
2 |
| |
|
3 |
| import java.io.IOException; |
|
4 |
| import java.io.InputStream; |
|
5 |
| import java.util.Iterator; |
|
6 |
| import java.util.Properties; |
|
7 |
| |
|
8 |
| import com.agical.rdoc.core.converter.ConversionException; |
|
9 |
| import com.agical.rdoc.core.converter.InputStreamConverter; |
|
10 |
| import com.agical.rdoc.util.SimpleEscapeHandler; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| public class EscapeHandlerConverter implements InputStreamConverter { |
|
18 |
| |
|
19 |
1
| public Object convert(InputStream stream) throws ConversionException {
|
|
20 |
1
| try {
|
|
21 |
1
| Properties properties = new Properties();
|
|
22 |
1
| properties.load( stream );
|
|
23 |
1
| SimpleEscapeHandler escapeHandler = new SimpleEscapeHandler();
|
|
24 |
1
| for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) {
|
|
25 |
1
| String key = (String) iter.next();
|
|
26 |
1
| escapeHandler.setEscape( key, properties.getProperty(key) );
|
|
27 |
| } |
|
28 |
1
| return escapeHandler;
|
|
29 |
| } catch (IOException e) { |
|
30 |
0
| throw new ConversionException( "Could not read properties from stream" );
|
|
31 |
| } |
|
32 |
| } |
|
33 |
| |
|
34 |
| } |