com.coherentlogic.fred.client.webstart.application.ExampleFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fred-client-webstart-application Show documentation
Show all versions of fred-client-webstart-application Show documentation
This application demonstrates how to use the FRED Client and
allows the developer to write custom queries via the FRED Client API.
package com.coherentlogic.fred.client.webstart.application;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import com.coherentlogic.fred.client.core.factories.Factory;
/**
* A class that is used to load examples from a file which is embedded in a jar.
*
* @author Support
*/
public class ExampleFactory implements Factory {
private final String value;
public ExampleFactory (ClassPathResource resource) throws IOException {
this (resource.getInputStream());
}
public ExampleFactory (InputStream inputStream) throws IOException {
this(newStringWriter(inputStream));
}
public ExampleFactory (StringWriter writer) {
this (writer.toString());
}
public ExampleFactory (String value) {
this.value = value;
}
@Override
public String getInstance () {
return value;
}
static StringWriter newStringWriter (InputStream inputStream)
throws IOException {
StringWriter result = new StringWriter ();
IOUtils.copy(inputStream, result);
return result;
}
}