com.flowthings.client.api.Api Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flowthings-client-core Show documentation
Show all versions of flowthings-client-core Show documentation
A client library for flowthings.io realtime event processing
package com.flowthings.client.api;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLConnection;
import java.util.Map;
import java.util.logging.Logger;
public abstract class Api {
protected static Logger logger = Logger.getLogger("com.flow.client.api.Api");
protected String collectResponse(InputStream response) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(response));
StringBuilder out = new StringBuilder();
String s = null;
while ((s = r.readLine()) != null) {
out.append(s + '\n');
}
return out.toString();
}
protected void setRequestProperties(URLConnection connection, Map headers) {
for (Map.Entry e : headers.entrySet()) {
connection.setRequestProperty(e.getKey(), e.getValue().toString());
}
// if (logger.isLoggable(Level.INFO)) {
// for (Map.Entry e : headers.entrySet()) {
// logger.log(Level.INFO, String.format("Header:\t%s\t->\t%s", e.getKey(),
// e.getValue()));
// }
// }
}
/**
* A consistent interface for sending requests via multiple APIs
*/
public abstract FlowthingsFuture sendAsync(final Request request);
public abstract boolean supportsSubscribe();
public abstract void close();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy