repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
tomzo/gocd-yaml-config-plugin | src/main/java/cd/go/plugin/config/yaml/YamlConfigPlugin.java | // Path: src/main/java/cd/go/plugin/config/yaml/transforms/RootTransform.java
// public class RootTransform {
// private PipelineTransform pipelineTransform;
// private EnvironmentsTransform environmentsTransform;
//
// public RootTransform() {
// EnvironmentVariablesTransform environmentVarsTransform = new EnvironmentVariablesTransform();
// MaterialTransform material = new MaterialTransform();
// ParameterTransform parameterTransform = new ParameterTransform();
// JobTransform job = new JobTransform(environmentVarsTransform, new TaskTransform());
// StageTransform stage = new StageTransform(environmentVarsTransform, job);
// this.pipelineTransform = new PipelineTransform(material, stage, environmentVarsTransform, parameterTransform);
// this.environmentsTransform = new EnvironmentsTransform(environmentVarsTransform);
// }
//
// public RootTransform(PipelineTransform pipelineTransform, EnvironmentsTransform environmentsTransform) {
// this.pipelineTransform = pipelineTransform;
// this.environmentsTransform = environmentsTransform;
// }
//
// public String inverseTransformPipeline(Map<String, Object> pipeline) {
// Map<String, Object> result = new LinkedTreeMap<>();
// result.put("format_version", 10);
// result.put("pipelines", pipelineTransform.inverseTransform(pipeline));
// return YamlUtils.dump(result);
// }
//
// public JsonConfigCollection transform(Object rootObj, String location) {
// JsonConfigCollection partialConfig = new JsonConfigCollection();
// Map<String, Object> rootMap = (Map<String, Object>) rootObj;
// // must obtain format_version first
// int formatVersion = 1;
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("format_version".equalsIgnoreCase(pe.getKey())) {
// formatVersion = Integer.valueOf((String) pe.getValue());
// partialConfig.updateFormatVersionFound(formatVersion);
// }
// }
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("pipelines".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> pipelines = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> pipe : pipelines.entrySet()) {
// try {
// JsonElement jsonPipeline = pipelineTransform.transform(pipe, formatVersion);
// partialConfig.addPipeline(jsonPipeline, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse pipeline %s; %s", pipe.getKey(), ex.getMessage()), location));
// }
// }
// } else if ("environments".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> environments = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> env : environments.entrySet()) {
// try {
// JsonElement jsonEnvironment = environmentsTransform.transform(env);
// partialConfig.addEnvironment(jsonEnvironment, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse environment %s; %s", env.getKey(), ex.getMessage()), location));
// }
// }
// } else if (!"common".equalsIgnoreCase(pe.getKey()) && !"format_version".equalsIgnoreCase(pe.getKey()))
// throw new YamlConfigException(pe.getKey() + " is invalid, expected format_version, pipelines, environments, or common");
// }
// return partialConfig;
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String DEFAULT_FILE_PATTERN = "**/*.gocd.yaml,**/*.gocd.yml";
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String PLUGIN_SETTINGS_FILE_PATTERN = "file_pattern";
| import cd.go.plugin.config.yaml.transforms.RootTransform;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.thoughtworks.go.plugin.api.GoApplicationAccessor;
import com.thoughtworks.go.plugin.api.GoPlugin;
import com.thoughtworks.go.plugin.api.GoPluginIdentifier;
import com.thoughtworks.go.plugin.api.annotation.Extension;
import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException;
import com.thoughtworks.go.plugin.api.logging.Logger;
import com.thoughtworks.go.plugin.api.request.GoApiRequest;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
import com.thoughtworks.go.plugin.api.response.GoApiResponse;
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Supplier;
import static cd.go.plugin.config.yaml.PluginSettings.DEFAULT_FILE_PATTERN;
import static cd.go.plugin.config.yaml.PluginSettings.PLUGIN_SETTINGS_FILE_PATTERN;
import static com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.*;
import static java.lang.String.format; | */
private void ensureConfigured() {
if (null == settings) {
settings = fetchPluginSettings();
}
}
private GoPluginApiResponse handleParseContentRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
YamlConfigParser parser = new YamlConfigParser();
Map<String, String> contents = parsed.getParam("contents");
JsonConfigCollection result = new JsonConfigCollection();
contents.forEach((filename, content) -> {
parser.parseStream(result, new ByteArrayInputStream(content.getBytes()), filename);
});
result.updateTargetVersionFromFiles();
return success(gson.toJson(result.getJsonObject()));
});
}
private GoPluginApiResponse handlePipelineExportRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
Map<String, Object> pipeline = parsed.getParam("pipeline");
String name = (String) pipeline.get("name");
| // Path: src/main/java/cd/go/plugin/config/yaml/transforms/RootTransform.java
// public class RootTransform {
// private PipelineTransform pipelineTransform;
// private EnvironmentsTransform environmentsTransform;
//
// public RootTransform() {
// EnvironmentVariablesTransform environmentVarsTransform = new EnvironmentVariablesTransform();
// MaterialTransform material = new MaterialTransform();
// ParameterTransform parameterTransform = new ParameterTransform();
// JobTransform job = new JobTransform(environmentVarsTransform, new TaskTransform());
// StageTransform stage = new StageTransform(environmentVarsTransform, job);
// this.pipelineTransform = new PipelineTransform(material, stage, environmentVarsTransform, parameterTransform);
// this.environmentsTransform = new EnvironmentsTransform(environmentVarsTransform);
// }
//
// public RootTransform(PipelineTransform pipelineTransform, EnvironmentsTransform environmentsTransform) {
// this.pipelineTransform = pipelineTransform;
// this.environmentsTransform = environmentsTransform;
// }
//
// public String inverseTransformPipeline(Map<String, Object> pipeline) {
// Map<String, Object> result = new LinkedTreeMap<>();
// result.put("format_version", 10);
// result.put("pipelines", pipelineTransform.inverseTransform(pipeline));
// return YamlUtils.dump(result);
// }
//
// public JsonConfigCollection transform(Object rootObj, String location) {
// JsonConfigCollection partialConfig = new JsonConfigCollection();
// Map<String, Object> rootMap = (Map<String, Object>) rootObj;
// // must obtain format_version first
// int formatVersion = 1;
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("format_version".equalsIgnoreCase(pe.getKey())) {
// formatVersion = Integer.valueOf((String) pe.getValue());
// partialConfig.updateFormatVersionFound(formatVersion);
// }
// }
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("pipelines".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> pipelines = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> pipe : pipelines.entrySet()) {
// try {
// JsonElement jsonPipeline = pipelineTransform.transform(pipe, formatVersion);
// partialConfig.addPipeline(jsonPipeline, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse pipeline %s; %s", pipe.getKey(), ex.getMessage()), location));
// }
// }
// } else if ("environments".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> environments = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> env : environments.entrySet()) {
// try {
// JsonElement jsonEnvironment = environmentsTransform.transform(env);
// partialConfig.addEnvironment(jsonEnvironment, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse environment %s; %s", env.getKey(), ex.getMessage()), location));
// }
// }
// } else if (!"common".equalsIgnoreCase(pe.getKey()) && !"format_version".equalsIgnoreCase(pe.getKey()))
// throw new YamlConfigException(pe.getKey() + " is invalid, expected format_version, pipelines, environments, or common");
// }
// return partialConfig;
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String DEFAULT_FILE_PATTERN = "**/*.gocd.yaml,**/*.gocd.yml";
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String PLUGIN_SETTINGS_FILE_PATTERN = "file_pattern";
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigPlugin.java
import cd.go.plugin.config.yaml.transforms.RootTransform;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.thoughtworks.go.plugin.api.GoApplicationAccessor;
import com.thoughtworks.go.plugin.api.GoPlugin;
import com.thoughtworks.go.plugin.api.GoPluginIdentifier;
import com.thoughtworks.go.plugin.api.annotation.Extension;
import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException;
import com.thoughtworks.go.plugin.api.logging.Logger;
import com.thoughtworks.go.plugin.api.request.GoApiRequest;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
import com.thoughtworks.go.plugin.api.response.GoApiResponse;
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Supplier;
import static cd.go.plugin.config.yaml.PluginSettings.DEFAULT_FILE_PATTERN;
import static cd.go.plugin.config.yaml.PluginSettings.PLUGIN_SETTINGS_FILE_PATTERN;
import static com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.*;
import static java.lang.String.format;
*/
private void ensureConfigured() {
if (null == settings) {
settings = fetchPluginSettings();
}
}
private GoPluginApiResponse handleParseContentRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
YamlConfigParser parser = new YamlConfigParser();
Map<String, String> contents = parsed.getParam("contents");
JsonConfigCollection result = new JsonConfigCollection();
contents.forEach((filename, content) -> {
parser.parseStream(result, new ByteArrayInputStream(content.getBytes()), filename);
});
result.updateTargetVersionFromFiles();
return success(gson.toJson(result.getJsonObject()));
});
}
private GoPluginApiResponse handlePipelineExportRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
Map<String, Object> pipeline = parsed.getParam("pipeline");
String name = (String) pipeline.get("name");
| Map<String, String> responseMap = Collections.singletonMap("pipeline", new RootTransform().inverseTransformPipeline(pipeline)); |
tomzo/gocd-yaml-config-plugin | src/main/java/cd/go/plugin/config/yaml/YamlConfigPlugin.java | // Path: src/main/java/cd/go/plugin/config/yaml/transforms/RootTransform.java
// public class RootTransform {
// private PipelineTransform pipelineTransform;
// private EnvironmentsTransform environmentsTransform;
//
// public RootTransform() {
// EnvironmentVariablesTransform environmentVarsTransform = new EnvironmentVariablesTransform();
// MaterialTransform material = new MaterialTransform();
// ParameterTransform parameterTransform = new ParameterTransform();
// JobTransform job = new JobTransform(environmentVarsTransform, new TaskTransform());
// StageTransform stage = new StageTransform(environmentVarsTransform, job);
// this.pipelineTransform = new PipelineTransform(material, stage, environmentVarsTransform, parameterTransform);
// this.environmentsTransform = new EnvironmentsTransform(environmentVarsTransform);
// }
//
// public RootTransform(PipelineTransform pipelineTransform, EnvironmentsTransform environmentsTransform) {
// this.pipelineTransform = pipelineTransform;
// this.environmentsTransform = environmentsTransform;
// }
//
// public String inverseTransformPipeline(Map<String, Object> pipeline) {
// Map<String, Object> result = new LinkedTreeMap<>();
// result.put("format_version", 10);
// result.put("pipelines", pipelineTransform.inverseTransform(pipeline));
// return YamlUtils.dump(result);
// }
//
// public JsonConfigCollection transform(Object rootObj, String location) {
// JsonConfigCollection partialConfig = new JsonConfigCollection();
// Map<String, Object> rootMap = (Map<String, Object>) rootObj;
// // must obtain format_version first
// int formatVersion = 1;
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("format_version".equalsIgnoreCase(pe.getKey())) {
// formatVersion = Integer.valueOf((String) pe.getValue());
// partialConfig.updateFormatVersionFound(formatVersion);
// }
// }
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("pipelines".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> pipelines = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> pipe : pipelines.entrySet()) {
// try {
// JsonElement jsonPipeline = pipelineTransform.transform(pipe, formatVersion);
// partialConfig.addPipeline(jsonPipeline, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse pipeline %s; %s", pipe.getKey(), ex.getMessage()), location));
// }
// }
// } else if ("environments".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> environments = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> env : environments.entrySet()) {
// try {
// JsonElement jsonEnvironment = environmentsTransform.transform(env);
// partialConfig.addEnvironment(jsonEnvironment, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse environment %s; %s", env.getKey(), ex.getMessage()), location));
// }
// }
// } else if (!"common".equalsIgnoreCase(pe.getKey()) && !"format_version".equalsIgnoreCase(pe.getKey()))
// throw new YamlConfigException(pe.getKey() + " is invalid, expected format_version, pipelines, environments, or common");
// }
// return partialConfig;
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String DEFAULT_FILE_PATTERN = "**/*.gocd.yaml,**/*.gocd.yml";
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String PLUGIN_SETTINGS_FILE_PATTERN = "file_pattern";
| import cd.go.plugin.config.yaml.transforms.RootTransform;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.thoughtworks.go.plugin.api.GoApplicationAccessor;
import com.thoughtworks.go.plugin.api.GoPlugin;
import com.thoughtworks.go.plugin.api.GoPluginIdentifier;
import com.thoughtworks.go.plugin.api.annotation.Extension;
import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException;
import com.thoughtworks.go.plugin.api.logging.Logger;
import com.thoughtworks.go.plugin.api.request.GoApiRequest;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
import com.thoughtworks.go.plugin.api.response.GoApiResponse;
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Supplier;
import static cd.go.plugin.config.yaml.PluginSettings.DEFAULT_FILE_PATTERN;
import static cd.go.plugin.config.yaml.PluginSettings.PLUGIN_SETTINGS_FILE_PATTERN;
import static com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.*;
import static java.lang.String.format; | }
private GoPluginApiResponse handleParseDirectoryRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
File baseDir = new File(parsed.getStringParam("directory"));
String[] files = scanForConfigFiles(parsed, baseDir);
YamlConfigParser parser = new YamlConfigParser();
JsonConfigCollection config = parser.parseFiles(baseDir, files);
config.updateTargetVersionFromFiles();
return success(gson.toJson(config.getJsonObject()));
});
}
private GoPluginApiResponse handleGetConfigFiles(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
File baseDir = new File(parsed.getStringParam("directory"));
Map<String, String[]> result = new HashMap<>();
result.put("files", scanForConfigFiles(parsed, baseDir));
return success(gson.toJson(result));
});
}
private String[] scanForConfigFiles(ParsedRequest parsed, File baseDir) { | // Path: src/main/java/cd/go/plugin/config/yaml/transforms/RootTransform.java
// public class RootTransform {
// private PipelineTransform pipelineTransform;
// private EnvironmentsTransform environmentsTransform;
//
// public RootTransform() {
// EnvironmentVariablesTransform environmentVarsTransform = new EnvironmentVariablesTransform();
// MaterialTransform material = new MaterialTransform();
// ParameterTransform parameterTransform = new ParameterTransform();
// JobTransform job = new JobTransform(environmentVarsTransform, new TaskTransform());
// StageTransform stage = new StageTransform(environmentVarsTransform, job);
// this.pipelineTransform = new PipelineTransform(material, stage, environmentVarsTransform, parameterTransform);
// this.environmentsTransform = new EnvironmentsTransform(environmentVarsTransform);
// }
//
// public RootTransform(PipelineTransform pipelineTransform, EnvironmentsTransform environmentsTransform) {
// this.pipelineTransform = pipelineTransform;
// this.environmentsTransform = environmentsTransform;
// }
//
// public String inverseTransformPipeline(Map<String, Object> pipeline) {
// Map<String, Object> result = new LinkedTreeMap<>();
// result.put("format_version", 10);
// result.put("pipelines", pipelineTransform.inverseTransform(pipeline));
// return YamlUtils.dump(result);
// }
//
// public JsonConfigCollection transform(Object rootObj, String location) {
// JsonConfigCollection partialConfig = new JsonConfigCollection();
// Map<String, Object> rootMap = (Map<String, Object>) rootObj;
// // must obtain format_version first
// int formatVersion = 1;
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("format_version".equalsIgnoreCase(pe.getKey())) {
// formatVersion = Integer.valueOf((String) pe.getValue());
// partialConfig.updateFormatVersionFound(formatVersion);
// }
// }
// for (Map.Entry<String, Object> pe : rootMap.entrySet()) {
// if ("pipelines".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> pipelines = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> pipe : pipelines.entrySet()) {
// try {
// JsonElement jsonPipeline = pipelineTransform.transform(pipe, formatVersion);
// partialConfig.addPipeline(jsonPipeline, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse pipeline %s; %s", pipe.getKey(), ex.getMessage()), location));
// }
// }
// } else if ("environments".equalsIgnoreCase(pe.getKey())) {
// if (pe.getValue() == null)
// continue;
// Map<String, Object> environments = (Map<String, Object>) pe.getValue();
// for (Map.Entry<String, Object> env : environments.entrySet()) {
// try {
// JsonElement jsonEnvironment = environmentsTransform.transform(env);
// partialConfig.addEnvironment(jsonEnvironment, location);
// } catch (Exception ex) {
// partialConfig.addError(new PluginError(
// String.format("Failed to parse environment %s; %s", env.getKey(), ex.getMessage()), location));
// }
// }
// } else if (!"common".equalsIgnoreCase(pe.getKey()) && !"format_version".equalsIgnoreCase(pe.getKey()))
// throw new YamlConfigException(pe.getKey() + " is invalid, expected format_version, pipelines, environments, or common");
// }
// return partialConfig;
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String DEFAULT_FILE_PATTERN = "**/*.gocd.yaml,**/*.gocd.yml";
//
// Path: src/main/java/cd/go/plugin/config/yaml/PluginSettings.java
// static final String PLUGIN_SETTINGS_FILE_PATTERN = "file_pattern";
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigPlugin.java
import cd.go.plugin.config.yaml.transforms.RootTransform;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.thoughtworks.go.plugin.api.GoApplicationAccessor;
import com.thoughtworks.go.plugin.api.GoPlugin;
import com.thoughtworks.go.plugin.api.GoPluginIdentifier;
import com.thoughtworks.go.plugin.api.annotation.Extension;
import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException;
import com.thoughtworks.go.plugin.api.logging.Logger;
import com.thoughtworks.go.plugin.api.request.GoApiRequest;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
import com.thoughtworks.go.plugin.api.response.GoApiResponse;
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.Supplier;
import static cd.go.plugin.config.yaml.PluginSettings.DEFAULT_FILE_PATTERN;
import static cd.go.plugin.config.yaml.PluginSettings.PLUGIN_SETTINGS_FILE_PATTERN;
import static com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.*;
import static java.lang.String.format;
}
private GoPluginApiResponse handleParseDirectoryRequest(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
File baseDir = new File(parsed.getStringParam("directory"));
String[] files = scanForConfigFiles(parsed, baseDir);
YamlConfigParser parser = new YamlConfigParser();
JsonConfigCollection config = parser.parseFiles(baseDir, files);
config.updateTargetVersionFromFiles();
return success(gson.toJson(config.getJsonObject()));
});
}
private GoPluginApiResponse handleGetConfigFiles(GoPluginApiRequest request) {
return handlingErrors(() -> {
ParsedRequest parsed = ParsedRequest.parse(request);
File baseDir = new File(parsed.getStringParam("directory"));
Map<String, String[]> result = new HashMap<>();
result.put("files", scanForConfigFiles(parsed, baseDir));
return success(gson.toJson(result));
});
}
private String[] scanForConfigFiles(ParsedRequest parsed, File baseDir) { | String pattern = parsed.getConfigurationKey(PLUGIN_SETTINGS_FILE_PATTERN); |
tomzo/gocd-yaml-config-plugin | src/main/java/cd/go/plugin/config/yaml/cli/YamlPluginCli.java | // Path: src/main/java/cd/go/plugin/config/yaml/JsonConfigCollection.java
// public class JsonConfigCollection {
// private static final int DEFAULT_VERSION = 1;
// private final Gson gson;
//
// private Set<Integer> uniqueVersions = new HashSet<>();
// private JsonObject mainObject = new JsonObject();
// private JsonArray environments = new JsonArray();
// private JsonArray pipelines = new JsonArray();
// private JsonArray errors = new JsonArray();
//
// public JsonConfigCollection() {
// gson = new Gson();
//
// updateTargetVersionTo(DEFAULT_VERSION);
// mainObject.add("environments", environments);
// mainObject.add("pipelines", pipelines);
// mainObject.add("errors", errors);
// }
//
// protected JsonArray getEnvironments() {
// return environments;
// }
//
// public void addEnvironment(JsonElement environment, String location) {
// environments.add(environment);
// environment.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonObject getJsonObject() {
// return mainObject;
// }
//
// public void addPipeline(JsonElement pipeline, String location) {
// pipelines.add(pipeline);
// pipeline.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonArray getPipelines() {
// return pipelines;
// }
//
// public JsonArray getErrors() {
// return errors;
// }
//
// public void addError(String message, String location) {
// this.addError(new PluginError(message, location));
// }
//
// public void addError(PluginError error) {
// errors.add(gson.toJsonTree(error));
// }
//
// public void append(JsonConfigCollection other) {
// this.environments.addAll(other.environments);
// this.pipelines.addAll(other.pipelines);
// this.errors.addAll(other.errors);
// this.uniqueVersions.addAll(other.uniqueVersions);
// }
//
// public void updateFormatVersionFound(int version) {
// uniqueVersions.add(version);
// updateTargetVersionTo(version);
// }
//
// public void updateTargetVersionFromFiles() {
// if (uniqueVersions.size() > 1) {
// throw new RuntimeException("Versions across files are not unique. Found versions: " + uniqueVersions + ". There can only be one version across the whole repository.");
// }
// updateTargetVersionTo(uniqueVersions.iterator().hasNext() ? uniqueVersions.iterator().next() : DEFAULT_VERSION);
// }
//
// private void updateTargetVersionTo(int targetVersion) {
// mainObject.remove("target_version");
// mainObject.add("target_version", new JsonPrimitive(targetVersion));
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigParser.java
// public class YamlConfigParser {
// private RootTransform rootTransform;
//
// public YamlConfigParser() {
// this(new RootTransform());
// }
//
// public YamlConfigParser(RootTransform rootTransform) {
// this.rootTransform = rootTransform;
// }
//
// public JsonConfigCollection parseFiles(File baseDir, String[] files) {
// JsonConfigCollection collection = new JsonConfigCollection();
//
// for (String file : files) {
// try {
// parseStream(collection, new FileInputStream(new File(baseDir, file)), file);
// } catch (FileNotFoundException ex) {
// collection.addError("File matching GoCD YAML pattern disappeared", file);
// }
// }
//
// return collection;
// }
//
// public void parseStream(JsonConfigCollection result, InputStream input, String location) {
// try (InputStreamReader contentReader = new InputStreamReader(input)) {
// if (input.available() < 1) {
// result.addError("File is empty", location);
// return;
// }
//
// YamlConfig config = new YamlConfig();
// config.setAllowDuplicates(false);
// YamlReader reader = new YamlReader(contentReader, config);
// Object rootObject = reader.read();
// JsonConfigCollection filePart = rootTransform.transform(rootObject, location);
// result.append(filePart);
// } catch (YamlReader.YamlReaderException e) {
// result.addError(e.getMessage(), location);
// } catch (IOException e) {
// result.addError(e.getMessage() + " : " + e.getCause().getMessage() + " : ", location);
// }
// }
// }
| import cd.go.plugin.config.yaml.JsonConfigCollection;
import cd.go.plugin.config.yaml.YamlConfigParser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.google.gson.JsonObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.String.format; | package cd.go.plugin.config.yaml.cli;
public class YamlPluginCli {
public static void main(String[] args) {
RootCmd root = new RootCmd();
SyntaxCmd syntax = new SyntaxCmd();
JCommander cmd = JCommander.newBuilder().
programName("yaml-cli").
addObject(root).
addCommand("syntax", syntax).
build();
try {
cmd.parse(args);
if (root.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (syntax.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (null == syntax.file) {
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
} catch (ParameterException e) {
error(e.getMessage());
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
| // Path: src/main/java/cd/go/plugin/config/yaml/JsonConfigCollection.java
// public class JsonConfigCollection {
// private static final int DEFAULT_VERSION = 1;
// private final Gson gson;
//
// private Set<Integer> uniqueVersions = new HashSet<>();
// private JsonObject mainObject = new JsonObject();
// private JsonArray environments = new JsonArray();
// private JsonArray pipelines = new JsonArray();
// private JsonArray errors = new JsonArray();
//
// public JsonConfigCollection() {
// gson = new Gson();
//
// updateTargetVersionTo(DEFAULT_VERSION);
// mainObject.add("environments", environments);
// mainObject.add("pipelines", pipelines);
// mainObject.add("errors", errors);
// }
//
// protected JsonArray getEnvironments() {
// return environments;
// }
//
// public void addEnvironment(JsonElement environment, String location) {
// environments.add(environment);
// environment.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonObject getJsonObject() {
// return mainObject;
// }
//
// public void addPipeline(JsonElement pipeline, String location) {
// pipelines.add(pipeline);
// pipeline.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonArray getPipelines() {
// return pipelines;
// }
//
// public JsonArray getErrors() {
// return errors;
// }
//
// public void addError(String message, String location) {
// this.addError(new PluginError(message, location));
// }
//
// public void addError(PluginError error) {
// errors.add(gson.toJsonTree(error));
// }
//
// public void append(JsonConfigCollection other) {
// this.environments.addAll(other.environments);
// this.pipelines.addAll(other.pipelines);
// this.errors.addAll(other.errors);
// this.uniqueVersions.addAll(other.uniqueVersions);
// }
//
// public void updateFormatVersionFound(int version) {
// uniqueVersions.add(version);
// updateTargetVersionTo(version);
// }
//
// public void updateTargetVersionFromFiles() {
// if (uniqueVersions.size() > 1) {
// throw new RuntimeException("Versions across files are not unique. Found versions: " + uniqueVersions + ". There can only be one version across the whole repository.");
// }
// updateTargetVersionTo(uniqueVersions.iterator().hasNext() ? uniqueVersions.iterator().next() : DEFAULT_VERSION);
// }
//
// private void updateTargetVersionTo(int targetVersion) {
// mainObject.remove("target_version");
// mainObject.add("target_version", new JsonPrimitive(targetVersion));
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigParser.java
// public class YamlConfigParser {
// private RootTransform rootTransform;
//
// public YamlConfigParser() {
// this(new RootTransform());
// }
//
// public YamlConfigParser(RootTransform rootTransform) {
// this.rootTransform = rootTransform;
// }
//
// public JsonConfigCollection parseFiles(File baseDir, String[] files) {
// JsonConfigCollection collection = new JsonConfigCollection();
//
// for (String file : files) {
// try {
// parseStream(collection, new FileInputStream(new File(baseDir, file)), file);
// } catch (FileNotFoundException ex) {
// collection.addError("File matching GoCD YAML pattern disappeared", file);
// }
// }
//
// return collection;
// }
//
// public void parseStream(JsonConfigCollection result, InputStream input, String location) {
// try (InputStreamReader contentReader = new InputStreamReader(input)) {
// if (input.available() < 1) {
// result.addError("File is empty", location);
// return;
// }
//
// YamlConfig config = new YamlConfig();
// config.setAllowDuplicates(false);
// YamlReader reader = new YamlReader(contentReader, config);
// Object rootObject = reader.read();
// JsonConfigCollection filePart = rootTransform.transform(rootObject, location);
// result.append(filePart);
// } catch (YamlReader.YamlReaderException e) {
// result.addError(e.getMessage(), location);
// } catch (IOException e) {
// result.addError(e.getMessage() + " : " + e.getCause().getMessage() + " : ", location);
// }
// }
// }
// Path: src/main/java/cd/go/plugin/config/yaml/cli/YamlPluginCli.java
import cd.go.plugin.config.yaml.JsonConfigCollection;
import cd.go.plugin.config.yaml.YamlConfigParser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.google.gson.JsonObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.String.format;
package cd.go.plugin.config.yaml.cli;
public class YamlPluginCli {
public static void main(String[] args) {
RootCmd root = new RootCmd();
SyntaxCmd syntax = new SyntaxCmd();
JCommander cmd = JCommander.newBuilder().
programName("yaml-cli").
addObject(root).
addCommand("syntax", syntax).
build();
try {
cmd.parse(args);
if (root.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (syntax.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (null == syntax.file) {
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
} catch (ParameterException e) {
error(e.getMessage());
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
| YamlConfigParser parser = new YamlConfigParser(); |
tomzo/gocd-yaml-config-plugin | src/main/java/cd/go/plugin/config/yaml/cli/YamlPluginCli.java | // Path: src/main/java/cd/go/plugin/config/yaml/JsonConfigCollection.java
// public class JsonConfigCollection {
// private static final int DEFAULT_VERSION = 1;
// private final Gson gson;
//
// private Set<Integer> uniqueVersions = new HashSet<>();
// private JsonObject mainObject = new JsonObject();
// private JsonArray environments = new JsonArray();
// private JsonArray pipelines = new JsonArray();
// private JsonArray errors = new JsonArray();
//
// public JsonConfigCollection() {
// gson = new Gson();
//
// updateTargetVersionTo(DEFAULT_VERSION);
// mainObject.add("environments", environments);
// mainObject.add("pipelines", pipelines);
// mainObject.add("errors", errors);
// }
//
// protected JsonArray getEnvironments() {
// return environments;
// }
//
// public void addEnvironment(JsonElement environment, String location) {
// environments.add(environment);
// environment.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonObject getJsonObject() {
// return mainObject;
// }
//
// public void addPipeline(JsonElement pipeline, String location) {
// pipelines.add(pipeline);
// pipeline.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonArray getPipelines() {
// return pipelines;
// }
//
// public JsonArray getErrors() {
// return errors;
// }
//
// public void addError(String message, String location) {
// this.addError(new PluginError(message, location));
// }
//
// public void addError(PluginError error) {
// errors.add(gson.toJsonTree(error));
// }
//
// public void append(JsonConfigCollection other) {
// this.environments.addAll(other.environments);
// this.pipelines.addAll(other.pipelines);
// this.errors.addAll(other.errors);
// this.uniqueVersions.addAll(other.uniqueVersions);
// }
//
// public void updateFormatVersionFound(int version) {
// uniqueVersions.add(version);
// updateTargetVersionTo(version);
// }
//
// public void updateTargetVersionFromFiles() {
// if (uniqueVersions.size() > 1) {
// throw new RuntimeException("Versions across files are not unique. Found versions: " + uniqueVersions + ". There can only be one version across the whole repository.");
// }
// updateTargetVersionTo(uniqueVersions.iterator().hasNext() ? uniqueVersions.iterator().next() : DEFAULT_VERSION);
// }
//
// private void updateTargetVersionTo(int targetVersion) {
// mainObject.remove("target_version");
// mainObject.add("target_version", new JsonPrimitive(targetVersion));
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigParser.java
// public class YamlConfigParser {
// private RootTransform rootTransform;
//
// public YamlConfigParser() {
// this(new RootTransform());
// }
//
// public YamlConfigParser(RootTransform rootTransform) {
// this.rootTransform = rootTransform;
// }
//
// public JsonConfigCollection parseFiles(File baseDir, String[] files) {
// JsonConfigCollection collection = new JsonConfigCollection();
//
// for (String file : files) {
// try {
// parseStream(collection, new FileInputStream(new File(baseDir, file)), file);
// } catch (FileNotFoundException ex) {
// collection.addError("File matching GoCD YAML pattern disappeared", file);
// }
// }
//
// return collection;
// }
//
// public void parseStream(JsonConfigCollection result, InputStream input, String location) {
// try (InputStreamReader contentReader = new InputStreamReader(input)) {
// if (input.available() < 1) {
// result.addError("File is empty", location);
// return;
// }
//
// YamlConfig config = new YamlConfig();
// config.setAllowDuplicates(false);
// YamlReader reader = new YamlReader(contentReader, config);
// Object rootObject = reader.read();
// JsonConfigCollection filePart = rootTransform.transform(rootObject, location);
// result.append(filePart);
// } catch (YamlReader.YamlReaderException e) {
// result.addError(e.getMessage(), location);
// } catch (IOException e) {
// result.addError(e.getMessage() + " : " + e.getCause().getMessage() + " : ", location);
// }
// }
// }
| import cd.go.plugin.config.yaml.JsonConfigCollection;
import cd.go.plugin.config.yaml.YamlConfigParser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.google.gson.JsonObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.String.format; | package cd.go.plugin.config.yaml.cli;
public class YamlPluginCli {
public static void main(String[] args) {
RootCmd root = new RootCmd();
SyntaxCmd syntax = new SyntaxCmd();
JCommander cmd = JCommander.newBuilder().
programName("yaml-cli").
addObject(root).
addCommand("syntax", syntax).
build();
try {
cmd.parse(args);
if (root.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (syntax.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (null == syntax.file) {
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
} catch (ParameterException e) {
error(e.getMessage());
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
YamlConfigParser parser = new YamlConfigParser(); | // Path: src/main/java/cd/go/plugin/config/yaml/JsonConfigCollection.java
// public class JsonConfigCollection {
// private static final int DEFAULT_VERSION = 1;
// private final Gson gson;
//
// private Set<Integer> uniqueVersions = new HashSet<>();
// private JsonObject mainObject = new JsonObject();
// private JsonArray environments = new JsonArray();
// private JsonArray pipelines = new JsonArray();
// private JsonArray errors = new JsonArray();
//
// public JsonConfigCollection() {
// gson = new Gson();
//
// updateTargetVersionTo(DEFAULT_VERSION);
// mainObject.add("environments", environments);
// mainObject.add("pipelines", pipelines);
// mainObject.add("errors", errors);
// }
//
// protected JsonArray getEnvironments() {
// return environments;
// }
//
// public void addEnvironment(JsonElement environment, String location) {
// environments.add(environment);
// environment.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonObject getJsonObject() {
// return mainObject;
// }
//
// public void addPipeline(JsonElement pipeline, String location) {
// pipelines.add(pipeline);
// pipeline.getAsJsonObject().add("location", new JsonPrimitive(location));
// }
//
// public JsonArray getPipelines() {
// return pipelines;
// }
//
// public JsonArray getErrors() {
// return errors;
// }
//
// public void addError(String message, String location) {
// this.addError(new PluginError(message, location));
// }
//
// public void addError(PluginError error) {
// errors.add(gson.toJsonTree(error));
// }
//
// public void append(JsonConfigCollection other) {
// this.environments.addAll(other.environments);
// this.pipelines.addAll(other.pipelines);
// this.errors.addAll(other.errors);
// this.uniqueVersions.addAll(other.uniqueVersions);
// }
//
// public void updateFormatVersionFound(int version) {
// uniqueVersions.add(version);
// updateTargetVersionTo(version);
// }
//
// public void updateTargetVersionFromFiles() {
// if (uniqueVersions.size() > 1) {
// throw new RuntimeException("Versions across files are not unique. Found versions: " + uniqueVersions + ". There can only be one version across the whole repository.");
// }
// updateTargetVersionTo(uniqueVersions.iterator().hasNext() ? uniqueVersions.iterator().next() : DEFAULT_VERSION);
// }
//
// private void updateTargetVersionTo(int targetVersion) {
// mainObject.remove("target_version");
// mainObject.add("target_version", new JsonPrimitive(targetVersion));
// }
// }
//
// Path: src/main/java/cd/go/plugin/config/yaml/YamlConfigParser.java
// public class YamlConfigParser {
// private RootTransform rootTransform;
//
// public YamlConfigParser() {
// this(new RootTransform());
// }
//
// public YamlConfigParser(RootTransform rootTransform) {
// this.rootTransform = rootTransform;
// }
//
// public JsonConfigCollection parseFiles(File baseDir, String[] files) {
// JsonConfigCollection collection = new JsonConfigCollection();
//
// for (String file : files) {
// try {
// parseStream(collection, new FileInputStream(new File(baseDir, file)), file);
// } catch (FileNotFoundException ex) {
// collection.addError("File matching GoCD YAML pattern disappeared", file);
// }
// }
//
// return collection;
// }
//
// public void parseStream(JsonConfigCollection result, InputStream input, String location) {
// try (InputStreamReader contentReader = new InputStreamReader(input)) {
// if (input.available() < 1) {
// result.addError("File is empty", location);
// return;
// }
//
// YamlConfig config = new YamlConfig();
// config.setAllowDuplicates(false);
// YamlReader reader = new YamlReader(contentReader, config);
// Object rootObject = reader.read();
// JsonConfigCollection filePart = rootTransform.transform(rootObject, location);
// result.append(filePart);
// } catch (YamlReader.YamlReaderException e) {
// result.addError(e.getMessage(), location);
// } catch (IOException e) {
// result.addError(e.getMessage() + " : " + e.getCause().getMessage() + " : ", location);
// }
// }
// }
// Path: src/main/java/cd/go/plugin/config/yaml/cli/YamlPluginCli.java
import cd.go.plugin.config.yaml.JsonConfigCollection;
import cd.go.plugin.config.yaml.YamlConfigParser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.google.gson.JsonObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.String.format;
package cd.go.plugin.config.yaml.cli;
public class YamlPluginCli {
public static void main(String[] args) {
RootCmd root = new RootCmd();
SyntaxCmd syntax = new SyntaxCmd();
JCommander cmd = JCommander.newBuilder().
programName("yaml-cli").
addObject(root).
addCommand("syntax", syntax).
build();
try {
cmd.parse(args);
if (root.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (syntax.help) {
printUsageAndExit(0, cmd, cmd.getParsedCommand());
}
if (null == syntax.file) {
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
} catch (ParameterException e) {
error(e.getMessage());
printUsageAndExit(1, cmd, cmd.getParsedCommand());
}
YamlConfigParser parser = new YamlConfigParser(); | JsonConfigCollection collection = new JsonConfigCollection(); |
ghabigant/task_easy | src/cn/cetelem/des/thread/listener/impl/DesListenerImpl.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/thread/listener/DesListener.java
// public interface DesListener {
// public boolean push(String appId, String ip);
// public void pop(String appId);
// public String getIp(String appId);
// public Map<String,RequestConf> getAll();
//
// }
| import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.xml.ws.WebServiceContext;
import org.springframework.stereotype.Repository;
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.thread.listener.DesListener; | /**
*
*/
package cn.cetelem.des.thread.listener.impl;
/**
* @author flaki
* @date 2016年6月12日
* @type DesListener
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
public class DesListenerImpl implements DesListener {
private static long OUT_TIME = 30000;
private static long CLEAN_TIME = 60000;
private volatile int i = 0; | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/thread/listener/DesListener.java
// public interface DesListener {
// public boolean push(String appId, String ip);
// public void pop(String appId);
// public String getIp(String appId);
// public Map<String,RequestConf> getAll();
//
// }
// Path: src/cn/cetelem/des/thread/listener/impl/DesListenerImpl.java
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.xml.ws.WebServiceContext;
import org.springframework.stereotype.Repository;
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.thread.listener.DesListener;
/**
*
*/
package cn.cetelem.des.thread.listener.impl;
/**
* @author flaki
* @date 2016年6月12日
* @type DesListener
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
public class DesListenerImpl implements DesListener {
private static long OUT_TIME = 30000;
private static long CLEAN_TIME = 60000;
private volatile int i = 0; | private TaskLogger logger = TaskLogger.getLogger(DesListenerImpl.class); |
ghabigant/task_easy | src/cn/cetelem/des/thread/NodesThreadLocal.java | // Path: src/cn/cetelem/des/object_support/task/factory/impl/TaskHoldManager.java
// @Repository
// public class TaskHoldManager {
// @Resource
// private TaskResolver taskResolver;
//
// public static Map<String, BaseNode> TASKS;
// public static Object lock = new Object();
// private Logger log = Logger.getLogger(TaskHoldManager.class);
// /**
// * 会在服务器启动时调用
// */
// @PostConstruct
// public void init(){
// if (TASKS == null) {
// synchronized (lock) {
// if(TASKS == null) {
// try {
// TASKS = taskResolver.getNodes();
// } catch (Exception e) {
// log.info("tasks init failed, please check the xml of task");
// e.printStackTrace();
// }
// log.info(TASKS.size()+" nodes have inited!");
//
// }
// }
// }
// }
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
| import cn.cetelem.des.object_support.task.factory.impl.TaskHoldManager;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import java.util.Map;
import org.springframework.stereotype.Repository; | /**
*
*/
package cn.cetelem.des.thread;
/**
* @author flaki
* @date 2016年6月2日
* @type 节点ThreadLocal
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
public class NodesThreadLocal extends ThreadLocal<Map<String, BaseNode>> {
/*
* @see java.lang.ThreadLocal#initialValue()
*/
@Override
protected Map<String, BaseNode> initialValue() { | // Path: src/cn/cetelem/des/object_support/task/factory/impl/TaskHoldManager.java
// @Repository
// public class TaskHoldManager {
// @Resource
// private TaskResolver taskResolver;
//
// public static Map<String, BaseNode> TASKS;
// public static Object lock = new Object();
// private Logger log = Logger.getLogger(TaskHoldManager.class);
// /**
// * 会在服务器启动时调用
// */
// @PostConstruct
// public void init(){
// if (TASKS == null) {
// synchronized (lock) {
// if(TASKS == null) {
// try {
// TASKS = taskResolver.getNodes();
// } catch (Exception e) {
// log.info("tasks init failed, please check the xml of task");
// e.printStackTrace();
// }
// log.info(TASKS.size()+" nodes have inited!");
//
// }
// }
// }
// }
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
// Path: src/cn/cetelem/des/thread/NodesThreadLocal.java
import cn.cetelem.des.object_support.task.factory.impl.TaskHoldManager;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import java.util.Map;
import org.springframework.stereotype.Repository;
/**
*
*/
package cn.cetelem.des.thread;
/**
* @author flaki
* @date 2016年6月2日
* @type 节点ThreadLocal
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
public class NodesThreadLocal extends ThreadLocal<Map<String, BaseNode>> {
/*
* @see java.lang.ThreadLocal#initialValue()
*/
@Override
protected Map<String, BaseNode> initialValue() { | return TaskHoldManager.TASKS; |
ghabigant/task_easy | src/cn/cetelem/des/thread/listener/DesListener.java | // Path: src/cn/cetelem/des/thread/listener/impl/DesListenerImpl.java
// public static class RequestConf {
// private Long intime;
// private String ip;
//
// public Long getIntime() {
// return intime;
// }
//
// public void setIntime(Long intime) {
// this.intime = intime;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// @Override
// public String toString() {
// return "RequestConf [intime=" + intime + ", ip=" + ip + "]";
// }
//
// public RequestConf(Long intime, String ip) {
// super();
// this.intime = intime;
// this.ip = ip;
// }
//
// public RequestConf() {
// super();
// }
//
// }
| import java.util.Map;
import cn.cetelem.des.thread.listener.impl.DesListenerImpl.RequestConf; | /**
*
*/
package cn.cetelem.des.thread.listener;
/**
* @author flaki
* @date 2016年6月12日
* @type TODO
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public interface DesListener {
public boolean push(String appId, String ip);
public void pop(String appId);
public String getIp(String appId); | // Path: src/cn/cetelem/des/thread/listener/impl/DesListenerImpl.java
// public static class RequestConf {
// private Long intime;
// private String ip;
//
// public Long getIntime() {
// return intime;
// }
//
// public void setIntime(Long intime) {
// this.intime = intime;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// @Override
// public String toString() {
// return "RequestConf [intime=" + intime + ", ip=" + ip + "]";
// }
//
// public RequestConf(Long intime, String ip) {
// super();
// this.intime = intime;
// this.ip = ip;
// }
//
// public RequestConf() {
// super();
// }
//
// }
// Path: src/cn/cetelem/des/thread/listener/DesListener.java
import java.util.Map;
import cn.cetelem.des.thread.listener.impl.DesListenerImpl.RequestConf;
/**
*
*/
package cn.cetelem.des.thread.listener;
/**
* @author flaki
* @date 2016年6月12日
* @type TODO
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public interface DesListener {
public boolean push(String appId, String ip);
public void pop(String appId);
public String getIp(String appId); | public Map<String,RequestConf> getAll(); |
ghabigant/task_easy | src/test/cn/test/task/End.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type End
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Multiton | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/test/cn/test/task/End.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type End
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Multiton | public class End implements TaskBean { |
ghabigant/task_easy | src/test/cn/test/task/End.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type End
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Multiton
public class End implements TaskBean { | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/test/cn/test/task/End.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type End
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Multiton
public class End implements TaskBean { | private TaskLogger logger = TaskLogger.getLogger(End.class); |
ghabigant/task_easy | src/cn/cetelem/des/utils/Group.java | // Path: src/cn/cetelem/des/work_support/worker/annotation/EfficientLogWorkerGroup4Annotation.java
// public class EfficientLogWorkerGroup4Annotation extends EfficientWorkerGroup4Annotation {
// protected TaskLogger logger = TaskLogger.getLogger(this.getClass());
// protected String beforeTip;
// protected String afterTip;
//
// @Override
// public Object invoke(Object context) throws Exception {
// if (beforeTip != null) {
// logger.info(beforeTip);
// }
// run(context);
// if (afterTip != null) {
// logger.info(afterTip);
// }
// return this.context;
//
// }
//
// /**
// * @return the beforeTip
// */
// public String getBeforeTip() {
// return beforeTip;
// }
//
// /**
// * @param beforeTip the beforeTip to set
// */
// public void setBeforeTip(String beforeTip) {
// this.beforeTip = beforeTip;
// }
//
// /**
// * @return the afterTip
// */
// public String getAfterTip() {
// return afterTip;
// }
//
// /**
// * @param afterTip the afterTip to set
// */
// public void setAfterTip(String afterTip) {
// this.afterTip = afterTip;
// }
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cn.cetelem.des.work_support.worker.annotation.EfficientLogWorkerGroup4Annotation; | /**
*
*/
package cn.cetelem.des.utils;
/**
* @author flaki
* @date 2016年7月7日
* @type TODO
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Task
public @interface Group {
String value() default ""; | // Path: src/cn/cetelem/des/work_support/worker/annotation/EfficientLogWorkerGroup4Annotation.java
// public class EfficientLogWorkerGroup4Annotation extends EfficientWorkerGroup4Annotation {
// protected TaskLogger logger = TaskLogger.getLogger(this.getClass());
// protected String beforeTip;
// protected String afterTip;
//
// @Override
// public Object invoke(Object context) throws Exception {
// if (beforeTip != null) {
// logger.info(beforeTip);
// }
// run(context);
// if (afterTip != null) {
// logger.info(afterTip);
// }
// return this.context;
//
// }
//
// /**
// * @return the beforeTip
// */
// public String getBeforeTip() {
// return beforeTip;
// }
//
// /**
// * @param beforeTip the beforeTip to set
// */
// public void setBeforeTip(String beforeTip) {
// this.beforeTip = beforeTip;
// }
//
// /**
// * @return the afterTip
// */
// public String getAfterTip() {
// return afterTip;
// }
//
// /**
// * @param afterTip the afterTip to set
// */
// public void setAfterTip(String afterTip) {
// this.afterTip = afterTip;
// }
//
// }
// Path: src/cn/cetelem/des/utils/Group.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cn.cetelem.des.work_support.worker.annotation.EfficientLogWorkerGroup4Annotation;
/**
*
*/
package cn.cetelem.des.utils;
/**
* @author flaki
* @date 2016年7月7日
* @type TODO
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Task
public @interface Group {
String value() default ""; | Class<?> type() default EfficientLogWorkerGroup4Annotation.class; |
ghabigant/task_easy | demo/src/cn/test/task/End.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
@Task
@Multiton | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: demo/src/cn/test/task/End.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
@Task
@Multiton | public class End implements TaskBean { |
ghabigant/task_easy | demo/src/cn/test/task/End.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
@Task
@Multiton
public class End implements TaskBean { | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: demo/src/cn/test/task/End.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Multiton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
@Task
@Multiton
public class End implements TaskBean { | private TaskLogger logger = TaskLogger.getLogger(End.class); |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/factory/impl/TaskRunManager.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.taskBean.TaskBean; | package cn.cetelem.des.object_support.task.factory.impl;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务执行器
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Service
public class TaskRunManager {
/**
* 如果method有有效值则调用显示方法
* 否则调用默认方法(必要时须强转类型)
* @throws Exception
*
*/ | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/cn/cetelem/des/object_support/task/factory/impl/TaskRunManager.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.taskBean.TaskBean;
package cn.cetelem.des.object_support.task.factory.impl;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务执行器
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Service
public class TaskRunManager {
/**
* 如果method有有效值则调用显示方法
* 否则调用默认方法(必要时须强转类型)
* @throws Exception
*
*/ | public Object push(BaseNode baseNode, Object context, TaskBean taskBean) throws Exception { |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/factory/impl/TaskRunManager.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.taskBean.TaskBean; | package cn.cetelem.des.object_support.task.factory.impl;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务执行器
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Service
public class TaskRunManager {
/**
* 如果method有有效值则调用显示方法
* 否则调用默认方法(必要时须强转类型)
* @throws Exception
*
*/ | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/cn/cetelem/des/object_support/task/factory/impl/TaskRunManager.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.taskBean.TaskBean;
package cn.cetelem.des.object_support.task.factory.impl;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务执行器
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Service
public class TaskRunManager {
/**
* 如果method有有效值则调用显示方法
* 否则调用默认方法(必要时须强转类型)
* @throws Exception
*
*/ | public Object push(BaseNode baseNode, Object context, TaskBean taskBean) throws Exception { |
ghabigant/task_easy | src/cn/cetelem/des/interceptor/CheckerInterceptor.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
| import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Repository;
import cn.cetelem.des.object_support.task.pojo.BaseNode; | package cn.cetelem.des.interceptor;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务处理AOP 用于记录任务指向
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
@Aspect
public class CheckerInterceptor {
private TaskLogger logger = TaskLogger.getLogger(NodeInterceptor.class);
@Pointcut("execution(* cn.cetelem.des.expression.TaskChecker.check(..))")
private void anyMethod(){}
@Around("anyMethod()")
public String around(ProceedingJoinPoint pjp) throws Throwable{ | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
// Path: src/cn/cetelem/des/interceptor/CheckerInterceptor.java
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Repository;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
package cn.cetelem.des.interceptor;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 任务处理AOP 用于记录任务指向
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Repository
@Aspect
public class CheckerInterceptor {
private TaskLogger logger = TaskLogger.getLogger(NodeInterceptor.class);
@Pointcut("execution(* cn.cetelem.des.expression.TaskChecker.check(..))")
private void anyMethod(){}
@Around("anyMethod()")
public String around(ProceedingJoinPoint pjp) throws Throwable{ | String gotoBean = ((BaseNode)pjp.getArgs()[0]).getGotoBean(); |
ghabigant/task_easy | src/test/cn/test/task/Start.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type start节点
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Singleton | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/test/cn/test/task/Start.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type start节点
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Singleton | public class Start implements TaskBean { |
ghabigant/task_easy | src/test/cn/test/task/Start.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type start节点
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Singleton
public class Start implements TaskBean { | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/test/cn/test/task/Start.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
/**
*
* @author flaki
* @date 2016年7月8日
* @type start节点
* @version 1.0
* @email wysznb@hotmail.com
*
*/
@Task
@Singleton
public class Start implements TaskBean { | private TaskLogger logger = TaskLogger.getLogger(Start.class); |
ghabigant/task_easy | src/cn/cetelem/des/expression/sign/list/Signs.java | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
| import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point; | package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS; | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
// Path: src/cn/cetelem/des/expression/sign/list/Signs.java
import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point;
package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS; | private static Map<String,Sign> datas ; |
ghabigant/task_easy | src/cn/cetelem/des/expression/sign/list/Signs.java | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
| import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point; | package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>(); | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
// Path: src/cn/cetelem/des/expression/sign/list/Signs.java
import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point;
package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>(); | for(Sign sign:Bound.values()){ |
ghabigant/task_easy | src/cn/cetelem/des/expression/sign/list/Signs.java | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
| import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point; | package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>();
for(Sign sign:Bound.values()){
datas.put(sign.getFormat(), sign);
} | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
// Path: src/cn/cetelem/des/expression/sign/list/Signs.java
import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point;
package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>();
for(Sign sign:Bound.values()){
datas.put(sign.getFormat(), sign);
} | for(Sign sign:Judge.values()){ |
ghabigant/task_easy | src/cn/cetelem/des/expression/sign/list/Signs.java | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
| import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point; | package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>();
for(Sign sign:Bound.values()){
datas.put(sign.getFormat(), sign);
}
for(Sign sign:Judge.values()){
datas.put(sign.getFormat(), sign);
} | // Path: src/cn/cetelem/des/expression/sign/Sign.java
// public interface Sign {
// public Long getSignId();
// public String getName();
// public String getFormat();
// public String getKey();
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Bound.java
// public enum Bound implements Sign {
// F_BRACE(11L,"前大括号","{","边界"),
// L_BRACE(12L,"后大括号","}","边界"),
// F_PAR(13L,"前小括号","(","边界"),
// L_PAR(14L,"后小括号",")","边界"),
// Blank(15L,"空格"," ","边界");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Bound(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Judge.java
// public enum Judge implements Sign {
// OR(0L,"或","or","或运算"),
// AND(1L,"与","and","与运算"),
// NOT(2L,"非","not","非运算"),
// IF(3L,"如果","if","判断先行词"),
// ELSE(4L,"就","else","判断其他条件"),
// ELSE_IF(5L,"就","else if","判断其他条件"),
// GT(6L,"大于","gt","判断其他条件"),
// LT(7L,"小于","lt","判断其他条件"),
// EQ(8L,"等于","eq","判断其他条件"),
// GTAE(9L,"大于","gtae","判断其他条件"),
// LTAE(10L,"小于","ltae","判断其他条件");
//
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Judge(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/expression/sign/impl/Point.java
// public enum Point implements Sign {
// GOTO(16L,"跳转","goto","跳转"),
// NEXT(17L,"下一步","next","跳转");
// private final Long signId;
// private final String name;
// private final String format;
// private final String key;
// private Point(Long signId, String name, String format, String key) {
// this.signId = signId;
// this.name = name;
// this.format = format;
// this.key = key;
// }
// public Long getSignId() {
// return signId;
// }
// public String getName() {
// return name;
// }
// public String getFormat() {
// return format;
// }
// public String getKey() {
// return key;
// }
//
//
//
//
//
//
//
//
// }
// Path: src/cn/cetelem/des/expression/sign/list/Signs.java
import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.expression.sign.Sign;
import cn.cetelem.des.expression.sign.impl.Bound;
import cn.cetelem.des.expression.sign.impl.Judge;
import cn.cetelem.des.expression.sign.impl.Point;
package cn.cetelem.des.expression.sign.list;
/**
*
* @author flaki
* @date 2016年6月1日
* @type 标记库
* @version 1.0
* @email wysznb@hotmail.com
*
*/
public enum Signs {
SIGNS;
private static Map<String,Sign> datas ;
static{
init();
}
private Signs(){}
private static void init() {
datas = new HashMap<String, Sign>();
for(Sign sign:Bound.values()){
datas.put(sign.getFormat(), sign);
}
for(Sign sign:Judge.values()){
datas.put(sign.getFormat(), sign);
} | for(Sign sign:Point.values()){ |
ghabigant/task_easy | demo/src/cn/test/task/Start.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
@Task
@Singleton | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: demo/src/cn/test/task/Start.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
@Task
@Singleton | public class Start implements TaskBean { |
ghabigant/task_easy | demo/src/cn/test/task/Start.java | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task; | package cn.test.task;
@Task
@Singleton
public class Start implements TaskBean { | // Path: src/cn/cetelem/des/interceptor/TaskLogger.java
// public class TaskLogger {
// Logger logger ;
//
// private TaskLogger(Logger logger){
// this.logger = logger;
// }
//
// public void info(Object message) {
// logger.info(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void warn(Object message) {
// logger.warn(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void debug(Object message) {
// logger.debug(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName());
// }
//
// public void error(Object message,Throwable t) {
// logger.error(Thread.currentThread().getName()+"||##"+message+" ######## "+logger.getName(),t);
// }
//
// public static TaskLogger getLogger(Class<?> clazz){
// return new TaskLogger(Logger.getLogger(clazz));
//
// }
//
//
// }
//
// Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: demo/src/cn/test/task/Start.java
import cn.cetelem.des.interceptor.TaskLogger;
import cn.cetelem.des.taskBean.TaskBean;
import cn.cetelem.des.utils.Singleton;
import cn.cetelem.des.utils.Task;
package cn.test.task;
@Task
@Singleton
public class Start implements TaskBean { | private TaskLogger logger = TaskLogger.getLogger(Start.class); |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar; |
/**
* taskContext.xml配置文件读取地址
*/
private String url;
/**
* 表达式引擎类
*/
private String engine;
private boolean blockWhenExhausted ;
private int maxIdlePerKey ;
private long timeBetweenEvictionRunsMillis ;
private boolean testWhileIdle ;
private int numTestsPerEvictionRun ;
private int maxTotal ;
private int maxTotalPerKey ;
private long maxWaitMillis ;
private int minIdlePerKey ;
private boolean testOnBorrow ;
private boolean testOnCreate ;
private boolean testOnReturn ;
private long minEvictableIdleTimeMillis ;
private boolean lifo ;
private boolean fairness ;
private String evictionPolicyClassName ;
private long softMinEvictableIdleTimeMillis;
public static final String DEFAULT_ENGINE = "cn.cetelem.des.expression.engine.impl.JsEngine";
public static final String DEFAULT_URL = "classpath:cn/cetelem/des/config/taskContext.xml";
| // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
// Path: src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar;
/**
* taskContext.xml配置文件读取地址
*/
private String url;
/**
* 表达式引擎类
*/
private String engine;
private boolean blockWhenExhausted ;
private int maxIdlePerKey ;
private long timeBetweenEvictionRunsMillis ;
private boolean testWhileIdle ;
private int numTestsPerEvictionRun ;
private int maxTotal ;
private int maxTotalPerKey ;
private long maxWaitMillis ;
private int minIdlePerKey ;
private boolean testOnBorrow ;
private boolean testOnCreate ;
private boolean testOnReturn ;
private long minEvictableIdleTimeMillis ;
private boolean lifo ;
private boolean fairness ;
private String evictionPolicyClassName ;
private long softMinEvictableIdleTimeMillis;
public static final String DEFAULT_ENGINE = "cn.cetelem.des.expression.engine.impl.JsEngine";
public static final String DEFAULT_URL = "classpath:cn/cetelem/des/config/taskContext.xml";
| public Map<String, BaseNode> getNodes() throws DocumentException, |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar; | private boolean testOnBorrow ;
private boolean testOnCreate ;
private boolean testOnReturn ;
private long minEvictableIdleTimeMillis ;
private boolean lifo ;
private boolean fairness ;
private String evictionPolicyClassName ;
private long softMinEvictableIdleTimeMillis;
public static final String DEFAULT_ENGINE = "cn.cetelem.des.expression.engine.impl.JsEngine";
public static final String DEFAULT_URL = "classpath:cn/cetelem/des/config/taskContext.xml";
public Map<String, BaseNode> getNodes() throws DocumentException,
SAXException {
Document document;
if (StringUtils.isEmpty(url)) {
document = TaskXMLUtil.getXMLDoc(DEFAULT_URL);
} else {
document = TaskXMLUtil.getXMLDoc(url);
}
Element rootE = TaskXMLUtil.getRoot(document);
Map<String, Element> nodeElements = TaskXMLUtil
.getAttElementList(rootE);
Map<String, BaseNode> nodes = new ConcurrentHashMap<String, BaseNode>();
String defaultInType = rootE.attributeValue("defaultInType");
String defaultOutType = rootE.attributeValue("defaultOutType");
for (String nodeName : nodeElements.keySet()) {
Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) { | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
// Path: src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar;
private boolean testOnBorrow ;
private boolean testOnCreate ;
private boolean testOnReturn ;
private long minEvictableIdleTimeMillis ;
private boolean lifo ;
private boolean fairness ;
private String evictionPolicyClassName ;
private long softMinEvictableIdleTimeMillis;
public static final String DEFAULT_ENGINE = "cn.cetelem.des.expression.engine.impl.JsEngine";
public static final String DEFAULT_URL = "classpath:cn/cetelem/des/config/taskContext.xml";
public Map<String, BaseNode> getNodes() throws DocumentException,
SAXException {
Document document;
if (StringUtils.isEmpty(url)) {
document = TaskXMLUtil.getXMLDoc(DEFAULT_URL);
} else {
document = TaskXMLUtil.getXMLDoc(url);
}
Element rootE = TaskXMLUtil.getRoot(document);
Map<String, Element> nodeElements = TaskXMLUtil
.getAttElementList(rootE);
Map<String, BaseNode> nodes = new ConcurrentHashMap<String, BaseNode>();
String defaultInType = rootE.attributeValue("defaultInType");
String defaultOutType = rootE.attributeValue("defaultOutType");
for (String nodeName : nodeElements.keySet()) {
Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) { | node = new StartNode(); |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar; | document = TaskXMLUtil.getXMLDoc(DEFAULT_URL);
} else {
document = TaskXMLUtil.getXMLDoc(url);
}
Element rootE = TaskXMLUtil.getRoot(document);
Map<String, Element> nodeElements = TaskXMLUtil
.getAttElementList(rootE);
Map<String, BaseNode> nodes = new ConcurrentHashMap<String, BaseNode>();
String defaultInType = rootE.attributeValue("defaultInType");
String defaultOutType = rootE.attributeValue("defaultOutType");
for (String nodeName : nodeElements.keySet()) {
Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) {
node = new StartNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
String[] gotos = ele.attributeValue("goto").split("-");
node.setGotoBean(gotos[0]);
if (gotos.length == 2) {
node.setGotoMethod(gotos[1]);
}
} else if ("end".equals(nodeName)) { | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
// Path: src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar;
document = TaskXMLUtil.getXMLDoc(DEFAULT_URL);
} else {
document = TaskXMLUtil.getXMLDoc(url);
}
Element rootE = TaskXMLUtil.getRoot(document);
Map<String, Element> nodeElements = TaskXMLUtil
.getAttElementList(rootE);
Map<String, BaseNode> nodes = new ConcurrentHashMap<String, BaseNode>();
String defaultInType = rootE.attributeValue("defaultInType");
String defaultOutType = rootE.attributeValue("defaultOutType");
for (String nodeName : nodeElements.keySet()) {
Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) {
node = new StartNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
String[] gotos = ele.attributeValue("goto").split("-");
node.setGotoBean(gotos[0]);
if (gotos.length == 2) {
node.setGotoMethod(gotos[1]);
}
} else if ("end".equals(nodeName)) { | node = new EndNode(); |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar; | Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) {
node = new StartNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
String[] gotos = ele.attributeValue("goto").split("-");
node.setGotoBean(gotos[0]);
if (gotos.length == 2) {
node.setGotoMethod(gotos[1]);
}
} else if ("end".equals(nodeName)) {
node = new EndNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
} else { | // Path: src/cn/cetelem/des/object_support/task/pojo/BaseNode.java
// public class BaseNode {
// protected String name;
// private String expression;
// private String inType;
// private String outType;
// private String gotoBean;
// private String gotoMethod;
// private String method;
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getExpression() {
// return expression;
// }
// public void setExpression(String expression) {
// this.expression = expression;
// }
// public String getGotoBean() {
// return gotoBean;
// }
// public void setGotoBean(String gotoBean) {
// this.gotoBean = gotoBean;
// }
// public String getGotoMethod() {
// return gotoMethod;
// }
// public void setGotoMethod(String gotoMethod) {
// this.gotoMethod = gotoMethod;
// }
// public String getInType() {
// return inType;
// }
// public void setInType(String inType) {
// this.inType = inType;
// }
// public String getOutType() {
// return outType;
// }
// public void setOutType(String outType) {
// this.outType = outType;
// }
// public String getMethod() {
// return method;
// }
// public void setMethod(String method) {
// this.method = method;
// }
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/EndNode.java
// public class EndNode extends BaseNode {
// private String name = "end";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/StartNode.java
// public class StartNode extends BaseNode {
// private String name = "start";
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
//
// }
//
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskChar.java
// public class TaskChar extends BaseNode {
//
// }
// Path: src/cn/cetelem/des/object_support/task/resolver/TaskResolver.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.xml.sax.SAXException;
import cn.cetelem.des.object_support.task.pojo.BaseNode;
import cn.cetelem.des.object_support.task.pojo.EndNode;
import cn.cetelem.des.object_support.task.pojo.StartNode;
import cn.cetelem.des.object_support.task.pojo.TaskChar;
Element ele = nodeElements.get(nodeName);
BaseNode node;
if ("start".equals(nodeName)) {
node = new StartNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
String[] gotos = ele.attributeValue("goto").split("-");
node.setGotoBean(gotos[0]);
if (gotos.length == 2) {
node.setGotoMethod(gotos[1]);
}
} else if ("end".equals(nodeName)) {
node = new EndNode();
node.setName(ele.attributeValue("name"));
node.setExpression(ele.attributeValue("expression"));
node.setInType((ele.attributeValue("inType") == null || ""
.equals(ele.attributeValue("inType"))) ? defaultInType
: ele.attributeValue("inType"));
node.setOutType((ele.attributeValue("outType") == null || ""
.equals(ele.attributeValue("outType"))) ? defaultOutType
: ele.attributeValue("outType"));
node.setMethod(ele.attributeValue("method"));
} else { | node = new TaskChar(); |
ghabigant/task_easy | src/cn/cetelem/des/object_support/task/pojo/TaskEntitys.java | // Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
| import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.taskBean.TaskBean; | package cn.cetelem.des.object_support.task.pojo;
public class TaskEntitys {
private Map<String, TaskEntity> taskMap = new HashMap<String, TaskEntity>();
| // Path: src/cn/cetelem/des/taskBean/TaskBean.java
// public interface TaskBean {
// public Object invoke(Object Context)throws Exception;
// }
// Path: src/cn/cetelem/des/object_support/task/pojo/TaskEntitys.java
import java.util.HashMap;
import java.util.Map;
import cn.cetelem.des.taskBean.TaskBean;
package cn.cetelem.des.object_support.task.pojo;
public class TaskEntitys {
private Map<String, TaskEntity> taskMap = new HashMap<String, TaskEntity>();
| public TaskBean getTask(String beanName) { |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/DatabaseModel.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java
// public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
// {
// public static byte[] toPrimitive(final Byte[] array) {
// if (array == null) {
// return null;
// } else if (array.length == 0) {
// return new byte[0];
// }
// final byte[] result = new byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// public static Byte[] fromPrimitive(final byte[] array) {
// if ( array == null ) {
// return null;
// } else if ( array.length == 0 ) {
// return new Byte[0];
// }
// final Byte[] result = new Byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// @Override
// public DatabaseDataType getDatabaseDataType()
// {
// return DatabaseDataType.BLOB;
// }
//
// @Override
// public boolean isModelType( Type type )
// {
// return super.isModelType( type ) || byte[].class == type;
// }
//
// @Override
// public Type getModelType()
// {
// return Byte[].class;
// }
//
// @Override
// public void toContentValues( ContentValues contentValues, String fieldName, Byte[] bytes )
// {
// contentValues.put( fieldName, toPrimitive( bytes ) );
// }
//
// @Override
// public Byte[] toModelType( Byte[] bytes )
// {
// return bytes;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.util.Log;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbField;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.database.annotations.DbIndex;
import com.ensoft.restafari.database.annotations.DbPrimaryKey;
import com.ensoft.restafari.database.converters.ByteArrayFieldConverter;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap; | return _localId;
}
public void setLocalId( int id )
{
_localId = id;
}
@SuppressWarnings("unchecked")
public DatabaseModel fromCursor( Cursor cursor )
{
if ( cursor.getPosition() == -1 )
return this;
Field[] loadedFields = dbModelFields.get( getClass().getCanonicalName() );
if ( null != loadedFields && loadedFields.length > 0 )
{
for ( Field field : loadedFields )
{
field.setAccessible( true );
String fieldName = field.isAnnotationPresent( SerializedName.class ) ? field.getAnnotation( SerializedName.class ).value(): field.getName();
int index = cursor.getColumnIndex( fieldName );
if ( -1 != index )
{
try
{ | // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java
// public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
// {
// public static byte[] toPrimitive(final Byte[] array) {
// if (array == null) {
// return null;
// } else if (array.length == 0) {
// return new byte[0];
// }
// final byte[] result = new byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// public static Byte[] fromPrimitive(final byte[] array) {
// if ( array == null ) {
// return null;
// } else if ( array.length == 0 ) {
// return new Byte[0];
// }
// final Byte[] result = new Byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// @Override
// public DatabaseDataType getDatabaseDataType()
// {
// return DatabaseDataType.BLOB;
// }
//
// @Override
// public boolean isModelType( Type type )
// {
// return super.isModelType( type ) || byte[].class == type;
// }
//
// @Override
// public Type getModelType()
// {
// return Byte[].class;
// }
//
// @Override
// public void toContentValues( ContentValues contentValues, String fieldName, Byte[] bytes )
// {
// contentValues.put( fieldName, toPrimitive( bytes ) );
// }
//
// @Override
// public Byte[] toModelType( Byte[] bytes )
// {
// return bytes;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseModel.java
import android.content.ContentValues;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.util.Log;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbField;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.database.annotations.DbIndex;
import com.ensoft.restafari.database.annotations.DbPrimaryKey;
import com.ensoft.restafari.database.converters.ByteArrayFieldConverter;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
return _localId;
}
public void setLocalId( int id )
{
_localId = id;
}
@SuppressWarnings("unchecked")
public DatabaseModel fromCursor( Cursor cursor )
{
if ( cursor.getPosition() == -1 )
return this;
Field[] loadedFields = dbModelFields.get( getClass().getCanonicalName() );
if ( null != loadedFields && loadedFields.length > 0 )
{
for ( Field field : loadedFields )
{
field.setAccessible( true );
String fieldName = field.isAnnotationPresent( SerializedName.class ) ? field.getAnnotation( SerializedName.class ).value(): field.getName();
int index = cursor.getColumnIndex( fieldName );
if ( -1 != index )
{
try
{ | FieldTypeConverter fieldTypeConverter = FieldTypeConverterService.getInstance().get( field.getType() ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/DatabaseModel.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java
// public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
// {
// public static byte[] toPrimitive(final Byte[] array) {
// if (array == null) {
// return null;
// } else if (array.length == 0) {
// return new byte[0];
// }
// final byte[] result = new byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// public static Byte[] fromPrimitive(final byte[] array) {
// if ( array == null ) {
// return null;
// } else if ( array.length == 0 ) {
// return new Byte[0];
// }
// final Byte[] result = new Byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// @Override
// public DatabaseDataType getDatabaseDataType()
// {
// return DatabaseDataType.BLOB;
// }
//
// @Override
// public boolean isModelType( Type type )
// {
// return super.isModelType( type ) || byte[].class == type;
// }
//
// @Override
// public Type getModelType()
// {
// return Byte[].class;
// }
//
// @Override
// public void toContentValues( ContentValues contentValues, String fieldName, Byte[] bytes )
// {
// contentValues.put( fieldName, toPrimitive( bytes ) );
// }
//
// @Override
// public Byte[] toModelType( Byte[] bytes )
// {
// return bytes;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.util.Log;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbField;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.database.annotations.DbIndex;
import com.ensoft.restafari.database.annotations.DbPrimaryKey;
import com.ensoft.restafari.database.converters.ByteArrayFieldConverter;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap; | {
for ( Field field : loadedFields )
{
field.setAccessible( true );
String fieldName = field.isAnnotationPresent( SerializedName.class ) ? field.getAnnotation( SerializedName.class ).value(): field.getName();
int index = cursor.getColumnIndex( fieldName );
if ( -1 != index )
{
try
{
FieldTypeConverter fieldTypeConverter = FieldTypeConverterService.getInstance().get( field.getType() );
if ( DatabaseDataType.INTEGER == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getInt( index ) ) );
else if ( DatabaseDataType.BIGINT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getLong( index ) ) );
else if ( DatabaseDataType.TEXT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getString( index ) ) );
else if ( DatabaseDataType.SMALLINT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getShort( index ) ) );
else if ( DatabaseDataType.REAL == fieldTypeConverter.getDatabaseDataType() || DatabaseDataType.FLOAT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getFloat( index ) ) );
else if ( DatabaseDataType.DOUBLE == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getDouble( index ) ) );
else if ( DatabaseDataType.BOOLEAN == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getInt( index ) ) );
else if ( DatabaseDataType.BLOB == fieldTypeConverter.getDatabaseDataType() ) | // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java
// public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
// {
// public static byte[] toPrimitive(final Byte[] array) {
// if (array == null) {
// return null;
// } else if (array.length == 0) {
// return new byte[0];
// }
// final byte[] result = new byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// public static Byte[] fromPrimitive(final byte[] array) {
// if ( array == null ) {
// return null;
// } else if ( array.length == 0 ) {
// return new Byte[0];
// }
// final Byte[] result = new Byte[array.length];
// for (int i = 0; i < array.length; i++) {
// result[i] = array[i];
// }
// return result;
// }
//
// @Override
// public DatabaseDataType getDatabaseDataType()
// {
// return DatabaseDataType.BLOB;
// }
//
// @Override
// public boolean isModelType( Type type )
// {
// return super.isModelType( type ) || byte[].class == type;
// }
//
// @Override
// public Type getModelType()
// {
// return Byte[].class;
// }
//
// @Override
// public void toContentValues( ContentValues contentValues, String fieldName, Byte[] bytes )
// {
// contentValues.put( fieldName, toPrimitive( bytes ) );
// }
//
// @Override
// public Byte[] toModelType( Byte[] bytes )
// {
// return bytes;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseModel.java
import android.content.ContentValues;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.util.Log;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbField;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.database.annotations.DbIndex;
import com.ensoft.restafari.database.annotations.DbPrimaryKey;
import com.ensoft.restafari.database.converters.ByteArrayFieldConverter;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
{
for ( Field field : loadedFields )
{
field.setAccessible( true );
String fieldName = field.isAnnotationPresent( SerializedName.class ) ? field.getAnnotation( SerializedName.class ).value(): field.getName();
int index = cursor.getColumnIndex( fieldName );
if ( -1 != index )
{
try
{
FieldTypeConverter fieldTypeConverter = FieldTypeConverterService.getInstance().get( field.getType() );
if ( DatabaseDataType.INTEGER == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getInt( index ) ) );
else if ( DatabaseDataType.BIGINT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getLong( index ) ) );
else if ( DatabaseDataType.TEXT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getString( index ) ) );
else if ( DatabaseDataType.SMALLINT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getShort( index ) ) );
else if ( DatabaseDataType.REAL == fieldTypeConverter.getDatabaseDataType() || DatabaseDataType.FLOAT == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getFloat( index ) ) );
else if ( DatabaseDataType.DOUBLE == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getDouble( index ) ) );
else if ( DatabaseDataType.BOOLEAN == fieldTypeConverter.getDatabaseDataType() )
field.set( this, fieldTypeConverter.toModelType( cursor.getInt( index ) ) );
else if ( DatabaseDataType.BLOB == fieldTypeConverter.getDatabaseDataType() ) | field.set( this, fieldTypeConverter.toModelType( ByteArrayFieldConverter.fromPrimitive( cursor.getBlob( index ) ) ) ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/DatabaseTable.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ForeignKeyHelper.java
// public class ForeignKeyHelper
// {
// public static String fromAction( int action )
// {
// switch ( action )
// {
// case DbForeignKey.NO_ACTION: return "NO ACTION";
// case DbForeignKey.RESTRICT: return "RESTRICT";
// case DbForeignKey.SET_NULL: return "SET NULL";
// case DbForeignKey.SET_DEFAULT: return "SET DEFAULT";
// case DbForeignKey.CASCADE: return "CASCADE";
// }
//
// return null;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/StringUtils.java
// public class StringUtils
// {
// public static String join( String[] strings, String glue )
// {
// StringBuilder sb = new StringBuilder();
//
// for ( int i = 0; i < strings.length; i++ )
// {
// sb.append( strings[i] );
//
// if (i != strings.length - 1)
// {
// sb.append(glue);
// }
// }
//
// return sb.toString();
// }
// }
| import android.content.ContentResolver;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.helper.ForeignKeyHelper;
import com.ensoft.restafari.helper.StringUtils;
import java.util.ArrayList; |
for ( int i = 0; i < columns.size(); i++ )
{
TableColumn column = columns.get( i );
sql += column.getColumnName() + " " + column.getDataType();
if ( column.getColumnName().equals( idName ) )
{
sql += " PRIMARY KEY AUTOINCREMENT";
}
boolean isPrimaryKey = column.getColumnName().equals( getColumnPK().getColumnName() );
if ( column.hasIndex() || ( !column.getColumnName().equals( idName ) && isPrimaryKey ) )
{
String uniqueIndex = isPrimaryKey ? " UNIQUE" : ( column.getIndex().isUnique() ? " UNIQUE" : "" );
sqlIndexes.add( "CREATE" + uniqueIndex + " INDEX " + getTableName() + "_" + column.getColumnName() + "_index ON " + getTableName() + " (" + column.getColumnName() + ");" );
}
if ( column.isForeignKey() )
{
DbForeignKey fk = column.getForeignKey();
String[] fkPart = fk.value().split( "\\." );
if ( fkPart.length >= 2 )
{
String fkSql = "FOREIGN KEY(" + column.getColumnName() + ") REFERENCES " + fkPart[0] + "(" + fkPart[1] + ")";
| // Path: restafari/src/main/java/com/ensoft/restafari/helper/ForeignKeyHelper.java
// public class ForeignKeyHelper
// {
// public static String fromAction( int action )
// {
// switch ( action )
// {
// case DbForeignKey.NO_ACTION: return "NO ACTION";
// case DbForeignKey.RESTRICT: return "RESTRICT";
// case DbForeignKey.SET_NULL: return "SET NULL";
// case DbForeignKey.SET_DEFAULT: return "SET DEFAULT";
// case DbForeignKey.CASCADE: return "CASCADE";
// }
//
// return null;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/StringUtils.java
// public class StringUtils
// {
// public static String join( String[] strings, String glue )
// {
// StringBuilder sb = new StringBuilder();
//
// for ( int i = 0; i < strings.length; i++ )
// {
// sb.append( strings[i] );
//
// if (i != strings.length - 1)
// {
// sb.append(glue);
// }
// }
//
// return sb.toString();
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseTable.java
import android.content.ContentResolver;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.helper.ForeignKeyHelper;
import com.ensoft.restafari.helper.StringUtils;
import java.util.ArrayList;
for ( int i = 0; i < columns.size(); i++ )
{
TableColumn column = columns.get( i );
sql += column.getColumnName() + " " + column.getDataType();
if ( column.getColumnName().equals( idName ) )
{
sql += " PRIMARY KEY AUTOINCREMENT";
}
boolean isPrimaryKey = column.getColumnName().equals( getColumnPK().getColumnName() );
if ( column.hasIndex() || ( !column.getColumnName().equals( idName ) && isPrimaryKey ) )
{
String uniqueIndex = isPrimaryKey ? " UNIQUE" : ( column.getIndex().isUnique() ? " UNIQUE" : "" );
sqlIndexes.add( "CREATE" + uniqueIndex + " INDEX " + getTableName() + "_" + column.getColumnName() + "_index ON " + getTableName() + " (" + column.getColumnName() + ");" );
}
if ( column.isForeignKey() )
{
DbForeignKey fk = column.getForeignKey();
String[] fkPart = fk.value().split( "\\." );
if ( fkPart.length >= 2 )
{
String fkSql = "FOREIGN KEY(" + column.getColumnName() + ") REFERENCES " + fkPart[0] + "(" + fkPart[1] + ")";
| fkSql += " ON UPDATE " + ForeignKeyHelper.fromAction( fk.onUpdate() ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/DatabaseTable.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ForeignKeyHelper.java
// public class ForeignKeyHelper
// {
// public static String fromAction( int action )
// {
// switch ( action )
// {
// case DbForeignKey.NO_ACTION: return "NO ACTION";
// case DbForeignKey.RESTRICT: return "RESTRICT";
// case DbForeignKey.SET_NULL: return "SET NULL";
// case DbForeignKey.SET_DEFAULT: return "SET DEFAULT";
// case DbForeignKey.CASCADE: return "CASCADE";
// }
//
// return null;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/StringUtils.java
// public class StringUtils
// {
// public static String join( String[] strings, String glue )
// {
// StringBuilder sb = new StringBuilder();
//
// for ( int i = 0; i < strings.length; i++ )
// {
// sb.append( strings[i] );
//
// if (i != strings.length - 1)
// {
// sb.append(glue);
// }
// }
//
// return sb.toString();
// }
// }
| import android.content.ContentResolver;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.helper.ForeignKeyHelper;
import com.ensoft.restafari.helper.StringUtils;
import java.util.ArrayList; | sql += ");";
}
else
{
sql += ", ";
}
}
}
for ( int i = 0; i < sqlForeignKeys.size(); i++ )
{
sql += sqlForeignKeys.get(i);
if ( i < sqlForeignKeys.size() - 1 )
{
sql += ", ";
}
else
{
sql += ");";
}
}
db.execSQL( sql );
if ( columns.getCompositeIndices().size() > 0 )
{
for ( DbCompositeIndex compositeIndex : columns.getCompositeIndices() )
{
String uniqueIndex = compositeIndex.isUnique() ? " UNIQUE" : ""; | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ForeignKeyHelper.java
// public class ForeignKeyHelper
// {
// public static String fromAction( int action )
// {
// switch ( action )
// {
// case DbForeignKey.NO_ACTION: return "NO ACTION";
// case DbForeignKey.RESTRICT: return "RESTRICT";
// case DbForeignKey.SET_NULL: return "SET NULL";
// case DbForeignKey.SET_DEFAULT: return "SET DEFAULT";
// case DbForeignKey.CASCADE: return "CASCADE";
// }
//
// return null;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/StringUtils.java
// public class StringUtils
// {
// public static String join( String[] strings, String glue )
// {
// StringBuilder sb = new StringBuilder();
//
// for ( int i = 0; i < strings.length; i++ )
// {
// sb.append( strings[i] );
//
// if (i != strings.length - 1)
// {
// sb.append(glue);
// }
// }
//
// return sb.toString();
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseTable.java
import android.content.ContentResolver;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import com.ensoft.restafari.database.annotations.DbCompositeIndex;
import com.ensoft.restafari.database.annotations.DbForeignKey;
import com.ensoft.restafari.helper.ForeignKeyHelper;
import com.ensoft.restafari.helper.StringUtils;
import java.util.ArrayList;
sql += ");";
}
else
{
sql += ", ";
}
}
}
for ( int i = 0; i < sqlForeignKeys.size(); i++ )
{
sql += sqlForeignKeys.get(i);
if ( i < sqlForeignKeys.size() - 1 )
{
sql += ", ";
}
else
{
sql += ");";
}
}
db.execSQL( sql );
if ( columns.getCompositeIndices().size() > 0 )
{
for ( DbCompositeIndex compositeIndex : columns.getCompositeIndices() )
{
String uniqueIndex = compositeIndex.isUnique() ? " UNIQUE" : ""; | String indexName = StringUtils.join( compositeIndex.value(), "_" ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public abstract class FieldTypeConverter<DbType, ModelType>
{ | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public abstract class FieldTypeConverter<DbType, ModelType>
{ | public abstract DatabaseDataType getDatabaseDataType(); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/IntegerFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class IntegerFieldTypeConverter extends FieldTypeConverter<Integer,Integer>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/IntegerFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class IntegerFieldTypeConverter extends FieldTypeConverter<Integer,Integer>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/FloatFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class FloatFieldTypeConverter extends FieldTypeConverter<Float,Float>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FloatFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class FloatFieldTypeConverter extends FieldTypeConverter<Float,Float>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
| import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse; | package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId; | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java
import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse;
package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId; | public NetworkResponse networkResponse; |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
| import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse; | package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId;
public NetworkResponse networkResponse;
| // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java
import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse;
package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId;
public NetworkResponse networkResponse;
| public ThreadMode getThreadMode() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
| import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse; | package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId;
public NetworkResponse networkResponse;
public ThreadMode getThreadMode()
{ | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadMode.java
// public enum ThreadMode
// {
// MAIN,
// ASYNC
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/helper/ThreadRunner.java
// public class ThreadRunner
// {
// protected static ThreadMode defaultThreadMode = ThreadMode.MAIN;
//
// public static ThreadMode getDefaultThreadMode()
// {
// return defaultThreadMode;
// }
//
// public static void setDefaultThreadMode( ThreadMode defaultThreadMode )
// {
// ThreadRunner.defaultThreadMode = defaultThreadMode;
// }
//
// public static void run( ThreadMode threadMode, Runnable runnable )
// {
// if ( threadMode == ThreadMode.ASYNC )
// {
// runnable.run();
// }
// else if ( threadMode == ThreadMode.MAIN )
// {
// new Handler( Looper.getMainLooper() ).post( runnable );
// }
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseListener.java
import android.content.Context;
import com.ensoft.restafari.helper.ThreadMode;
import com.ensoft.restafari.helper.ThreadRunner;
import com.ensoft.restafari.network.rest.response.NetworkResponse;
package com.ensoft.restafari.network.processor;
public abstract class ResponseListener<T>
{
public long requestId;
public NetworkResponse networkResponse;
public ThreadMode getThreadMode()
{ | return ThreadRunner.getDefaultThreadMode(); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/LongFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class LongFieldTypeConverter extends FieldTypeConverter<Long,Long>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/LongFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class LongFieldTypeConverter extends FieldTypeConverter<Long,Long>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/CharacterFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class CharacterFieldTypeConverter extends FieldTypeConverter<String,Character>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/CharacterFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class CharacterFieldTypeConverter extends FieldTypeConverter<String,Character>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/DatabaseTableModel.java | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ReflectionHelper.java
// public class ReflectionHelper
// {
// private static final String TAG = ReflectionHelper.class.getSimpleName();
//
// @SuppressWarnings("unchecked")
// public static <T> T createInstance(Class<?> clazz)
// {
// String msg = null;
// Object newInstance = null;
// try
// {
// for ( Constructor<?> constructor : clazz.getConstructors() )
// {
// if ( constructor.getParameterTypes().length == 0 )
// {
// newInstance = constructor.newInstance();
//
// break;
// }
// }
//
// if ( null == newInstance )
// {
// msg = "Class must have a default constructor without parameters";
// }
// }
// catch (IllegalArgumentException e)
// {
// msg = e.getMessage();
// }
// catch (Exception e)
// {
// msg = "ReflectiveOperationException";
// }
// finally
// {
// if (msg != null)
// {
// Log.e( TAG, "error instantiating type " + clazz.getSimpleName() + "\n" + msg );
// newInstance = null;
// }
// }
//
// return (T) newInstance;
// }
//
// public static Type getTypeArgument( Object object, int position)
// {
// Type genericType = null;
//
// if (object != null)
// {
// try
// {
// genericType = ((ParameterizedType) object.getClass().getGenericSuperclass()).getActualTypeArguments()[position];
// }
// catch (Exception e)
// {
// //do nothing
// }
// }
//
// return genericType;
// }
// }
| import android.content.ContentValues;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;
import android.text.TextUtils;
import com.ensoft.restafari.helper.ReflectionHelper;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.Nullable; | package com.ensoft.restafari.database;
public class DatabaseTableModel<T extends DatabaseModel> extends DatabaseTable
{
protected Class<? extends DatabaseModel> clazz;
protected TableColumns tableColumns;
public DatabaseTableModel( Class<? extends DatabaseModel> model )
{
clazz = model;
TableColumns cachedTableColumns = T.getCachedTableColumns( clazz.getCanonicalName() );
if ( null != cachedTableColumns )
{
tableColumns = cachedTableColumns;
}
else
{ | // Path: restafari/src/main/java/com/ensoft/restafari/helper/ReflectionHelper.java
// public class ReflectionHelper
// {
// private static final String TAG = ReflectionHelper.class.getSimpleName();
//
// @SuppressWarnings("unchecked")
// public static <T> T createInstance(Class<?> clazz)
// {
// String msg = null;
// Object newInstance = null;
// try
// {
// for ( Constructor<?> constructor : clazz.getConstructors() )
// {
// if ( constructor.getParameterTypes().length == 0 )
// {
// newInstance = constructor.newInstance();
//
// break;
// }
// }
//
// if ( null == newInstance )
// {
// msg = "Class must have a default constructor without parameters";
// }
// }
// catch (IllegalArgumentException e)
// {
// msg = e.getMessage();
// }
// catch (Exception e)
// {
// msg = "ReflectiveOperationException";
// }
// finally
// {
// if (msg != null)
// {
// Log.e( TAG, "error instantiating type " + clazz.getSimpleName() + "\n" + msg );
// newInstance = null;
// }
// }
//
// return (T) newInstance;
// }
//
// public static Type getTypeArgument( Object object, int position)
// {
// Type genericType = null;
//
// if (object != null)
// {
// try
// {
// genericType = ((ParameterizedType) object.getClass().getGenericSuperclass()).getActualTypeArguments()[position];
// }
// catch (Exception e)
// {
// //do nothing
// }
// }
//
// return genericType;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseTableModel.java
import android.content.ContentValues;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;
import android.text.TextUtils;
import com.ensoft.restafari.helper.ReflectionHelper;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.Nullable;
package com.ensoft.restafari.database;
public class DatabaseTableModel<T extends DatabaseModel> extends DatabaseTable
{
protected Class<? extends DatabaseModel> clazz;
protected TableColumns tableColumns;
public DatabaseTableModel( Class<? extends DatabaseModel> model )
{
clazz = model;
TableColumns cachedTableColumns = T.getCachedTableColumns( clazz.getCanonicalName() );
if ( null != cachedTableColumns )
{
tableColumns = cachedTableColumns;
}
else
{ | DatabaseModel instancedModel = ReflectionHelper.createInstance( model ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java | // Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
// public abstract class ResponseProcessor<T>
// {
// public long requestId;
// public NetworkResponse networkResponse;
//
// public long getRequestId()
// {
// return requestId;
// }
//
// public NetworkResponse getNetworkResponse()
// {
// return networkResponse;
// }
//
// public abstract void handleResponse( Context context, RequestConfiguration request, T response );
//
// public void handleError( Context context, RequestConfiguration request, int errorCode, String errorMessage ) {}
// }
| import com.android.volley.Request;
import com.ensoft.restafari.network.processor.ResponseProcessor; | package com.ensoft.restafari.network.rest.request;
public class RequestConfiguration
{
private final Class<? extends Request> requestClass;
private final Class<?> responseClass; | // Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
// public abstract class ResponseProcessor<T>
// {
// public long requestId;
// public NetworkResponse networkResponse;
//
// public long getRequestId()
// {
// return requestId;
// }
//
// public NetworkResponse getNetworkResponse()
// {
// return networkResponse;
// }
//
// public abstract void handleResponse( Context context, RequestConfiguration request, T response );
//
// public void handleError( Context context, RequestConfiguration request, int errorCode, String errorMessage ) {}
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
import com.android.volley.Request;
import com.ensoft.restafari.network.processor.ResponseProcessor;
package com.ensoft.restafari.network.rest.request;
public class RequestConfiguration
{
private final Class<? extends Request> requestClass;
private final Class<?> responseClass; | private final Class<? extends ResponseProcessor> processorClass; |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/StringFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class StringFieldTypeConverter extends FieldTypeConverter<String,String>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/StringFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class StringFieldTypeConverter extends FieldTypeConverter<String,String>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/ByteFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class ByteFieldTypeConverter extends FieldTypeConverter<Byte,Byte>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class ByteFieldTypeConverter extends FieldTypeConverter<Byte,Byte>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/DoubleFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class DoubleFieldTypeConverter extends FieldTypeConverter<Double,Double>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/DoubleFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class DoubleFieldTypeConverter extends FieldTypeConverter<Double,Double>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/BooleanFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class BooleanFieldTypeConverter extends FieldTypeConverter<Integer,Boolean>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/BooleanFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class BooleanFieldTypeConverter extends FieldTypeConverter<Integer,Boolean>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/JsonFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import android.text.TextUtils;
import com.ensoft.restafari.database.DatabaseDataType;
import com.google.gson.Gson;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class JsonFieldTypeConverter<ModelType> extends FieldTypeConverter<String,ModelType>
{
protected Type classType;
public JsonFieldTypeConverter( Type modelType )
{
this.classType = modelType;
}
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/JsonFieldTypeConverter.java
import android.content.ContentValues;
import android.text.TextUtils;
import com.ensoft.restafari.database.DatabaseDataType;
import com.google.gson.Gson;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class JsonFieldTypeConverter<ModelType> extends FieldTypeConverter<String,ModelType>
{
protected Type classType;
public JsonFieldTypeConverter( Type modelType )
{
this.classType = modelType;
}
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/UUIDFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
import java.util.UUID; | package com.ensoft.restafari.database.converters;
public class UUIDFieldTypeConverter extends FieldTypeConverter<String, UUID>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/UUIDFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
import java.util.UUID;
package com.ensoft.restafari.database.converters;
public class UUIDFieldTypeConverter extends FieldTypeConverter<String, UUID>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/ShortFieldTypeConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class ShortFieldTypeConverter extends FieldTypeConverter<Short,Short>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ShortFieldTypeConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class ShortFieldTypeConverter extends FieldTypeConverter<Short,Short>
{
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
| import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type; | package com.ensoft.restafari.database.converters;
public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
{
public static byte[] toPrimitive(final Byte[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new byte[0];
}
final byte[] result = new byte[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static Byte[] fromPrimitive(final byte[] array) {
if ( array == null ) {
return null;
} else if ( array.length == 0 ) {
return new Byte[0];
}
final Byte[] result = new Byte[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/database/DatabaseDataType.java
// public enum DatabaseDataType
// {
// INTEGER("INTEGER"),
// TINYINT("TINYINT"),
// SMALLINT("SMALLINT"),
// BIGINT("BIGINT"),
// REAL("REAL"),
// DOUBLE("DOUBLE"),
// FLOAT("FLOAT"),
// BOOLEAN("BOOLEAN"),
// TEXT("TEXT"),
// BLOB("BLOB"),
// ANY("ANY");
//
// private final String text;
//
// DatabaseDataType(final String text)
// {
// this.text = text;
// }
//
// @Override
// public String toString()
// {
// return text;
// }
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/converters/ByteArrayFieldConverter.java
import android.content.ContentValues;
import com.ensoft.restafari.database.DatabaseDataType;
import java.lang.reflect.Type;
package com.ensoft.restafari.database.converters;
public class ByteArrayFieldConverter extends FieldTypeConverter<Byte[],Byte[]>
{
public static byte[] toPrimitive(final Byte[] array) {
if (array == null) {
return null;
} else if (array.length == 0) {
return new byte[0];
}
final byte[] result = new byte[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
public static Byte[] fromPrimitive(final byte[] array) {
if ( array == null ) {
return null;
} else if ( array.length == 0 ) {
return new Byte[0];
}
final Byte[] result = new Byte[array.length];
for (int i = 0; i < array.length; i++) {
result[i] = array[i];
}
return result;
}
@Override | public DatabaseDataType getDatabaseDataType() |
SpartanJ/restafari | app-test/src/main/java/com/ensoft/restafari_app/example/IpResponseProcessor.java | // Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
// public abstract class ResponseProcessor<T>
// {
// public long requestId;
// public NetworkResponse networkResponse;
//
// public long getRequestId()
// {
// return requestId;
// }
//
// public NetworkResponse getNetworkResponse()
// {
// return networkResponse;
// }
//
// public abstract void handleResponse( Context context, RequestConfiguration request, T response );
//
// public void handleError( Context context, RequestConfiguration request, int errorCode, String errorMessage ) {}
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
| import android.content.Context;
import android.provider.Settings;
import com.ensoft.restafari.network.processor.ResponseProcessor;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone; | package com.ensoft.restafari_app.example;
// The response processor, it runs in the background, this should be separated from the UI, this stores the result
public class IpResponseProcessor extends ResponseProcessor<IpModel>
{
@Override | // Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
// public abstract class ResponseProcessor<T>
// {
// public long requestId;
// public NetworkResponse networkResponse;
//
// public long getRequestId()
// {
// return requestId;
// }
//
// public NetworkResponse getNetworkResponse()
// {
// return networkResponse;
// }
//
// public abstract void handleResponse( Context context, RequestConfiguration request, T response );
//
// public void handleError( Context context, RequestConfiguration request, int errorCode, String errorMessage ) {}
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
// Path: app-test/src/main/java/com/ensoft/restafari_app/example/IpResponseProcessor.java
import android.content.Context;
import android.provider.Settings;
import com.ensoft.restafari.network.processor.ResponseProcessor;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
package com.ensoft.restafari_app.example;
// The response processor, it runs in the background, this should be separated from the UI, this stores the result
public class IpResponseProcessor extends ResponseProcessor<IpModel>
{
@Override | public void handleResponse( Context context, RequestConfiguration request, IpModel response ) |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java | // Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
| import android.content.Context;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import com.ensoft.restafari.network.rest.response.NetworkResponse; | package com.ensoft.restafari.network.processor;
public abstract class ResponseProcessor<T>
{
public long requestId; | // Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
import android.content.Context;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import com.ensoft.restafari.network.rest.response.NetworkResponse;
package com.ensoft.restafari.network.processor;
public abstract class ResponseProcessor<T>
{
public long requestId; | public NetworkResponse networkResponse; |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java | // Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
| import android.content.Context;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import com.ensoft.restafari.network.rest.response.NetworkResponse; | package com.ensoft.restafari.network.processor;
public abstract class ResponseProcessor<T>
{
public long requestId;
public NetworkResponse networkResponse;
public long getRequestId()
{
return requestId;
}
public NetworkResponse getNetworkResponse()
{
return networkResponse;
}
| // Path: restafari/src/main/java/com/ensoft/restafari/network/rest/request/RequestConfiguration.java
// public class RequestConfiguration
// {
// private final Class<? extends Request> requestClass;
// private final Class<?> responseClass;
// private final Class<? extends ResponseProcessor> processorClass;
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass, Class<?> responseClass )
// {
// this.requestClass = requestClass;
// this.processorClass = processorClass;
// this.responseClass = responseClass;
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass, Class<? extends ResponseProcessor> processorClass )
// {
// this( requestClass, processorClass, null );
// }
//
// public RequestConfiguration( Class<? extends Request> requestClass )
// {
// this( requestClass, null, null );
// }
//
// public Class<?> getResponseClass()
// {
// return responseClass;
// }
//
// public Class<? extends Request> getRequestClass()
// {
// return requestClass;
// }
//
// public Class<? extends ResponseProcessor> getProcessorClass()
// {
// return processorClass;
// }
// }
//
// Path: restafari/src/main/java/com/ensoft/restafari/network/rest/response/NetworkResponse.java
// public class NetworkResponse implements Serializable
// {
// private List<Header> convertHeaders( List<com.android.volley.Header> headers )
// {
// ArrayList<Header> ret = new ArrayList<>();
//
// for ( com.android.volley.Header header : headers )
// {
// ret.add( new Header( header.getName(), header.getValue() ) );
// }
//
// return ret;
// }
//
// public NetworkResponse( com.android.volley.NetworkResponse networkResponse )
// {
// this.statusCode = networkResponse.statusCode;
// this.headers = networkResponse.headers;
// this.allHeaders = convertHeaders( networkResponse.allHeaders );
// this.notModified = networkResponse.notModified;
// this.networkTimeMs = networkResponse.networkTimeMs;
// }
//
// public NetworkResponse( int statusCode, Map<String, String> headers, List<Header> allHeaders, boolean notModified, long networkTimeMs )
// {
// this.statusCode = statusCode;
// this.headers = headers;
// this.allHeaders = allHeaders;
// this.notModified = notModified;
// this.networkTimeMs = networkTimeMs;
// }
//
// /** The HTTP status code. */
// public final int statusCode;
//
// /** Response headers. */
// public final Map<String, String> headers;
//
// /** All response headers. */
// public final List<Header> allHeaders;
//
// /** True if the server returned a 304 (Not Modified). */
// public final boolean notModified;
//
// /** Network roundtrip time in milliseconds. */
// public final long networkTimeMs;
// }
// Path: restafari/src/main/java/com/ensoft/restafari/network/processor/ResponseProcessor.java
import android.content.Context;
import com.ensoft.restafari.network.rest.request.RequestConfiguration;
import com.ensoft.restafari.network.rest.response.NetworkResponse;
package com.ensoft.restafari.network.processor;
public abstract class ResponseProcessor<T>
{
public long requestId;
public NetworkResponse networkResponse;
public long getRequestId()
{
return requestId;
}
public NetworkResponse getNetworkResponse()
{
return networkResponse;
}
| public abstract void handleResponse( Context context, RequestConfiguration request, T response ); |
SpartanJ/restafari | restafari/src/main/java/com/ensoft/restafari/database/TableCollection.java | // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
| import android.content.res.Resources;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import java.util.ArrayList;
import java.util.List; | package com.ensoft.restafari.database;
public class TableCollection extends ArrayList<DatabaseTable>
{
private String dbName;
private int dbVersion;
| // Path: restafari/src/main/java/com/ensoft/restafari/database/converters/FieldTypeConverter.java
// public abstract class FieldTypeConverter<DbType, ModelType>
// {
// public abstract DatabaseDataType getDatabaseDataType();
//
// public boolean isModelType( Type type )
// {
// return getModelType() == type;
// }
//
// public abstract Type getModelType();
//
// public abstract void toContentValues( ContentValues contentValues, String fieldName, ModelType modelType );
//
// public abstract ModelType toModelType( DbType dbType );
// }
// Path: restafari/src/main/java/com/ensoft/restafari/database/TableCollection.java
import android.content.res.Resources;
import com.ensoft.restafari.database.converters.FieldTypeConverter;
import java.util.ArrayList;
import java.util.List;
package com.ensoft.restafari.database;
public class TableCollection extends ArrayList<DatabaseTable>
{
private String dbName;
private int dbVersion;
| public TableCollection( String dbName, int dbVersion, List<FieldTypeConverter> fieldTypeConverters ) |
zozoh/zdoc | java/test/org/nutz/zdoc/ZDocBaseTest.java | // Path: java/src/org/nutz/am/AmFactory.java
// public class AmFactory {
//
// /**
// * 从工厂中获取一个自动机的实例
// *
// * @param amType
// * 自动机的类型
// *
// * @param amName
// * 自动机的名称
// *
// * @return 自动机实例
// */
// public <T extends Am<?>> T getAm(Class<T> amType, String amName) {
// return ioc.get(amType, amName);
// }
//
// private Ioc ioc;
//
// public AmFactory(String path) {
// this(new NutIoc(new JsonLoader(path)));
// }
//
// public AmFactory(Ioc ioc) {
// this.ioc = ioc;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.nutz.zdoc.ZDocEleType.IMG;
import java.util.HashMap;
import java.util.Map;
import org.nutz.am.AmFactory;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.Streams;
import org.nutz.lang.util.Context; | package org.nutz.zdoc;
public class ZDocBaseTest {
protected Parser parser;
| // Path: java/src/org/nutz/am/AmFactory.java
// public class AmFactory {
//
// /**
// * 从工厂中获取一个自动机的实例
// *
// * @param amType
// * 自动机的类型
// *
// * @param amName
// * 自动机的名称
// *
// * @return 自动机实例
// */
// public <T extends Am<?>> T getAm(Class<T> amType, String amName) {
// return ioc.get(amType, amName);
// }
//
// private Ioc ioc;
//
// public AmFactory(String path) {
// this(new NutIoc(new JsonLoader(path)));
// }
//
// public AmFactory(Ioc ioc) {
// this.ioc = ioc;
// }
//
// }
// Path: java/test/org/nutz/zdoc/ZDocBaseTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.nutz.zdoc.ZDocEleType.IMG;
import java.util.HashMap;
import java.util.Map;
import org.nutz.am.AmFactory;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.Streams;
import org.nutz.lang.util.Context;
package org.nutz.zdoc;
public class ZDocBaseTest {
protected Parser parser;
| protected AmFactory NewAmFactory(String name) { |
zozoh/zdoc | java/test/org/nutz/zdoc/BaseParserTest.java | // Path: java/src/org/nutz/am/AmFactory.java
// public class AmFactory {
//
// /**
// * 从工厂中获取一个自动机的实例
// *
// * @param amType
// * 自动机的类型
// *
// * @param amName
// * 自动机的名称
// *
// * @return 自动机实例
// */
// public <T extends Am<?>> T getAm(Class<T> amType, String amName) {
// return ioc.get(amType, amName);
// }
//
// private Ioc ioc;
//
// public AmFactory(String path) {
// this(new NutIoc(new JsonLoader(path)));
// }
//
// public AmFactory(Ioc ioc) {
// this.ioc = ioc;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.nutz.am.AmFactory;
import org.nutz.json.Json;
import org.nutz.lang.Lang; | package org.nutz.zdoc;
public abstract class BaseParserTest extends ZDocBaseTest {
protected void _C(ZDocNode nd,
ZDocNodeType exType,
int exChildCount,
String exAttrs,
String exText,
int... iPaths) {
ZDocNode nd2 = nd.node(iPaths);
Object exMap = Json.fromJson(exAttrs);
Object attMap = Json.fromJson(Json.toJson(nd2.attrs().getInnerMap()));
assertEquals(exType, nd2.type());
assertEquals(exChildCount, nd2.children().size());
assertTrue(Lang.equals(exMap, attMap));
assertEquals(exText, nd2.text());
}
protected void _CE(ZDocNode nd,
int index,
ZDocEleType exType,
String exAttrs,
String exText,
int... iPaths) {
ZDocEle ele = nd.eles().get(index).ele(iPaths);
Object exMap = Json.fromJson(exAttrs);
Object attMap = Json.fromJson(ele.attrsAsJson());
assertEquals(exType, ele.type());
assertTrue(Lang.equals(exMap, attMap));
assertEquals(exText, ele.text());
}
| // Path: java/src/org/nutz/am/AmFactory.java
// public class AmFactory {
//
// /**
// * 从工厂中获取一个自动机的实例
// *
// * @param amType
// * 自动机的类型
// *
// * @param amName
// * 自动机的名称
// *
// * @return 自动机实例
// */
// public <T extends Am<?>> T getAm(Class<T> amType, String amName) {
// return ioc.get(amType, amName);
// }
//
// private Ioc ioc;
//
// public AmFactory(String path) {
// this(new NutIoc(new JsonLoader(path)));
// }
//
// public AmFactory(Ioc ioc) {
// this.ioc = ioc;
// }
//
// }
// Path: java/test/org/nutz/zdoc/BaseParserTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.nutz.am.AmFactory;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
package org.nutz.zdoc;
public abstract class BaseParserTest extends ZDocBaseTest {
protected void _C(ZDocNode nd,
ZDocNodeType exType,
int exChildCount,
String exAttrs,
String exText,
int... iPaths) {
ZDocNode nd2 = nd.node(iPaths);
Object exMap = Json.fromJson(exAttrs);
Object attMap = Json.fromJson(Json.toJson(nd2.attrs().getInnerMap()));
assertEquals(exType, nd2.type());
assertEquals(exChildCount, nd2.children().size());
assertTrue(Lang.equals(exMap, attMap));
assertEquals(exText, nd2.text());
}
protected void _CE(ZDocNode nd,
int index,
ZDocEleType exType,
String exAttrs,
String exText,
int... iPaths) {
ZDocEle ele = nd.eles().get(index).ele(iPaths);
Object exMap = Json.fromJson(exAttrs);
Object attMap = Json.fromJson(ele.attrsAsJson());
assertEquals(exType, ele.type());
assertTrue(Lang.equals(exMap, attMap));
assertEquals(exText, ele.text());
}
| protected abstract AmFactory genAmFactory(); |
zozoh/zdoc | java/src/org/nutz/zdoc/ZLine.java | // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
| import static org.nutz.zdoc.ZLineType.*;
import org.nutz.lang.Strings; | package org.nutz.zdoc;
public class ZLine {
public String origin;
private String text;
public int indent;
public int blockLevel;
| // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
// Path: java/src/org/nutz/zdoc/ZLine.java
import static org.nutz.zdoc.ZLineType.*;
import org.nutz.lang.Strings;
package org.nutz.zdoc;
public class ZLine {
public String origin;
private String text;
public int indent;
public int blockLevel;
| public ZLineType type; |
zozoh/zdoc | java/src/org/nutz/zdoc/ZDocEle.java | // Path: java/src/org/nutz/css/CssRule.java
// public class CssRule extends SimpleContext {}
| import java.util.LinkedList;
import java.util.List;
import org.nutz.css.CssRule;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings; |
public ZDocEle title(String title) {
return attr("title", title);
}
public int width() {
return attrInt("width");
}
public ZDocEle width(int width) {
return attr("width", width);
}
public int height() {
return attrInt("height");
}
public ZDocEle height(int height) {
return attr("height", height);
}
public String text() {
return text;
}
public ZDocEle text(String text) {
this.text = text;
return this;
}
| // Path: java/src/org/nutz/css/CssRule.java
// public class CssRule extends SimpleContext {}
// Path: java/src/org/nutz/zdoc/ZDocEle.java
import java.util.LinkedList;
import java.util.List;
import org.nutz.css.CssRule;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
public ZDocEle title(String title) {
return attr("title", title);
}
public int width() {
return attrInt("width");
}
public ZDocEle width(int width) {
return attr("width", width);
}
public int height() {
return attrInt("height");
}
public ZDocEle height(int height) {
return attr("height", height);
}
public String text() {
return text;
}
public ZDocEle text(String text) {
this.text = text;
return this;
}
| public CssRule style() { |
zozoh/zdoc | java/test/org/nutz/zdoc/impl/MdScannerTest.java | // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
//
// Path: java/src/org/nutz/zdoc/Parsing.java
// public class Parsing {
//
// public BufferedReader reader;
//
// public List<ZBlock> blocks;
//
// public int depth;
//
// public ZDocNode root;
//
// public ZDocNode current;
//
// public AmFactory fa;
//
// public String rootAmName;
//
// public ZDocAmStack stack;
//
// public StringBuilder raw;
//
// /**
// * 供扫描器使用的,说明现在文档正在处于的层别,默认为 0
// * <p>
// * 比如对于 Markdown 之类的依靠缩进来判断代码段
// */
// public int scanLevel;
//
// public Parsing(Reader reader) {
// this.reader = Streams.buffr(reader);
// this.root = new ZDocNode();
// this.current = root;
// this.blocks = new ArrayList<ZBlock>();
// this.stack = new ZDocAmStack(10);
// this.raw = new StringBuilder();
// }
//
// /**
// * 根据一段字符串填充当前的节点
// *
// * @param str
// * 字符串
// * @return 自身
// *
// * @see #fillEles(ZDocNode, String)
// */
// public ZDocNode fillCurrentEles(String str) {
// return fillEles(current, str);
// }
//
// /**
// * 根据一段字符串填充节点
// *
// * @param nd
// * 节点
// * @param str
// * 字符串
// * @return 自身
// */
// public ZDocNode fillEles(ZDocNode nd, String str) {
// ZDocEle ele = parseString(str);
// // 这种情况需要仅仅加入所有的子 ...
// if (ele.isWrapper()) {
// nd.addEles(ele.children());
// }
// // 加入自己就成
// else {
// nd.addEle(ele);
// }
// return nd;
// }
//
// /**
// * 从一个字符串中解析出一个 ZDocEle 对象
// *
// * @param str
// * 字符串对象
// * @return 节点内容元素对象
// */
// public ZDocEle parseString(String str) {
// char[] cs = str.toCharArray();
// Am<ZDocEle> am = fa.getAm(ZDocParallelAm.class, rootAmName);
// // 准备堆栈
// AmStack<ZDocEle> stack = this.stack.born();
// stack.pushObj(stack.bornObj());
// // 用第一个字符测试...
// if (am.enter(stack, cs[0]) != AmStatus.CONTINUE) {
// throw Lang.impossible();
// }
// // 循环每个字符
// for (int i = 1; i < cs.length; i++) {
// char c = cs[i];
// AmStatus st = stack.eat(c);
// if (AmStatus.CONTINUE != st)
// throw Lang.makeThrow("Fail to parse :\n%s", str);
// }
// // 关闭堆栈得到对象
// return stack.close();
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.nutz.zdoc.ZLineType.*;
import org.junit.Before;
import org.junit.Test;
import org.nutz.zdoc.Parsing; | package org.nutz.zdoc.impl;
public class MdScannerTest extends AbstractScannerTest {
@Before
public void before() {
scanner = new MdScanner();
}
@Test
public void test_link_define() {
String s = "[a0]: http://nutzam.com 'Nutz'\n";
s += "ABC\n";
s += "[a1]: http://www.google.com 'Google'\n";
// ............................................. | // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
//
// Path: java/src/org/nutz/zdoc/Parsing.java
// public class Parsing {
//
// public BufferedReader reader;
//
// public List<ZBlock> blocks;
//
// public int depth;
//
// public ZDocNode root;
//
// public ZDocNode current;
//
// public AmFactory fa;
//
// public String rootAmName;
//
// public ZDocAmStack stack;
//
// public StringBuilder raw;
//
// /**
// * 供扫描器使用的,说明现在文档正在处于的层别,默认为 0
// * <p>
// * 比如对于 Markdown 之类的依靠缩进来判断代码段
// */
// public int scanLevel;
//
// public Parsing(Reader reader) {
// this.reader = Streams.buffr(reader);
// this.root = new ZDocNode();
// this.current = root;
// this.blocks = new ArrayList<ZBlock>();
// this.stack = new ZDocAmStack(10);
// this.raw = new StringBuilder();
// }
//
// /**
// * 根据一段字符串填充当前的节点
// *
// * @param str
// * 字符串
// * @return 自身
// *
// * @see #fillEles(ZDocNode, String)
// */
// public ZDocNode fillCurrentEles(String str) {
// return fillEles(current, str);
// }
//
// /**
// * 根据一段字符串填充节点
// *
// * @param nd
// * 节点
// * @param str
// * 字符串
// * @return 自身
// */
// public ZDocNode fillEles(ZDocNode nd, String str) {
// ZDocEle ele = parseString(str);
// // 这种情况需要仅仅加入所有的子 ...
// if (ele.isWrapper()) {
// nd.addEles(ele.children());
// }
// // 加入自己就成
// else {
// nd.addEle(ele);
// }
// return nd;
// }
//
// /**
// * 从一个字符串中解析出一个 ZDocEle 对象
// *
// * @param str
// * 字符串对象
// * @return 节点内容元素对象
// */
// public ZDocEle parseString(String str) {
// char[] cs = str.toCharArray();
// Am<ZDocEle> am = fa.getAm(ZDocParallelAm.class, rootAmName);
// // 准备堆栈
// AmStack<ZDocEle> stack = this.stack.born();
// stack.pushObj(stack.bornObj());
// // 用第一个字符测试...
// if (am.enter(stack, cs[0]) != AmStatus.CONTINUE) {
// throw Lang.impossible();
// }
// // 循环每个字符
// for (int i = 1; i < cs.length; i++) {
// char c = cs[i];
// AmStatus st = stack.eat(c);
// if (AmStatus.CONTINUE != st)
// throw Lang.makeThrow("Fail to parse :\n%s", str);
// }
// // 关闭堆栈得到对象
// return stack.close();
// }
//
// }
// Path: java/test/org/nutz/zdoc/impl/MdScannerTest.java
import static org.junit.Assert.assertEquals;
import static org.nutz.zdoc.ZLineType.*;
import org.junit.Before;
import org.junit.Test;
import org.nutz.zdoc.Parsing;
package org.nutz.zdoc.impl;
public class MdScannerTest extends AbstractScannerTest {
@Before
public void before() {
scanner = new MdScanner();
}
@Test
public void test_link_define() {
String s = "[a0]: http://nutzam.com 'Nutz'\n";
s += "ABC\n";
s += "[a1]: http://www.google.com 'Google'\n";
// ............................................. | Parsing ing = scan(s); |
zozoh/zdoc | java/src/org/nutz/zdoc/impl/md/RenderToMarkdown.java | // Path: java/src/org/nutz/zdoc/RenderTo.java
// public abstract class RenderTo extends ZDocHome {
//
// public RenderTo(ZIO io) {
// super(io);
// }
//
// /**
// * 渲染整个 ZDoc 集合
// *
// * @param ing
// * 渲染时上下文
// */
// public abstract void render(Rendering ing);
//
// protected ZDir dest;
//
// public ZDir dest() {
// return dest;
// }
//
// public RenderTo dest(ZDir dest) {
// this.dest = dest;
// return this;
// }
//
// }
//
// Path: java/src/org/nutz/zdoc/Rendering.java
// public class Rendering {
//
// public int charCount;
//
// public int limit;
//
// public String currentBasePath;
//
// public Map<String, ZFile> medias;
//
// public boolean isOutOfLimit() {
// if (limit <= 0)
// return false;
// return charCount > limit;
// }
//
// public boolean hasLimit() {
// return limit > 0;
// }
//
// /**
// * 读写接口
// */
// private ZIO io;
//
// /**
// * 模板工厂
// */
// private ZDocTemplateFactory tfa;
//
// /**
// * 当前正在工作的上下文
// */
// private NutMap context;
//
// public Rendering(ZIO io, ZDocTemplateFactory tfa) {
// this.io = io;
// this.tfa = tfa;
// this.context = new NutMap();
// this.medias = new LinkedHashMap<String, ZFile>();
// }
//
// public ZIO io() {
// return io;
// }
//
// public ZDocTemplateFactory tfa() {
// return tfa;
// }
//
// public NutMap context() {
// return context;
// }
//
// }
| import org.nutz.vfs.ZIO;
import org.nutz.zdoc.RenderTo;
import org.nutz.zdoc.Rendering; | package org.nutz.zdoc.impl.md;
public class RenderToMarkdown extends RenderTo {
public RenderToMarkdown(ZIO io) {
super(io);
}
@Override | // Path: java/src/org/nutz/zdoc/RenderTo.java
// public abstract class RenderTo extends ZDocHome {
//
// public RenderTo(ZIO io) {
// super(io);
// }
//
// /**
// * 渲染整个 ZDoc 集合
// *
// * @param ing
// * 渲染时上下文
// */
// public abstract void render(Rendering ing);
//
// protected ZDir dest;
//
// public ZDir dest() {
// return dest;
// }
//
// public RenderTo dest(ZDir dest) {
// this.dest = dest;
// return this;
// }
//
// }
//
// Path: java/src/org/nutz/zdoc/Rendering.java
// public class Rendering {
//
// public int charCount;
//
// public int limit;
//
// public String currentBasePath;
//
// public Map<String, ZFile> medias;
//
// public boolean isOutOfLimit() {
// if (limit <= 0)
// return false;
// return charCount > limit;
// }
//
// public boolean hasLimit() {
// return limit > 0;
// }
//
// /**
// * 读写接口
// */
// private ZIO io;
//
// /**
// * 模板工厂
// */
// private ZDocTemplateFactory tfa;
//
// /**
// * 当前正在工作的上下文
// */
// private NutMap context;
//
// public Rendering(ZIO io, ZDocTemplateFactory tfa) {
// this.io = io;
// this.tfa = tfa;
// this.context = new NutMap();
// this.medias = new LinkedHashMap<String, ZFile>();
// }
//
// public ZIO io() {
// return io;
// }
//
// public ZDocTemplateFactory tfa() {
// return tfa;
// }
//
// public NutMap context() {
// return context;
// }
//
// }
// Path: java/src/org/nutz/zdoc/impl/md/RenderToMarkdown.java
import org.nutz.vfs.ZIO;
import org.nutz.zdoc.RenderTo;
import org.nutz.zdoc.Rendering;
package org.nutz.zdoc.impl.md;
public class RenderToMarkdown extends RenderTo {
public RenderToMarkdown(ZIO io) {
super(io);
}
@Override | public void render(Rendering ing) {} |
zozoh/zdoc | java/test/org/nutz/zdoc/impl/ZDocScannerTest.java | // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
//
// Path: java/src/org/nutz/zdoc/Parsing.java
// public class Parsing {
//
// public BufferedReader reader;
//
// public List<ZBlock> blocks;
//
// public int depth;
//
// public ZDocNode root;
//
// public ZDocNode current;
//
// public AmFactory fa;
//
// public String rootAmName;
//
// public ZDocAmStack stack;
//
// public StringBuilder raw;
//
// /**
// * 供扫描器使用的,说明现在文档正在处于的层别,默认为 0
// * <p>
// * 比如对于 Markdown 之类的依靠缩进来判断代码段
// */
// public int scanLevel;
//
// public Parsing(Reader reader) {
// this.reader = Streams.buffr(reader);
// this.root = new ZDocNode();
// this.current = root;
// this.blocks = new ArrayList<ZBlock>();
// this.stack = new ZDocAmStack(10);
// this.raw = new StringBuilder();
// }
//
// /**
// * 根据一段字符串填充当前的节点
// *
// * @param str
// * 字符串
// * @return 自身
// *
// * @see #fillEles(ZDocNode, String)
// */
// public ZDocNode fillCurrentEles(String str) {
// return fillEles(current, str);
// }
//
// /**
// * 根据一段字符串填充节点
// *
// * @param nd
// * 节点
// * @param str
// * 字符串
// * @return 自身
// */
// public ZDocNode fillEles(ZDocNode nd, String str) {
// ZDocEle ele = parseString(str);
// // 这种情况需要仅仅加入所有的子 ...
// if (ele.isWrapper()) {
// nd.addEles(ele.children());
// }
// // 加入自己就成
// else {
// nd.addEle(ele);
// }
// return nd;
// }
//
// /**
// * 从一个字符串中解析出一个 ZDocEle 对象
// *
// * @param str
// * 字符串对象
// * @return 节点内容元素对象
// */
// public ZDocEle parseString(String str) {
// char[] cs = str.toCharArray();
// Am<ZDocEle> am = fa.getAm(ZDocParallelAm.class, rootAmName);
// // 准备堆栈
// AmStack<ZDocEle> stack = this.stack.born();
// stack.pushObj(stack.bornObj());
// // 用第一个字符测试...
// if (am.enter(stack, cs[0]) != AmStatus.CONTINUE) {
// throw Lang.impossible();
// }
// // 循环每个字符
// for (int i = 1; i < cs.length; i++) {
// char c = cs[i];
// AmStatus st = stack.eat(c);
// if (AmStatus.CONTINUE != st)
// throw Lang.makeThrow("Fail to parse :\n%s", str);
// }
// // 关闭堆栈得到对象
// return stack.close();
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.nutz.zdoc.ZLineType.*;
import org.junit.Before;
import org.junit.Test;
import org.nutz.zdoc.Parsing; | package org.nutz.zdoc.impl;
public class ZDocScannerTest extends AbstractScannerTest {
@Before
public void before() {
scanner = new ZDocScanner();
}
@Test
public void test_simple_table() {
String s = "AAAAAAA\n";
s += " || H1 || H2 ||\n";
s += " || --- || --- ||\n";
s += " || C11 || C12 ||\n";
s += " || C21 || C22 ||\n";
s += " \n";
s += " XYZ";
| // Path: java/src/org/nutz/zdoc/ZLineType.java
// public enum ZLineType {
//
// // LIST
// UL, OL,
//
// // 特殊块
// TABLE, HTML, CODE, COMMENT,
//
// // HR
// HR,
//
// // 段落&标题
// PARAGRAPH, BLOCKQUOTE, HEADER,
//
// // 空行
// BLANK
//
// }
//
// Path: java/src/org/nutz/zdoc/Parsing.java
// public class Parsing {
//
// public BufferedReader reader;
//
// public List<ZBlock> blocks;
//
// public int depth;
//
// public ZDocNode root;
//
// public ZDocNode current;
//
// public AmFactory fa;
//
// public String rootAmName;
//
// public ZDocAmStack stack;
//
// public StringBuilder raw;
//
// /**
// * 供扫描器使用的,说明现在文档正在处于的层别,默认为 0
// * <p>
// * 比如对于 Markdown 之类的依靠缩进来判断代码段
// */
// public int scanLevel;
//
// public Parsing(Reader reader) {
// this.reader = Streams.buffr(reader);
// this.root = new ZDocNode();
// this.current = root;
// this.blocks = new ArrayList<ZBlock>();
// this.stack = new ZDocAmStack(10);
// this.raw = new StringBuilder();
// }
//
// /**
// * 根据一段字符串填充当前的节点
// *
// * @param str
// * 字符串
// * @return 自身
// *
// * @see #fillEles(ZDocNode, String)
// */
// public ZDocNode fillCurrentEles(String str) {
// return fillEles(current, str);
// }
//
// /**
// * 根据一段字符串填充节点
// *
// * @param nd
// * 节点
// * @param str
// * 字符串
// * @return 自身
// */
// public ZDocNode fillEles(ZDocNode nd, String str) {
// ZDocEle ele = parseString(str);
// // 这种情况需要仅仅加入所有的子 ...
// if (ele.isWrapper()) {
// nd.addEles(ele.children());
// }
// // 加入自己就成
// else {
// nd.addEle(ele);
// }
// return nd;
// }
//
// /**
// * 从一个字符串中解析出一个 ZDocEle 对象
// *
// * @param str
// * 字符串对象
// * @return 节点内容元素对象
// */
// public ZDocEle parseString(String str) {
// char[] cs = str.toCharArray();
// Am<ZDocEle> am = fa.getAm(ZDocParallelAm.class, rootAmName);
// // 准备堆栈
// AmStack<ZDocEle> stack = this.stack.born();
// stack.pushObj(stack.bornObj());
// // 用第一个字符测试...
// if (am.enter(stack, cs[0]) != AmStatus.CONTINUE) {
// throw Lang.impossible();
// }
// // 循环每个字符
// for (int i = 1; i < cs.length; i++) {
// char c = cs[i];
// AmStatus st = stack.eat(c);
// if (AmStatus.CONTINUE != st)
// throw Lang.makeThrow("Fail to parse :\n%s", str);
// }
// // 关闭堆栈得到对象
// return stack.close();
// }
//
// }
// Path: java/test/org/nutz/zdoc/impl/ZDocScannerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.nutz.zdoc.ZLineType.*;
import org.junit.Before;
import org.junit.Test;
import org.nutz.zdoc.Parsing;
package org.nutz.zdoc.impl;
public class ZDocScannerTest extends AbstractScannerTest {
@Before
public void before() {
scanner = new ZDocScanner();
}
@Test
public void test_simple_table() {
String s = "AAAAAAA\n";
s += " || H1 || H2 ||\n";
s += " || --- || --- ||\n";
s += " || C11 || C12 ||\n";
s += " || C21 || C22 ||\n";
s += " \n";
s += " XYZ";
| Parsing ing = scan(s); |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/Parameters.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/storage/PermanentStorage.java
// public interface PermanentStorage {
// /**
// * Returns the training model of the current classifier object from
// * the permanent storage
// * @param fileName Name of the file that was used to store the model
// * @return returns the training model as an Object file
// * @throws FileNotFoundException
// * @throws IOException
// * @throws ClassNotFoundException
// */
// public Object retrieveModel(String fileName)
// throws FileNotFoundException, IOException, ClassNotFoundException;
//
// /**
// * Saves the training model 'model' of the classifier to the permanent
// * storage
// * @param fileName Name of the file that will store the model
// * @param model Model that should be stored in the permanent storage
// * @throws FileNotFoundException
// * @throws IOException
// */
// public boolean saveModel(String fileName, Object model)
// throws FileNotFoundException, IOException;
//
// /**
// * Writes deflated {@code FeatureVector} {@code strFV} in {@code fileName}
// * and inserts a newline
// * @param fileName
// * @param strFV
// * @throws IOException
// */
// public void log(String fileName, String strFV) throws IOException;
// }
| import ca.uwaterloo.crysp.itus.storage.PermanentStorage; | /*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* Various parameters used by Itus. These are default values only.
* Prefabs may overwrite them by calling setParam()
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class Parameters {
/**
* Current operation mode
*/
private static Mode mode = Mode.ONLINE_MODE;
/**
* How often we invoke the Itus train/classify loop, in ms
*/
private static long itusPeriod = 5000;
/**
* minimum number of instances required before training kicks in
* note: this is a minimum -- training might be invoked with more
* instances than this
*/
private static int trainingThreshold = 8;
/**
* Used to pause/resume the Itus thread after it has been launched.
*/
private static State itusState = State.STOPPED;
/**
* History size of past scores
*/
private static int scoreHistorySize = 10;
/**
* The default filename for the touch log file
*/
private static final String touchLogFileName = "itus_touch_data_";
/**
* Name of the model file
*/
private static String modelFileName = "itus_classifier_model_file";
| // Path: Itus/src/ca/uwaterloo/crysp/itus/storage/PermanentStorage.java
// public interface PermanentStorage {
// /**
// * Returns the training model of the current classifier object from
// * the permanent storage
// * @param fileName Name of the file that was used to store the model
// * @return returns the training model as an Object file
// * @throws FileNotFoundException
// * @throws IOException
// * @throws ClassNotFoundException
// */
// public Object retrieveModel(String fileName)
// throws FileNotFoundException, IOException, ClassNotFoundException;
//
// /**
// * Saves the training model 'model' of the classifier to the permanent
// * storage
// * @param fileName Name of the file that will store the model
// * @param model Model that should be stored in the permanent storage
// * @throws FileNotFoundException
// * @throws IOException
// */
// public boolean saveModel(String fileName, Object model)
// throws FileNotFoundException, IOException;
//
// /**
// * Writes deflated {@code FeatureVector} {@code strFV} in {@code fileName}
// * and inserts a newline
// * @param fileName
// * @param strFV
// * @throws IOException
// */
// public void log(String fileName, String strFV) throws IOException;
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/Parameters.java
import ca.uwaterloo.crysp.itus.storage.PermanentStorage;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* Various parameters used by Itus. These are default values only.
* Prefabs may overwrite them by calling setParam()
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class Parameters {
/**
* Current operation mode
*/
private static Mode mode = Mode.ONLINE_MODE;
/**
* How often we invoke the Itus train/classify loop, in ms
*/
private static long itusPeriod = 5000;
/**
* minimum number of instances required before training kicks in
* note: this is a minimum -- training might be invoked with more
* instances than this
*/
private static int trainingThreshold = 8;
/**
* Used to pause/resume the Itus thread after it has been launched.
*/
private static State itusState = State.STOPPED;
/**
* History size of past scores
*/
private static int scoreHistorySize = 10;
/**
* The default filename for the touch log file
*/
private static final String touchLogFileName = "itus_touch_data_";
/**
* Name of the model file
*/
private static String modelFileName = "itus_classifier_model_file";
| private static PermanentStorage permanentStorageInstance = null; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/FeatureVectorTest.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/ClassLabel.java
// @SuppressWarnings("serial")
// public class ClassLabel implements java.io.Serializable {
// /**
// * Integer label for the class
// */
// private final int value;
//
// private ClassLabel(int value) {
// this.value = value;
// }
// /**
// * Get the integer value for this label
// * @return
// */
// public int getClassLabel() {
// return this.value;
// }
//
// /**
// * Get the integer value for this label
// * @return
// */
// public static ClassLabel getClassLabel(int intValue) {
// if (intValue == POSITIVE.value)
// return POSITIVE;
// else if (intValue == NEGATIVE.value)
// return NEGATIVE;
// return UNKNOWN;
// }
// /**
// * The positive sample
// */
// public static final ClassLabel POSITIVE = new ClassLabel(1);
//
// /**
// * The negative sample
// */
// public static final ClassLabel NEGATIVE = new ClassLabel(-1);
//
// /**
// * The unknown sample
// */
// public static final ClassLabel UNKNOWN = new ClassLabel(0);
// }
| import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.machinelearning.ClassLabel; | /*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* Testclass for the FeatureVector
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class FeatureVectorTest {
int size = 10;
double [] fv; | // Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/ClassLabel.java
// @SuppressWarnings("serial")
// public class ClassLabel implements java.io.Serializable {
// /**
// * Integer label for the class
// */
// private final int value;
//
// private ClassLabel(int value) {
// this.value = value;
// }
// /**
// * Get the integer value for this label
// * @return
// */
// public int getClassLabel() {
// return this.value;
// }
//
// /**
// * Get the integer value for this label
// * @return
// */
// public static ClassLabel getClassLabel(int intValue) {
// if (intValue == POSITIVE.value)
// return POSITIVE;
// else if (intValue == NEGATIVE.value)
// return NEGATIVE;
// return UNKNOWN;
// }
// /**
// * The positive sample
// */
// public static final ClassLabel POSITIVE = new ClassLabel(1);
//
// /**
// * The negative sample
// */
// public static final ClassLabel NEGATIVE = new ClassLabel(-1);
//
// /**
// * The unknown sample
// */
// public static final ClassLabel UNKNOWN = new ClassLabel(0);
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVectorTest.java
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.machinelearning.ClassLabel;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* Testclass for the FeatureVector
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class FeatureVectorTest {
int size = 10;
double [] fv; | ClassLabel label; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifierTest.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
//
// Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifier.java
// public static class ComputedDistance {
// /**
// * Label of the class
// */
// int label;
//
// /**
// * Distance from the sample that is being evaluated
// */
// double distance;
// /**
// * Constructor for ComputedDistance
// * @param label
// * @param distance
// */
// public ComputedDistance(int label, double distance) {
// this.label = label;
// this.distance = distance;
// }
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.FeatureVector;
import ca.uwaterloo.crysp.itus.machinelearning.KNNClassifier.ComputedDistance; | package ca.uwaterloo.crysp.itus.machinelearning;
public class KNNClassifierTest {
private KNNClassifier knnClassifier;
int size, k, numFeatures;
double [] fv;
ClassLabel label; | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
//
// Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifier.java
// public static class ComputedDistance {
// /**
// * Label of the class
// */
// int label;
//
// /**
// * Distance from the sample that is being evaluated
// */
// double distance;
// /**
// * Constructor for ComputedDistance
// * @param label
// * @param distance
// */
// public ComputedDistance(int label, double distance) {
// this.label = label;
// this.distance = distance;
// }
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifierTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.FeatureVector;
import ca.uwaterloo.crysp.itus.machinelearning.KNNClassifier.ComputedDistance;
package ca.uwaterloo.crysp.itus.machinelearning;
public class KNNClassifierTest {
private KNNClassifier knnClassifier;
int size, k, numFeatures;
double [] fv;
ClassLabel label; | ArrayList<FeatureVector> data; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/measurements/Measurement.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import ca.uwaterloo.crysp.itus.FeatureVector; | /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus.measurements;
/**
* Measurement class that can be extended by different data sources to convert
* raw measurements to FeatureVectors
* @author Aaron Atwater
* @author Hassan Khan
*
*/
public abstract class Measurement {
/**
* The subset of Features supported by this measurement
*/
public static HashMap<Class<?>, ArrayList<Boolean>> employedFeatures =
new HashMap<Class<?>, ArrayList<Boolean>>();
/**
* Features name-index mapping
*/
public static HashMap<Class<?>, HashMap<String,Integer>> featureIndexMap =
new HashMap<Class<?>, HashMap<String,Integer>>();
/**
* FeatureVector to store the converted features
*/ | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/measurements/Measurement.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import ca.uwaterloo.crysp.itus.FeatureVector;
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus.measurements;
/**
* Measurement class that can be extended by different data sources to convert
* raw measurements to FeatureVectors
* @author Aaron Atwater
* @author Hassan Khan
*
*/
public abstract class Measurement {
/**
* The subset of Features supported by this measurement
*/
public static HashMap<Class<?>, ArrayList<Boolean>> employedFeatures =
new HashMap<Class<?>, ArrayList<Boolean>>();
/**
* Features name-index mapping
*/
public static HashMap<Class<?>, HashMap<String,Integer>> featureIndexMap =
new HashMap<Class<?>, HashMap<String,Integer>>();
/**
* FeatureVector to store the converted features
*/ | protected FeatureVector fv; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/machinelearning/SVMClassifierTest.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
| import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.FeatureVector; | package ca.uwaterloo.crysp.itus.machinelearning;
public class SVMClassifierTest {
private SVMClassifier svmClassifier;
int size, numFeatures;
double [] fv;
ClassLabel label; | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/SVMClassifierTest.java
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import ca.uwaterloo.crysp.itus.FeatureVector;
package ca.uwaterloo.crysp.itus.machinelearning;
public class SVMClassifierTest {
private SVMClassifier svmClassifier;
int size, numFeatures;
double [] fv;
ClassLabel label; | ArrayList<FeatureVector> data; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/ClassLabel.java
// @SuppressWarnings("serial")
// public class ClassLabel implements java.io.Serializable {
// /**
// * Integer label for the class
// */
// private final int value;
//
// private ClassLabel(int value) {
// this.value = value;
// }
// /**
// * Get the integer value for this label
// * @return
// */
// public int getClassLabel() {
// return this.value;
// }
//
// /**
// * Get the integer value for this label
// * @return
// */
// public static ClassLabel getClassLabel(int intValue) {
// if (intValue == POSITIVE.value)
// return POSITIVE;
// else if (intValue == NEGATIVE.value)
// return NEGATIVE;
// return UNKNOWN;
// }
// /**
// * The positive sample
// */
// public static final ClassLabel POSITIVE = new ClassLabel(1);
//
// /**
// * The negative sample
// */
// public static final ClassLabel NEGATIVE = new ClassLabel(-1);
//
// /**
// * The unknown sample
// */
// public static final ClassLabel UNKNOWN = new ClassLabel(0);
// }
| import java.util.Arrays;
import ca.uwaterloo.crysp.itus.machinelearning.ClassLabel; | /*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* FeatureVector is consumed by the {@code Classifier}
*
* @author Aaron Atwater
* @author Hassan Khan
*/
@SuppressWarnings("serial")
public class FeatureVector implements java.io.Serializable {
/**
* An array to store the features.
* and 1 for positive)
*/
protected double[] features;
/**
* Label of the class i.e. positive instance or negative instance
*
*/ | // Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/ClassLabel.java
// @SuppressWarnings("serial")
// public class ClassLabel implements java.io.Serializable {
// /**
// * Integer label for the class
// */
// private final int value;
//
// private ClassLabel(int value) {
// this.value = value;
// }
// /**
// * Get the integer value for this label
// * @return
// */
// public int getClassLabel() {
// return this.value;
// }
//
// /**
// * Get the integer value for this label
// * @return
// */
// public static ClassLabel getClassLabel(int intValue) {
// if (intValue == POSITIVE.value)
// return POSITIVE;
// else if (intValue == NEGATIVE.value)
// return NEGATIVE;
// return UNKNOWN;
// }
// /**
// * The positive sample
// */
// public static final ClassLabel POSITIVE = new ClassLabel(1);
//
// /**
// * The negative sample
// */
// public static final ClassLabel NEGATIVE = new ClassLabel(-1);
//
// /**
// * The unknown sample
// */
// public static final ClassLabel UNKNOWN = new ClassLabel(0);
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
import java.util.Arrays;
import ca.uwaterloo.crysp.itus.machinelearning.ClassLabel;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus;
/**
* FeatureVector is consumed by the {@code Classifier}
*
* @author Aaron Atwater
* @author Hassan Khan
*/
@SuppressWarnings("serial")
public class FeatureVector implements java.io.Serializable {
/**
* An array to store the features.
* and 1 for positive)
*/
protected double[] features;
/**
* Label of the class i.e. positive instance or negative instance
*
*/ | private ClassLabel classLabel; |
hassan-khan/itus | Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifier.java | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ca.uwaterloo.crysp.itus.FeatureVector; | /*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus.machinelearning;
/**
* An implementation of kNN Classifier (Assumes two classes only)
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class KNNClassifier extends Classifier {
/**
* Model for the KNN Classifier
*
* @author Aaron Atwater
* @author Hassan Khan
*/
@SuppressWarnings("serial")
public class KNNModel implements java.io.Serializable {
/**
* A reference to training and testing instances
*/ | // Path: Itus/src/ca/uwaterloo/crysp/itus/FeatureVector.java
// @SuppressWarnings("serial")
// public class FeatureVector implements java.io.Serializable {
// /**
// * An array to store the features.
// * and 1 for positive)
// */
// protected double[] features;
//
// /**
// * Label of the class i.e. positive instance or negative instance
// *
// */
// private ClassLabel classLabel;
//
// /**
// * Copy constructor for FeatureVector class
// * @param _fv Uses this FeatureVector to generate a copy constructor
// */
// public FeatureVector(FeatureVector _fv) {
// this.features = new double[_fv.features.length];
// for(int i = 0; i <_fv.features.length; i++)
// set(i, _fv.get(i));
// this.classLabel = _fv.classLabel;
// }
//
// /**
// * Constructs FeatureVector with a capacity of numFeatures features
// * @param numFeatures Capacity of the FeatureVector including class label
// */
// public FeatureVector(int numFeatures) throws IllegalArgumentException {
// if (numFeatures < 1)
// throw new IllegalArgumentException("numFeatures cannot be <= 0");
// this.features = new double[numFeatures];
// }
//
//
// /**
// * Creates a FeatureVector using the feature values in {@code vals} &
// * {@code classlabel} in '_classlabel'
// * @param vals double array containing the feature score and class at index 0
// * @param _classLabel class Label of the FeatureVector
// */
// public FeatureVector(double [] vals, ClassLabel _classLabel) {
// this.features = new double[vals.length];
// for (int i = 0; i < vals.length; i++)
// this.set(i, vals[i]);
// this.classLabel = _classLabel;
// }
//
// /**
// * Returns size of the FeatureVector
// * @return size of the FeatureVector
// */
// public int size() {
// return this.features.length;
// }
//
// /**
// * Returns class label of this FeatureVector
// * @return Class Label of this FeatureVector
// */
// public ClassLabel getClassLabel() {
// return classLabel;
// }
//
// /**
// * Returns Integer value of class label of this FeatureVector
// * @return Integer value of Class Label of this FeatureVector
// */
// public int getIntClassLabel() {
// return classLabel.getClassLabel();
// }
// /**
// * Sets class label of this FeatureVector
// * @param classLabel class label to set
// */
// public void setClassLabel(ClassLabel classLabel) {
// this.classLabel = classLabel;
// }
//
// /**
// * Sets the value at a particular index of the FeatureVector
// * @param index Index of the FeatureVector to modify
// * @param value New value to set at the index
// */
// public void set(int index, double value)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// features[index] = value;
// }
//
// /**
// * Get the value of the feature at a specific index.
// *
// * @param index index of the attribute to return
// * @return the value of the feature at <tt>index</tt>
// */
// public double get(int index)
// throws ArrayIndexOutOfBoundsException {
// if (index < 0 || index >= features.length)
// throw new ArrayIndexOutOfBoundsException(String.valueOf(index) +
// " out of bounds for FeatureVector with size "+ this.size());
// return features[index];
// }
//
// /**
// * Gets the feature score at the index 'index'; if no value exists, returns
// * the default '_default'
// * @param index index of the FeatureVector to get the feature score from
// * @param _default default value to return if sparse array index is not
// * populated
// * @return returns the feature score if index exists or default otherwise
// */
// public double get(int index, double _default) {
// if (index < 0 || index >= features.length)
// return _default;
// return features[index];
// }
// /**
// * Get the feature values as an array
// *
// * @return a double array containing a *copy* of all feature values
// */
// public double[] getAll() {
// return Arrays.copyOf(features, features.length);
// }
//
// /**
// * Reset all feature values to zero.
// */
// public void clear() {
// for (int i=0; i<features.length; i++)
// features[i] = 0;
// }
// }
// Path: Itus/src/ca/uwaterloo/crysp/itus/machinelearning/KNNClassifier.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ca.uwaterloo.crysp.itus.FeatureVector;
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.uwaterloo.crysp.itus.machinelearning;
/**
* An implementation of kNN Classifier (Assumes two classes only)
*
* @author Aaron Atwater
* @author Hassan Khan
*/
public class KNNClassifier extends Classifier {
/**
* Model for the KNN Classifier
*
* @author Aaron Atwater
* @author Hassan Khan
*/
@SuppressWarnings("serial")
public class KNNModel implements java.io.Serializable {
/**
* A reference to training and testing instances
*/ | public List<FeatureVector> data; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.dimmer.builder;
/**
* @author Koen Serneels
*/
public class DimmerBuilder {
private static final Logger logger = LoggerFactory.getLogger(DimmerBuilder.class);
| // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.dimmer.builder;
/**
* @author Koen Serneels
*/
public class DimmerBuilder {
private static final Logger logger = LoggerFactory.getLogger(DimmerBuilder.class);
| private LocationId name; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList; |
/**
* The logical name of this dimmers instance. This is just an identifier for naming thread groups and debugging purposes
*/
public DimmerBuilder name(LocationId name) {
this.name = name;
return this;
}
/**
* The address of the module to which the analog in of the dimmers is connected
*/
public DimmerBuilder boardAddress(int boardAddress) {
this.boardAddress = boardAddress;
return this;
}
/**
* The specific channel of the RPI DAC extension board to which the analog in of the dimmers is connected
*/
public DimmerBuilder boardChannel(int channel) {
this.channel = channel;
return this;
}
/**
* When the dim value is > 0% this dimmers instance will need to turn on the LED driver. This is done by toggling a KNX actor. Likewise, when the dim value is at 0%,
* the LED driver needs to be turned off again. Add the KNX GA's here that operate the actor(s) if applicable
*/
public DimmerBuilder outputGroupAddressesForActorSwitchingOnAndOff(String... groupAddresses) { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList;
/**
* The logical name of this dimmers instance. This is just an identifier for naming thread groups and debugging purposes
*/
public DimmerBuilder name(LocationId name) {
this.name = name;
return this;
}
/**
* The address of the module to which the analog in of the dimmers is connected
*/
public DimmerBuilder boardAddress(int boardAddress) {
this.boardAddress = boardAddress;
return this;
}
/**
* The specific channel of the RPI DAC extension board to which the analog in of the dimmers is connected
*/
public DimmerBuilder boardChannel(int channel) {
this.channel = channel;
return this;
}
/**
* When the dim value is > 0% this dimmers instance will need to turn on the LED driver. This is done by toggling a KNX actor. Likewise, when the dim value is at 0%,
* the LED driver needs to be turned off again. Add the KNX GA's here that operate the actor(s) if applicable
*/
public DimmerBuilder outputGroupAddressesForActorSwitchingOnAndOff(String... groupAddresses) { | switchGroupAddresses.addAll(asList(groupAddresses).stream().map(s -> createGroupAddress(s)).collect(toList())); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList; | */
public DimmerBuilder delayBetweenDimmingSteps(int stepDelay) {
this.stepDelay = of(stepDelay);
return this;
}
public void lucidControl() {
this.dimmerBackend = LUCID_CONTROL;
}
public Dimmer build() {
try {
Dimmer dimmer = new Dimmer(name, dimmerBackend, boardAddress, channel, switchGroupAddresses, feedbackGroupAddresses, switchLedControlGroupAddresses,
switchUpdateGroupAddresses);
if (delayBeforeIncreasingDimValue.isPresent()) {
dimmer.setDelayBeforeIncreasingDimValue(delayBeforeIncreasingDimValue.get());
}
if (turnOffDelay.isPresent()) {
dimmer.setTurnOffDelay(turnOffDelay.get());
}
if (stepDelay.isPresent()) {
dimmer.setStepDelay(stepDelay.get());
}
dimmer.start();
KnxDimmerProcessListener knxDimmerProcessListener = new KnxDimmerProcessListener(onOff, onOffOverride, precenseDetectorLock, dim, dimAbsolute,
dimAbsoluteOverride, minDimVal, deactivateOnOtherUse, dimmer); | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/knx/Support.java
// public static GroupAddress createGroupAddress(String groupAddress) {
// try {
// return new GroupAddress(groupAddress);
// } catch (KNXException knxException) {
// logger.error("Could not create group address from " + groupAddress, knxException);
// throw new RuntimeException(knxException);
// }
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/DimmerBuilder.java
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.I2C;
import static be.error.rpi.dac.dimmer.builder.DimmerBackend.LUCID_CONTROL;
import static be.error.rpi.knx.Support.createGroupAddress;
import static java.util.Arrays.asList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import java.util.ArrayList;
*/
public DimmerBuilder delayBetweenDimmingSteps(int stepDelay) {
this.stepDelay = of(stepDelay);
return this;
}
public void lucidControl() {
this.dimmerBackend = LUCID_CONTROL;
}
public Dimmer build() {
try {
Dimmer dimmer = new Dimmer(name, dimmerBackend, boardAddress, channel, switchGroupAddresses, feedbackGroupAddresses, switchLedControlGroupAddresses,
switchUpdateGroupAddresses);
if (delayBeforeIncreasingDimValue.isPresent()) {
dimmer.setDelayBeforeIncreasingDimValue(delayBeforeIncreasingDimValue.get());
}
if (turnOffDelay.isPresent()) {
dimmer.setTurnOffDelay(turnOffDelay.get());
}
if (stepDelay.isPresent()) {
dimmer.setStepDelay(stepDelay.get());
}
dimmer.start();
KnxDimmerProcessListener knxDimmerProcessListener = new KnxDimmerProcessListener(onOff, onOffOverride, precenseDetectorLock, dim, dimAbsolute,
dimAbsoluteOverride, minDimVal, deactivateOnOtherUse, dimmer); | getInstance().getKnxConnectionFactory().addProcessListener(knxDimmerProcessListener); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/SetCurrentRoomTemperature.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
| import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetCurrentRoomTemperature implements EbusCommand<Void> {
private final BigDecimal temperatureControlValue;
private final BigDecimal temperatureDisplayValue;
public SetCurrentRoomTemperature(final BigDecimal temperatureControlValue, final BigDecimal temperatureDisplayValue) {
this.temperatureControlValue = temperatureControlValue;
this.temperatureDisplayValue = temperatureDisplayValue;
}
@Override
public String[] getEbusCommands() {
try { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/SetCurrentRoomTemperature.java
import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetCurrentRoomTemperature implements EbusCommand<Void> {
private final BigDecimal temperatureControlValue;
private final BigDecimal temperatureDisplayValue;
public SetCurrentRoomTemperature(final BigDecimal temperatureControlValue, final BigDecimal temperatureDisplayValue) {
this.temperatureControlValue = temperatureControlValue;
this.temperatureDisplayValue = temperatureDisplayValue;
}
@Override
public String[] getEbusCommands() {
try { | return new String[] { addTemperatureToCommand("15b509060e3a00%s%s00", temperatureControlValue, 2), |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
// Path: src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override | public UdpChannelCommand command() { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override
public UdpChannelCommand command() {
return VENTILATIE;
}
@Override
public void callBack(final String s) throws Exception {
BigDecimal val = new BigDecimal(s);
if (val.compareTo(MIN_PCT) < 0) {
val = MIN_PCT;
} | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
// Path: src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override
public UdpChannelCommand command() {
return VENTILATIE;
}
@Override
public void callBack(final String s) throws Exception {
BigDecimal val = new BigDecimal(s);
if (val.compareTo(MIN_PCT) < 0) {
val = MIN_PCT;
} | getInstance().getI2CCommunicator().write(boardAddress, channel, convertPercentageToDacBytes(val)); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override
public UdpChannelCommand command() {
return VENTILATIE;
}
@Override
public void callBack(final String s) throws Exception {
BigDecimal val = new BigDecimal(s);
if (val.compareTo(MIN_PCT) < 0) {
val = MIN_PCT;
} | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/support/Support.java
// public static byte[] convertPercentageToDacBytes(BigDecimal bigDecimal) {
// BigDecimal result = new BigDecimal(1023).divide(new BigDecimal(100)).multiply(bigDecimal).setScale(0, RoundingMode.HALF_UP);
// byte[] b = result.toBigInteger().toByteArray();
// if (b.length == 1) {
// return new byte[] { 0, b[0] };
// }
// return b;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
// Path: src/main/java/be/error/rpi/dac/ventilation/VentilationUdpCallback.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.dac.support.Support.convertPercentageToDacBytes;
import static be.error.rpi.knx.UdpChannelCommand.VENTILATIE;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.ventilation;
public class VentilationUdpCallback implements UdpChannelCallback {
private static final Logger logger = LoggerFactory.getLogger("vent");
private final BigDecimal MIN_PCT = new BigDecimal("10");
private int boardAddress = 0x58;
private int channel = 1;
@Override
public UdpChannelCommand command() {
return VENTILATIE;
}
@Override
public void callBack(final String s) throws Exception {
BigDecimal val = new BigDecimal(s);
if (val.compareTo(MIN_PCT) < 0) {
val = MIN_PCT;
} | getInstance().getI2CCommunicator().write(boardAddress, channel, convertPercentageToDacBytes(val)); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/GetDepartWaterTemperatureGv.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
| import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDepartWaterTemperatureGv implements EbusCommand<String> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b509030d2c01" };
}
public String convertResult(List<String> result) {
String hex = result.get(0).substring(4, 6) + result.get(0).substring(2, 4);
try { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/GetDepartWaterTemperatureGv.java
import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDepartWaterTemperatureGv implements EbusCommand<String> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b509030d2c01" };
}
public String convertResult(List<String> result) {
String hex = result.get(0).substring(4, 6) + result.get(0).substring(2, 4);
try { | return decodeDATA2c(decodeHex(hex.toCharArray())).toString(); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomValveController.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomValveController {
private static final Logger logger = LoggerFactory.getLogger("heating");
| // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomValveController.java
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomValveController {
private static final Logger logger = LoggerFactory.getLogger("heating");
| private LocationId locationId; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomValveController.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomValveController {
private static final Logger logger = LoggerFactory.getLogger("heating");
private LocationId locationId;
private Collection<GroupAddress> valves = new ArrayList<>();
private Optional<Boolean> lastSendValveState = empty();
public RoomValveController(final LocationId locationId, final Collection<GroupAddress> valves) {
this.locationId = locationId;
this.valves = valves;
}
public void updateIfNeeded(boolean heatingDemand) {
if (lastSendValveState.isPresent() && lastSendValveState.get() == heatingDemand) {
logger.debug("Not sending valve update for room " + locationId + " last send:" + lastSendValveState + " current::" + heatingDemand);
return;
}
try { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomValveController.java
import tuwien.auto.calimero.GroupAddress;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomValveController {
private static final Logger logger = LoggerFactory.getLogger("heating");
private LocationId locationId;
private Collection<GroupAddress> valves = new ArrayList<>();
private Optional<Boolean> lastSendValveState = empty();
public RoomValveController(final LocationId locationId, final Collection<GroupAddress> valves) {
this.locationId = locationId;
this.valves = valves;
}
public void updateIfNeeded(boolean heatingDemand) {
if (lastSendValveState.isPresent() && lastSendValveState.get() == heatingDemand) {
logger.debug("Not sending valve update for room " + locationId + " last send:" + lastSendValveState + " current::" + heatingDemand);
return;
}
try { | getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
| // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
| private final LocationId roomId; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa; | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa; | private final UdpChannelCommand desiredTempCommand; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa;
private final UdpChannelCommand desiredTempCommand;
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa;
private final UdpChannelCommand desiredTempCommand;
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() { | getInstance().addUdpChannelCallback(new UdpChannelCallback() { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa;
private final UdpChannelCommand desiredTempCommand;
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class RoomTemperatureCollector {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final LocationId roomId;
private final HeatingController heatingController;
private final GroupAddress currentTemperatureGa;
private final UdpChannelCommand desiredTempCommand;
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() { | getInstance().addUdpChannelCallback(new UdpChannelCallback() { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent; |
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() {
getInstance().addUdpChannelCallback(new UdpChannelCallback() {
@Override
public UdpChannelCommand command() {
return desiredTempCommand;
}
@Override
public void callBack(final String desiredTemp) throws Exception {
logger.debug("Receiving desired temperature " + desiredTemp + "for room " + roomId);
synchronized (roomTemperature) {
roomTemperature.updateDesiredTemp(desiredTemp);
processTemperatureChange();
}
}
});
| // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/dac/dimmer/builder/AbstractDimmerProcessListener.java
// public abstract class AbstractDimmerProcessListener extends ProcessListenerEx {
//
// protected Dimmer dimmer;
//
// void setDimmer(Dimmer dimmer) {
// this.dimmer = dimmer;
// }
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
// public interface UdpChannelCallback {
//
// UdpChannelCommand command();
//
// void callBack(String s) throws Exception;
// }
//
// Path: src/main/java/be/error/rpi/knx/UdpChannelCommand.java
// public enum UdpChannelCommand {
//
// VENTILATIE("VENT"),
// HEATING_ENABLED("HEATING_ENABLED"),
// TEMPERATURE_BADKAMER(TEMPERATURE + "_" + BADKAMER),
// TEMPERATURE_DRESSING(TEMPERATURE + "_" + DRESSING),
// TEMPERATURE_SK1(TEMPERATURE + "_" + SK1),
// TEMPERATURE_SK2(TEMPERATURE + "_" + SK2),
// TEMPERATURE_SK3(TEMPERATURE + "_" + SK3),
// TEMPERATURE_GV(TEMPERATURE + "_" + GELIJKVLOERS);
//
// private String command;
//
// UdpChannelCommand(String s) {
// this.command = s;
// }
//
// public static UdpChannelCommand fromString(String s) {
// for (UdpChannelCommand udpChannelCommand : UdpChannelCommand.values()) {
// if (udpChannelCommand.command.equals(s)) {
// return udpChannelCommand;
// }
// }
// throw new IllegalStateException("Unknown command " + s);
// }
//
// public static class Constants {
// public static final String TEMPERATURE = "TEMP";
// }
//
// }
//
// Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/main/java/be/error/rpi/heating/RoomTemperatureCollector.java
import be.error.rpi.dac.dimmer.builder.AbstractDimmerProcessListener;
import be.error.rpi.knx.UdpChannel.UdpChannelCallback;
import be.error.rpi.knx.UdpChannelCommand;
import be.error.types.LocationId;
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.knx.UdpChannelCommand.Constants.TEMPERATURE;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.DetachEvent;
import tuwien.auto.calimero.GroupAddress;
import tuwien.auto.calimero.process.ProcessEvent;
private final ControlValueCalculator controlValueCalculator = new ControlValueCalculator();
private final RoomTemperature roomTemperature;
public RoomTemperatureCollector(final LocationId roomId, final HeatingController heatingController, GroupAddress currentTemperatureGa) {
this.roomId = roomId;
this.heatingController = heatingController;
this.currentTemperatureGa = currentTemperatureGa;
this.desiredTempCommand = fromString(TEMPERATURE + "_" + roomId);
this.roomTemperature = new RoomTemperature(roomId);
}
public void start() {
getInstance().addUdpChannelCallback(new UdpChannelCallback() {
@Override
public UdpChannelCommand command() {
return desiredTempCommand;
}
@Override
public void callBack(final String desiredTemp) throws Exception {
logger.debug("Receiving desired temperature " + desiredTemp + "for room " + roomId);
synchronized (roomTemperature) {
roomTemperature.updateDesiredTemp(desiredTemp);
processTemperatureChange();
}
}
});
| getInstance().getKnxConnectionFactory().addProcessListener(new AbstractDimmerProcessListener() { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/knx/UdpChannel.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static String LOCAL_IP;
| import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static be.error.rpi.config.RunConfig.LOCAL_IP;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import static java.net.InetAddress.getByName;
import static java.util.Collections.synchronizedList;
import static org.apache.commons.lang3.ArrayUtils.remove;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.ArrayList;
import java.util.List; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.knx;
public class UdpChannel extends Thread {
private static final Logger logger = LoggerFactory.getLogger(UdpChannel.class);
private final List<UdpChannelCallback> udpChannelCallbacks = synchronizedList(new ArrayList<>());
private final DatagramSocket clientSocket;
public UdpChannel(int port, UdpChannelCallback... udpChannelCallbacks) throws Exception {
addUdpChannelCallback(udpChannelCallbacks); | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static String LOCAL_IP;
// Path: src/main/java/be/error/rpi/knx/UdpChannel.java
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static be.error.rpi.config.RunConfig.LOCAL_IP;
import static be.error.rpi.knx.UdpChannelCommand.fromString;
import static java.net.InetAddress.getByName;
import static java.util.Collections.synchronizedList;
import static org.apache.commons.lang3.ArrayUtils.remove;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.ArrayList;
import java.util.List;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.knx;
public class UdpChannel extends Thread {
private static final Logger logger = LoggerFactory.getLogger(UdpChannel.class);
private final List<UdpChannelCallback> udpChannelCallbacks = synchronizedList(new ArrayList<>());
private final DatagramSocket clientSocket;
public UdpChannel(int port, UdpChannelCallback... udpChannelCallbacks) throws Exception {
addUdpChannelCallback(udpChannelCallbacks); | clientSocket = new DatagramSocket(port, getByName(LOCAL_IP)); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress; | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
// Path: src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress; | private final Map<EbusCommand<?>, GroupAddress> map; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress;
private final Map<EbusCommand<?>, GroupAddress> map;
public HeatingInfoPollerJobSchedulerFactory(EbusDeviceAddress ebusDeviceAddress, Map<EbusCommand<?>, GroupAddress> map) throws Exception {
this.map = map;
this.ebusDeviceAddress = ebusDeviceAddress;
logger.debug("Scheduling HeatingInfoPollerJob"); | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
// Path: src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress;
private final Map<EbusCommand<?>, GroupAddress> map;
public HeatingInfoPollerJobSchedulerFactory(EbusDeviceAddress ebusDeviceAddress, Map<EbusCommand<?>, GroupAddress> map) throws Exception {
this.map = map;
this.ebusDeviceAddress = ebusDeviceAddress;
logger.debug("Scheduling HeatingInfoPollerJob"); | getInstance().getScheduler().scheduleJob(getJob(HeatingInfoPollerJob.class, ebusDeviceAddress, map), |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
| import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress;
private final Map<EbusCommand<?>, GroupAddress> map;
public HeatingInfoPollerJobSchedulerFactory(EbusDeviceAddress ebusDeviceAddress, Map<EbusCommand<?>, GroupAddress> map) throws Exception {
this.map = map;
this.ebusDeviceAddress = ebusDeviceAddress;
logger.debug("Scheduling HeatingInfoPollerJob"); | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/HeatingInfoPollerJob.java
// public class HeatingInfoPollerJob implements Job {
//
// public static String JOB_CONFIG_KEY = "jobconfig";
//
// private static final Logger logger = LoggerFactory.getLogger("heating");
//
// @Override
// public void execute(final JobExecutionContext context) throws JobExecutionException {
// try {
// logger.debug("Status poller job starting...");
// JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);
//
// for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
// logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
// List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress()).send(entry.getKey());
// logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> " + ArrayUtils.toString(result, ""));
// Object converted = entry.getKey().convertResult(result);
// logger.debug("Sending result " + converted + " to GA: " + entry.getValue());
//
// if (converted instanceof Float) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
// } else if (converted instanceof BigDecimal) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
// } else if (converted instanceof Boolean) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
// } else if (converted instanceof String) {
// getInstance().getKnxConnectionFactory().runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
// } else {
// throw new IllegalStateException("Could not send type " + converted.getClass());
// }
// }
// } catch (Exception e) {
// logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
// throw new JobExecutionException(e);
// }
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
// public class JobConfig implements Serializable {
//
// private EbusDeviceAddress ebusDeviceAddress;
// private Map<EbusCommand<?>, GroupAddress> ebusCommands;
//
// public JobConfig(final EbusDeviceAddress ebusDeviceAddress, final Map<EbusCommand<?>, GroupAddress> ebusCommands) {
// this.ebusDeviceAddress = ebusDeviceAddress;
// this.ebusCommands = ebusCommands;
// }
//
// public EbusDeviceAddress getEbusDeviceAddress() {
// return ebusDeviceAddress;
// }
//
// public Map<EbusCommand<?>, GroupAddress> getEbusCommands() {
// return ebusCommands;
// }
// }
// Path: src/main/java/be/error/rpi/heating/HeatingInfoPollerJobSchedulerFactory.java
import static be.error.rpi.config.RunConfig.getInstance;
import static be.error.rpi.heating.jobs.HeatingInfoPollerJob.JOB_CONFIG_KEY;
import static org.apache.commons.lang3.time.DateUtils.addSeconds;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import java.util.Date;
import java.util.Map;
import org.quartz.CronExpression;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.jobs.HeatingInfoPollerJob;
import be.error.rpi.heating.jobs.JobConfig;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating;
public class HeatingInfoPollerJobSchedulerFactory {
private static final Logger logger = LoggerFactory.getLogger("heating");
private final EbusDeviceAddress ebusDeviceAddress;
private final Map<EbusCommand<?>, GroupAddress> map;
public HeatingInfoPollerJobSchedulerFactory(EbusDeviceAddress ebusDeviceAddress, Map<EbusCommand<?>, GroupAddress> map) throws Exception {
this.map = map;
this.ebusDeviceAddress = ebusDeviceAddress;
logger.debug("Scheduling HeatingInfoPollerJob"); | getInstance().getScheduler().scheduleJob(getJob(HeatingInfoPollerJob.class, ebusDeviceAddress, map), |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/GetDesiredTemperatureCommand.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
| import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDesiredTemperatureCommand implements EbusCommand<BigDecimal> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b50903292200" };
}
public BigDecimal convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/GetDesiredTemperatureCommand.java
import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDesiredTemperatureCommand implements EbusCommand<BigDecimal> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b50903292200" };
}
public BigDecimal convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | return decodeDATA2c(decodeHex(hex.toCharArray())); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/SetDesiredRoomTemperature.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
| import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal;
import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetDesiredRoomTemperature implements EbusCommand<Void> {
/**
* 18
* --
* 3015b509040e 2300 01 / 00
* 3015b509050e 2400 2001 / 00
* 3015b509070e 2500 86734200 / 00
* <p>
* <p>
* 3015b509040e230001 / 00
* 3015b509050e 2400 1001 / 00
* 3015b509070e 2500 86734200 / 00
*/
private final BigDecimal temperature; | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/SetDesiredRoomTemperature.java
import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal;
import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetDesiredRoomTemperature implements EbusCommand<Void> {
/**
* 18
* --
* 3015b509040e 2300 01 / 00
* 3015b509050e 2400 2001 / 00
* 3015b509070e 2500 86734200 / 00
* <p>
* <p>
* 3015b509040e230001 / 00
* 3015b509050e 2400 1001 / 00
* 3015b509070e 2500 86734200 / 00
*/
private final BigDecimal temperature; | private final EbusDeviceAddress ebusDeviceAddress; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/SetDesiredRoomTemperature.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
| import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal;
import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetDesiredRoomTemperature implements EbusCommand<Void> {
/**
* 18
* --
* 3015b509040e 2300 01 / 00
* 3015b509050e 2400 2001 / 00
* 3015b509070e 2500 86734200 / 00
* <p>
* <p>
* 3015b509040e230001 / 00
* 3015b509050e 2400 1001 / 00
* 3015b509070e 2500 86734200 / 00
*/
private final BigDecimal temperature;
private final EbusDeviceAddress ebusDeviceAddress;
public SetDesiredRoomTemperature(final BigDecimal temperature, final EbusDeviceAddress ebusDeviceAddress) {
this.temperature = temperature;
this.ebusDeviceAddress = ebusDeviceAddress;
}
@Override
public String[] getEbusCommands() { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static String addTemperatureToCommand(String command, BigDecimal temperature, int offset) {
// String converted = encodeDATA2c(temperature.add(new BigDecimal(offset)));
// return format(command, substring(converted, 2, 4), substring(converted, 0, 2));
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/SetDesiredRoomTemperature.java
import static be.error.rpi.ebus.Support.addTemperatureToCommand;
import java.math.BigDecimal;
import java.util.List;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class SetDesiredRoomTemperature implements EbusCommand<Void> {
/**
* 18
* --
* 3015b509040e 2300 01 / 00
* 3015b509050e 2400 2001 / 00
* 3015b509070e 2500 86734200 / 00
* <p>
* <p>
* 3015b509040e230001 / 00
* 3015b509050e 2400 1001 / 00
* 3015b509070e 2500 86734200 / 00
*/
private final BigDecimal temperature;
private final EbusDeviceAddress ebusDeviceAddress;
public SetDesiredRoomTemperature(final BigDecimal temperature, final EbusDeviceAddress ebusDeviceAddress) {
this.temperature = temperature;
this.ebusDeviceAddress = ebusDeviceAddress;
}
@Override
public String[] getEbusCommands() { | return new String[] { "15b509040e230001", addTemperatureToCommand("15b509050e2400%s%s", temperature, 0), "15b509070e250086734200" }; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/EbusdTcpCommunicatorImpl.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
| import org.slf4j.LoggerFactory;
import be.error.rpi.heating.EbusDeviceAddress;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus;
public class EbusdTcpCommunicatorImpl implements EbusdTcpCommunicator {
private static final Logger logger = LoggerFactory.getLogger("ebusd"); | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/EbusdTcpCommunicatorImpl.java
import org.slf4j.LoggerFactory;
import be.error.rpi.heating.EbusDeviceAddress;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus;
public class EbusdTcpCommunicatorImpl implements EbusdTcpCommunicator {
private static final Logger logger = LoggerFactory.getLogger("ebusd"); | private final EbusDeviceAddress ebusDeviceAddress; |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/EbusdTcpCommunicatorImpl.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
| import org.slf4j.LoggerFactory;
import be.error.rpi.heating.EbusDeviceAddress;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus;
public class EbusdTcpCommunicatorImpl implements EbusdTcpCommunicator {
private static final Logger logger = LoggerFactory.getLogger("ebusd");
private final EbusDeviceAddress ebusDeviceAddress;
public EbusdTcpCommunicatorImpl(final EbusDeviceAddress ebusDeviceAddress) {
this.ebusDeviceAddress = ebusDeviceAddress;
}
public List<String> send(EbusCommand ebusCommand) throws Exception { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/EbusdTcpCommunicatorImpl.java
import org.slf4j.LoggerFactory;
import be.error.rpi.heating.EbusDeviceAddress;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus;
public class EbusdTcpCommunicatorImpl implements EbusdTcpCommunicator {
private static final Logger logger = LoggerFactory.getLogger("ebusd");
private final EbusDeviceAddress ebusDeviceAddress;
public EbusdTcpCommunicatorImpl(final EbusDeviceAddress ebusDeviceAddress) {
this.ebusDeviceAddress = ebusDeviceAddress;
}
public List<String> send(EbusCommand ebusCommand) throws Exception { | try (Socket clientSocket = new Socket(getInstance().getEbusdIp(), getInstance().getEbusdPort())) { |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/GetOutsideTemperature.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
| import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetOutsideTemperature implements EbusCommand<BigDecimal> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b50903293c00" };
}
public BigDecimal convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/GetOutsideTemperature.java
import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetOutsideTemperature implements EbusCommand<BigDecimal> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b50903293c00" };
}
public BigDecimal convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | return decodeDATA2c(decodeHex(hex.toCharArray())); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/adc/AdcController.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/adc/ObjectStatusTypeMapper.java
// public enum ObjectStatusType {
// OPEN((byte) 1),
// CLOSED((byte) 2),
// SHORT_CIRCUIT((byte) 3),
// CIRCUIT_BREACH((byte) 4),
// READ_ERROR((byte) 5);
//
// private byte id;
//
// ObjectStatusType(final byte id) {
// this.id = id;
// }
//
// public byte getId() {
// return id;
// }
// }
| import java.util.concurrent.ExecutorService;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.adc.ObjectStatusTypeMapper.ObjectStatusType;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.tuple.Pair.of;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.adc;
/**
* Loops over the different ADC connected to the I2C bus based on their bus address (see {@link AdcControllerConfiguration}). Each ADC board has two ADC
* 'devices' and thus two addresses. Each ADC has 4 channels. Each channel is configured for continuous 16bit conversion. The application runs over each channel of
* each devices and gathers the actual voltage. The voltage depends on the total resistance of the circuit. The magnetic contacts in use in use have 2 x 1kohm
* resistors. When the contact is 'open' the 2 resistors are active. When the contact is 'closed', one resistor is bypassed. When the circuit voltage is measured via
* the internal voltage divider of the ADC, this will result in different voltages. This results in 4 possible states and enables to detect circuit tampering. When the
* circuit is short-circuited, the voltage measured will be near to the input voltage of 5V. When the circuit is cut (like a wire cut) a voltage near to 0V will be
* measured. If the magnetic contact is open or closed a different voltage >0V and <5V will be measured. This is reflected in the following 4 enum states:
* <p/>
* <ul>
* <li>{@link ObjectStatusType#OPEN}</li>
* <li>{@link ObjectStatusType#CLOSED}</li>
* <li>{@link ObjectStatusType#CIRCUIT_BREACH}</li>
* <li>{@link ObjectStatusType#SHORT_CIRCUIT}</li>
* </ul>
* <p/>
* There is an additional status for indicating read errors ({@link ObjectStatusType#READ_ERROR}) which means there is either a coding or a electronical issue. The
* voltage measured is determined based on the ADC internal voltage divider and the total resistance at that time. See {@link ObjectStatusTypeMapper} for the
* conversion table. Finally, the state read from each of the channels is sent over UDP to Loxone. Each channel is represented by a single UDP packet, consisting out
* of 2 bytes payload. The first byte indicated the channel number, the second byte indicates the status. Via this information Loxone can display the state of each of
* the window/door object.
*
* @author Koen Serneels
*/
public class AdcController {
private static final Logger logger = LoggerFactory.getLogger(AdcController.class);
private static final ExecutorService adcPool = newFixedThreadPool(4);
public void run() throws Exception { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/adc/ObjectStatusTypeMapper.java
// public enum ObjectStatusType {
// OPEN((byte) 1),
// CLOSED((byte) 2),
// SHORT_CIRCUIT((byte) 3),
// CIRCUIT_BREACH((byte) 4),
// READ_ERROR((byte) 5);
//
// private byte id;
//
// ObjectStatusType(final byte id) {
// this.id = id;
// }
//
// public byte getId() {
// return id;
// }
// }
// Path: src/main/java/be/error/rpi/adc/AdcController.java
import java.util.concurrent.ExecutorService;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.adc.ObjectStatusTypeMapper.ObjectStatusType;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.tuple.Pair.of;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.adc;
/**
* Loops over the different ADC connected to the I2C bus based on their bus address (see {@link AdcControllerConfiguration}). Each ADC board has two ADC
* 'devices' and thus two addresses. Each ADC has 4 channels. Each channel is configured for continuous 16bit conversion. The application runs over each channel of
* each devices and gathers the actual voltage. The voltage depends on the total resistance of the circuit. The magnetic contacts in use in use have 2 x 1kohm
* resistors. When the contact is 'open' the 2 resistors are active. When the contact is 'closed', one resistor is bypassed. When the circuit voltage is measured via
* the internal voltage divider of the ADC, this will result in different voltages. This results in 4 possible states and enables to detect circuit tampering. When the
* circuit is short-circuited, the voltage measured will be near to the input voltage of 5V. When the circuit is cut (like a wire cut) a voltage near to 0V will be
* measured. If the magnetic contact is open or closed a different voltage >0V and <5V will be measured. This is reflected in the following 4 enum states:
* <p/>
* <ul>
* <li>{@link ObjectStatusType#OPEN}</li>
* <li>{@link ObjectStatusType#CLOSED}</li>
* <li>{@link ObjectStatusType#CIRCUIT_BREACH}</li>
* <li>{@link ObjectStatusType#SHORT_CIRCUIT}</li>
* </ul>
* <p/>
* There is an additional status for indicating read errors ({@link ObjectStatusType#READ_ERROR}) which means there is either a coding or a electronical issue. The
* voltage measured is determined based on the ADC internal voltage divider and the total resistance at that time. See {@link ObjectStatusTypeMapper} for the
* conversion table. Finally, the state read from each of the channels is sent over UDP to Loxone. Each channel is represented by a single UDP packet, consisting out
* of 2 bytes payload. The first byte indicated the channel number, the second byte indicates the status. Via this information Loxone can display the state of each of
* the window/door object.
*
* @author Koen Serneels
*/
public class AdcController {
private static final Logger logger = LoggerFactory.getLogger(AdcController.class);
private static final ExecutorService adcPool = newFixedThreadPool(4);
public void run() throws Exception { | ObjectStatusUdpSender sender = new ObjectStatusUdpSender(getInstance().getLoxoneIp(), getInstance().getLoxonePort()); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/adc/AdcController.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/adc/ObjectStatusTypeMapper.java
// public enum ObjectStatusType {
// OPEN((byte) 1),
// CLOSED((byte) 2),
// SHORT_CIRCUIT((byte) 3),
// CIRCUIT_BREACH((byte) 4),
// READ_ERROR((byte) 5);
//
// private byte id;
//
// ObjectStatusType(final byte id) {
// this.id = id;
// }
//
// public byte getId() {
// return id;
// }
// }
| import java.util.concurrent.ExecutorService;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.adc.ObjectStatusTypeMapper.ObjectStatusType;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.tuple.Pair.of;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.adc;
/**
* Loops over the different ADC connected to the I2C bus based on their bus address (see {@link AdcControllerConfiguration}). Each ADC board has two ADC
* 'devices' and thus two addresses. Each ADC has 4 channels. Each channel is configured for continuous 16bit conversion. The application runs over each channel of
* each devices and gathers the actual voltage. The voltage depends on the total resistance of the circuit. The magnetic contacts in use in use have 2 x 1kohm
* resistors. When the contact is 'open' the 2 resistors are active. When the contact is 'closed', one resistor is bypassed. When the circuit voltage is measured via
* the internal voltage divider of the ADC, this will result in different voltages. This results in 4 possible states and enables to detect circuit tampering. When the
* circuit is short-circuited, the voltage measured will be near to the input voltage of 5V. When the circuit is cut (like a wire cut) a voltage near to 0V will be
* measured. If the magnetic contact is open or closed a different voltage >0V and <5V will be measured. This is reflected in the following 4 enum states:
* <p/>
* <ul>
* <li>{@link ObjectStatusType#OPEN}</li>
* <li>{@link ObjectStatusType#CLOSED}</li>
* <li>{@link ObjectStatusType#CIRCUIT_BREACH}</li>
* <li>{@link ObjectStatusType#SHORT_CIRCUIT}</li>
* </ul>
* <p/>
* There is an additional status for indicating read errors ({@link ObjectStatusType#READ_ERROR}) which means there is either a coding or a electronical issue. The
* voltage measured is determined based on the ADC internal voltage divider and the total resistance at that time. See {@link ObjectStatusTypeMapper} for the
* conversion table. Finally, the state read from each of the channels is sent over UDP to Loxone. Each channel is represented by a single UDP packet, consisting out
* of 2 bytes payload. The first byte indicated the channel number, the second byte indicates the status. Via this information Loxone can display the state of each of
* the window/door object.
*
* @author Koen Serneels
*/
public class AdcController {
private static final Logger logger = LoggerFactory.getLogger(AdcController.class);
private static final ExecutorService adcPool = newFixedThreadPool(4);
public void run() throws Exception {
ObjectStatusUdpSender sender = new ObjectStatusUdpSender(getInstance().getLoxoneIp(), getInstance().getLoxonePort());
logger.debug("ADC controller starting");
AdcControllerConfiguration adcControllerConfiguration = new AdcControllerConfiguration();
int i = 0;
while (true) { | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
//
// Path: src/main/java/be/error/rpi/adc/ObjectStatusTypeMapper.java
// public enum ObjectStatusType {
// OPEN((byte) 1),
// CLOSED((byte) 2),
// SHORT_CIRCUIT((byte) 3),
// CIRCUIT_BREACH((byte) 4),
// READ_ERROR((byte) 5);
//
// private byte id;
//
// ObjectStatusType(final byte id) {
// this.id = id;
// }
//
// public byte getId() {
// return id;
// }
// }
// Path: src/main/java/be/error/rpi/adc/AdcController.java
import java.util.concurrent.ExecutorService;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.error.rpi.adc.ObjectStatusTypeMapper.ObjectStatusType;
import static be.error.rpi.config.RunConfig.getInstance;
import static java.lang.Thread.sleep;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.tuple.Pair.of;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.adc;
/**
* Loops over the different ADC connected to the I2C bus based on their bus address (see {@link AdcControllerConfiguration}). Each ADC board has two ADC
* 'devices' and thus two addresses. Each ADC has 4 channels. Each channel is configured for continuous 16bit conversion. The application runs over each channel of
* each devices and gathers the actual voltage. The voltage depends on the total resistance of the circuit. The magnetic contacts in use in use have 2 x 1kohm
* resistors. When the contact is 'open' the 2 resistors are active. When the contact is 'closed', one resistor is bypassed. When the circuit voltage is measured via
* the internal voltage divider of the ADC, this will result in different voltages. This results in 4 possible states and enables to detect circuit tampering. When the
* circuit is short-circuited, the voltage measured will be near to the input voltage of 5V. When the circuit is cut (like a wire cut) a voltage near to 0V will be
* measured. If the magnetic contact is open or closed a different voltage >0V and <5V will be measured. This is reflected in the following 4 enum states:
* <p/>
* <ul>
* <li>{@link ObjectStatusType#OPEN}</li>
* <li>{@link ObjectStatusType#CLOSED}</li>
* <li>{@link ObjectStatusType#CIRCUIT_BREACH}</li>
* <li>{@link ObjectStatusType#SHORT_CIRCUIT}</li>
* </ul>
* <p/>
* There is an additional status for indicating read errors ({@link ObjectStatusType#READ_ERROR}) which means there is either a coding or a electronical issue. The
* voltage measured is determined based on the ADC internal voltage divider and the total resistance at that time. See {@link ObjectStatusTypeMapper} for the
* conversion table. Finally, the state read from each of the channels is sent over UDP to Loxone. Each channel is represented by a single UDP packet, consisting out
* of 2 bytes payload. The first byte indicated the channel number, the second byte indicates the status. Via this information Loxone can display the state of each of
* the window/door object.
*
* @author Koen Serneels
*/
public class AdcController {
private static final Logger logger = LoggerFactory.getLogger(AdcController.class);
private static final ExecutorService adcPool = newFixedThreadPool(4);
public void run() throws Exception {
ObjectStatusUdpSender sender = new ObjectStatusUdpSender(getInstance().getLoxoneIp(), getInstance().getLoxonePort());
logger.debug("ADC controller starting");
AdcControllerConfiguration adcControllerConfiguration = new AdcControllerConfiguration();
int i = 0;
while (true) { | List<CompletableFuture<List<Pair<AdcChannel, ObjectStatusType>>>> futures = new ArrayList(); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/ebus/commands/GetDepartWaterTemperatureEv.java | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
| import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDepartWaterTemperatureEv implements EbusCommand<String> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b509030dc500" };
}
public String convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | // Path: src/main/java/be/error/rpi/ebus/Support.java
// public static BigDecimal decodeDATA2c(byte[] data) {
// return new BigDecimal(decodeInt(data)).divide(new BigDecimal(16)).setScale(2, HALF_UP);
// }
//
// Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
// Path: src/main/java/be/error/rpi/ebus/commands/GetDepartWaterTemperatureEv.java
import static be.error.rpi.ebus.Support.decodeDATA2c;
import static org.apache.commons.codec.binary.Hex.decodeHex;
import java.util.List;
import org.apache.commons.codec.DecoderException;
import be.error.rpi.ebus.EbusCommand;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.ebus.commands;
public class GetDepartWaterTemperatureEv implements EbusCommand<String> {
@Override
public String[] getEbusCommands() {
return new String[] { "15b509030dc500" };
}
public String convertResult(List<String> result) {
String hex = result.get(0).substring(8, 10) + result.get(0).substring(6, 8);
try { | return decodeDATA2c(decodeHex(hex.toCharArray())).toString(); |
koen-serneels/HomeAutomation | src/test/java/be/error/rpi/heating/RoomTemperatureDeltaSorterTest.java | // Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import static org.testng.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.Test;
import be.error.types.LocationId; | assertEquals(sorted.get(0), create("18.99", "21.00"));
assertEquals(sorted.get(1), create("19.00", "21.00"));
assertEquals(sorted.get(2), create("20.00", "21.00"));
assertEquals(sorted.get(3), create("20.00", "21.00"));
assertEquals(sorted.get(4), create("24.00", "21.00"));
assertEquals(sorted.get(5), create("25.00", "21.00"));
assertEquals(sorted.get(6), create("27.00", "21.00"));
roomTemperatureInfos = new ArrayList<>();
roomTemperatureInfos.add(create("20.00", "21.00"));
roomTemperatureInfos.add(create("19.00", "21.00"));
roomTemperatureInfos.add(create("27.00", "21.00"));
roomTemperatureInfos.add(create("25.00", "21.00"));
roomTemperatureInfos.add(create("18.99", "21.00"));
roomTemperatureInfos.add(create("20.00", "21.00"));
roomTemperatureInfos.add(create("21.00", "21.00"));
roomTemperatureInfos.add(create("24.00", "21.00"));
sorted = sorter.sortRoomTemperatureInfos(roomTemperatureInfos);
assertEquals(sorted.get(0), create("18.99", "21.00"));
assertEquals(sorted.get(1), create("19.00", "21.00"));
assertEquals(sorted.get(2), create("20.00", "21.00"));
assertEquals(sorted.get(3), create("20.00", "21.00"));
assertEquals(sorted.get(4), create("21.00", "21.00"));
assertEquals(sorted.get(5), create("24.00", "21.00"));
assertEquals(sorted.get(6), create("25.00", "21.00"));
assertEquals(sorted.get(7), create("27.00", "21.00"));
}
private RoomTemperature create(String current, String desired) { | // Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/test/java/be/error/rpi/heating/RoomTemperatureDeltaSorterTest.java
import static org.testng.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.Test;
import be.error.types.LocationId;
assertEquals(sorted.get(0), create("18.99", "21.00"));
assertEquals(sorted.get(1), create("19.00", "21.00"));
assertEquals(sorted.get(2), create("20.00", "21.00"));
assertEquals(sorted.get(3), create("20.00", "21.00"));
assertEquals(sorted.get(4), create("24.00", "21.00"));
assertEquals(sorted.get(5), create("25.00", "21.00"));
assertEquals(sorted.get(6), create("27.00", "21.00"));
roomTemperatureInfos = new ArrayList<>();
roomTemperatureInfos.add(create("20.00", "21.00"));
roomTemperatureInfos.add(create("19.00", "21.00"));
roomTemperatureInfos.add(create("27.00", "21.00"));
roomTemperatureInfos.add(create("25.00", "21.00"));
roomTemperatureInfos.add(create("18.99", "21.00"));
roomTemperatureInfos.add(create("20.00", "21.00"));
roomTemperatureInfos.add(create("21.00", "21.00"));
roomTemperatureInfos.add(create("24.00", "21.00"));
sorted = sorter.sortRoomTemperatureInfos(roomTemperatureInfos);
assertEquals(sorted.get(0), create("18.99", "21.00"));
assertEquals(sorted.get(1), create("19.00", "21.00"));
assertEquals(sorted.get(2), create("20.00", "21.00"));
assertEquals(sorted.get(3), create("20.00", "21.00"));
assertEquals(sorted.get(4), create("21.00", "21.00"));
assertEquals(sorted.get(5), create("24.00", "21.00"));
assertEquals(sorted.get(6), create("25.00", "21.00"));
assertEquals(sorted.get(7), create("27.00", "21.00"));
}
private RoomTemperature create(String current, String desired) { | RoomTemperature roomTemperature = new RoomTemperature(LocationId.BADKAMER, new BigDecimal(current).setScale(2), new BigDecimal(desired).setScale(2)); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/heating/jobs/JobConfig.java | // Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
| import java.io.Serializable;
import java.util.Map;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating.jobs;
public class JobConfig implements Serializable {
private EbusDeviceAddress ebusDeviceAddress; | // Path: src/main/java/be/error/rpi/ebus/EbusCommand.java
// public interface EbusCommand<R> {
//
// String[] getEbusCommands();
//
// R convertResult(List<String> results);
//
// default boolean withResult() {
// return false;
// }
// }
//
// Path: src/main/java/be/error/rpi/heating/EbusDeviceAddress.java
// public enum EbusDeviceAddress {
//
// GROUND_FLOOR("30"),
// FIRST_FLOOR("70");
//
// private final String ebusAddressPrefix;
//
// EbusDeviceAddress(final String ebusAddressPrefix) {
// this.ebusAddressPrefix = ebusAddressPrefix;
// }
//
// public String getEbusAddressPrefix() {
// return ebusAddressPrefix;
// }
// }
// Path: src/main/java/be/error/rpi/heating/jobs/JobConfig.java
import java.io.Serializable;
import java.util.Map;
import tuwien.auto.calimero.GroupAddress;
import be.error.rpi.ebus.EbusCommand;
import be.error.rpi.heating.EbusDeviceAddress;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.heating.jobs;
public class JobConfig implements Serializable {
private EbusDeviceAddress ebusDeviceAddress; | private Map<EbusCommand<?>, GroupAddress> ebusCommands; |
koen-serneels/HomeAutomation | src/test/java/be/error/rpi/heating/ControlValueCalculatorTest.java | // Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
| import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import java.math.BigDecimal;
import org.testng.annotations.Test;
import be.error.types.LocationId; |
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.40", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.50", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.70", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.80", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("23.10", "23.00")).getHeatingDemand());
assertFalse(controlValueCalculator.updateHeatingDemand(create("23.11", "23.00")).getHeatingDemand());
RoomTemperature roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(false);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateHeatingDemand(true);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(false);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(22.50);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(true);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(23.00);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(23.12);
assertFalse(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
}
private RoomTemperature create(String current, String desired) { | // Path: src/main/java/be/error/types/LocationId.java
// public enum LocationId {
//
// GELIJKVLOERS("Gelijkvloers"),
// NACHTHAL("Nachthal"),
// BADKAMER("Badkamer"),
// DRESSING("Dressing"),
// SK1("Slaapkamer1"),
// SK2("Slaapkamer2"),
// SK3("Slaapkamer3"),
// KEUKEN("Keuken"),
// EETHOEK("Eethoek"),
// INKOMHAL("Inkomhal"),
// BERGING("Berging"),
// VOORDEUR("Inkom buiten"),
// GANG("Gang"),
// WC("WC"),
// ZITHOEK("Zithoek"),
// GARAGE("Garage"),
// LZG("LZG"),
// AG("AG"),
// RZG("RZG"),
// VG("VG");
//
// private String dimmerDescription;
//
// LocationId(final String dimmerDescription) {
// this.dimmerDescription = dimmerDescription;
// }
// }
// Path: src/test/java/be/error/rpi/heating/ControlValueCalculatorTest.java
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import java.math.BigDecimal;
import org.testng.annotations.Test;
import be.error.types.LocationId;
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.40", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.50", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.70", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("22.80", "23.00")).getHeatingDemand());
assertTrue(controlValueCalculator.updateHeatingDemand(create("23.10", "23.00")).getHeatingDemand());
assertFalse(controlValueCalculator.updateHeatingDemand(create("23.11", "23.00")).getHeatingDemand());
RoomTemperature roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(false);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateHeatingDemand(true);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(false);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(22.50);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature = controlValueCalculator.updateHeatingDemand(create("22.80", "23.00"));
roomTemperature.updateHeatingDemand(true);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(23.00);
assertTrue(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
roomTemperature.updateCurrentTemp(23.12);
assertFalse(controlValueCalculator.updateHeatingDemand(roomTemperature).getHeatingDemand());
}
private RoomTemperature create(String current, String desired) { | RoomTemperature roomTemperature = new RoomTemperature(LocationId.BADKAMER, new BigDecimal(current).setScale(2), new BigDecimal(desired).setScale(2)); |
koen-serneels/HomeAutomation | src/main/java/be/error/rpi/dac/i2c/I2CCommunicator.java | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
| import com.pi4j.io.i2c.I2CDevice;
import static be.error.rpi.config.RunConfig.getInstance;
import static org.apache.commons.lang3.ArrayUtils.add;
import static org.apache.commons.lang3.ArrayUtils.reverse;
import java.io.IOException;
import java.math.BigInteger;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.i2c;
/**
* @author Koen Serneels
*/
public class I2CCommunicator extends Thread {
private static final Logger logger = LoggerFactory.getLogger(I2CCommunicator.class);
private BlockingQueue<WriteCommand> commandQueue = new LinkedBlockingDeque();
@Override
public void run() {
logger.debug("Communicator thread starting");
WriteCommand writeCommand = null;
while (true) {
try {
writeCommand = commandQueue.take();
writeCommand.i2cDevice.write(writeCommand.value, 0, writeCommand.value.length);
sleep(5);
//If there is a next command, and the command is meant for the same board as we have just written to, wait to avoid overload
if (commandQueue.peek() == null || (commandQueue.peek() != null && commandQueue.peek().boardAddress == writeCommand.boardAddress)) {
sleep(8);
}
} catch (Exception e) {
logger.error("Communicator thread had exception. Write command: " + writeCommand, e);
}
}
}
public synchronized void write(int boardAddress, int channel, byte[] b) throws IOException {
WriteCommand writeCommand = new WriteCommand();
writeCommand.boardAddress = boardAddress; | // Path: src/main/java/be/error/rpi/config/RunConfig.java
// public static RunConfig getInstance() {
// if (runConfig == null) {
// throw new IllegalStateException("Initialize first");
// }
// return runConfig;
// }
// Path: src/main/java/be/error/rpi/dac/i2c/I2CCommunicator.java
import com.pi4j.io.i2c.I2CDevice;
import static be.error.rpi.config.RunConfig.getInstance;
import static org.apache.commons.lang3.ArrayUtils.add;
import static org.apache.commons.lang3.ArrayUtils.reverse;
import java.io.IOException;
import java.math.BigInteger;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*-
* #%L
* Home Automation
* %%
* Copyright (C) 2016 - 2017 Koen Serneels
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package be.error.rpi.dac.i2c;
/**
* @author Koen Serneels
*/
public class I2CCommunicator extends Thread {
private static final Logger logger = LoggerFactory.getLogger(I2CCommunicator.class);
private BlockingQueue<WriteCommand> commandQueue = new LinkedBlockingDeque();
@Override
public void run() {
logger.debug("Communicator thread starting");
WriteCommand writeCommand = null;
while (true) {
try {
writeCommand = commandQueue.take();
writeCommand.i2cDevice.write(writeCommand.value, 0, writeCommand.value.length);
sleep(5);
//If there is a next command, and the command is meant for the same board as we have just written to, wait to avoid overload
if (commandQueue.peek() == null || (commandQueue.peek() != null && commandQueue.peek().boardAddress == writeCommand.boardAddress)) {
sleep(8);
}
} catch (Exception e) {
logger.error("Communicator thread had exception. Write command: " + writeCommand, e);
}
}
}
public synchronized void write(int boardAddress, int channel, byte[] b) throws IOException {
WriteCommand writeCommand = new WriteCommand();
writeCommand.boardAddress = boardAddress; | writeCommand.i2cDevice = getInstance().getBus().getDevice(boardAddress); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.