Refactoring checkstyle daemon into a more general purpose buck daemon.
Change-Id: I999541e8894f07061141b3a62414e491369f8d08
diff --git a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java
new file mode 100644
index 0000000..dc5b753
--- /dev/null
+++ b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * 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.
+ */
+
+package org.onosproject.buckdaemon;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.io.ByteStreams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Context for executing a single Buck task.
+ */
+public class BuckTaskContext {
+
+ private final String taskName;
+ private final ImmutableList<String> input;
+ private final List<String> output = new ArrayList<>();
+
+ BuckTaskContext(InputStream inputString) throws IOException {
+ String[] split = new String(ByteStreams.toByteArray(inputString)).split("\n");
+ checkArgument(split.length >= 1, "Request must contain at least task type");
+ this.taskName = split[0];
+ ImmutableList.Builder<String> builder = ImmutableList.builder();
+ for (int i = 1; i < split.length; i++) {
+ builder.add(split[i]);
+ }
+ input = builder.build();
+ }
+
+ /**
+ * Returns the symbolic task name.
+ */
+ public String taskName() {
+ return taskName;
+ }
+
+ /**
+ * Returns the input data a list of strings.
+ *
+ * @return input data
+ */
+ public List<String> input() {
+ return ImmutableList.copyOf(input);
+ }
+
+ /**
+ * Returns the output data a list of strings.
+ *
+ * @return output data
+ */
+ List<String> output() {
+ return ImmutableList.copyOf(output);
+ }
+
+ /**
+ * Adds a line to the output data.
+ *
+ * @param line line of output data
+ */
+ public void output(String line) {
+ output.add(line);
+ }
+
+}