All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.coherentlogic.fred.client.webstart.application.ExampleFactory Maven / Gradle / Ivy

Go to download

This application demonstrates how to use the FRED Client and allows the developer to write custom queries via the FRED Client API.

There is a newer version: 1.0.11-RELEASE
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy