View Javadoc
1   package org.kuali.common.devops.metadata.function;
2   
3   import static org.kuali.common.util.Encodings.UTF8;
4   import static org.kuali.common.util.base.Precondition.checkNotNull;
5   
6   import java.io.ByteArrayInputStream;
7   import java.util.Properties;
8   
9   import org.kuali.common.util.properties.rice.RiceLoader;
10  
11  import com.google.common.base.Function;
12  
13  public class RicePropertiesFunction implements Function<String, Properties> {
14  
15  	@Override
16  	public Properties apply(String content) {
17  		return getProperties(checkNotNull(content, "content"));
18  	}
19  
20  	protected Properties getProperties(String content) {
21  		try {
22  			ByteArrayInputStream in = new ByteArrayInputStream(content.getBytes(UTF8));
23  			return RiceLoader.load(in);
24  		} catch (Exception e) {
25  			// TODO Don't do this
26  			e.printStackTrace();
27  			return new Properties();
28  		}
29  	}
30  
31  }