/*
Copyright (c) 2013, Colorado State University
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright holder or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and on
any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
*/

package io.sigpipe.sing.query;

import io.sigpipe.sing.serialization.ByteSerializable;

import io.sigpipe.sing.serialization.SerializationException;
import io.sigpipe.sing.serialization.SerializationInputStream;
import io.sigpipe.sing.serialization.SerializationOutputStream;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Encapsulates a Galileo query.
 *
 * @author malensek
 */
public class Query implements ByteSerializable {

    private List<Operation> operations = new ArrayList<>();

    public Query() { }

    public Query(Operation... operations) {
        for (Operation operation : operations) {
            addOperation(operation);
        }
    }

    public void addOperation(Operation op) {
        operations.add(op);
    }

    public List<Operation> getOperations() {
        return operations;
    }

    @Override
    public String toString() {
        String str = "";
        for (int i = 0; i < operations.size(); ++i) {
            str += operations.get(i);

            if (i < operations.size() - 1) {
                str += " || ";
            }
        }
        return str;
    }

    @Deserialize
    public Query(SerializationInputStream in)
    throws IOException, SerializationException {
        in.readSerializableCollection(Operation.class, operations);
    }

    @Override
    public void serialize(SerializationOutputStream out)
    throws IOException {
        out.writeSerializableCollection(operations);
    }
}

@@ -17,9 +17,9 @@
  201
-3
+6
 , Co
@@ -1355,116 +1355,65 @@
 ort 
-io.sigpipe.sing.serialization.ByteSerializable;%0A%0Aimport io.sigpipe.sing.serialization.SerializationException
+java.io.IOException;%0A%0Aimport io.sigpipe.sing.graph.Vertex
 ;%0Aim
@@ -1439,32 +1439,36 @@
 g.serialization.
+Byte
 SerializationInp
@@ -1460,31 +1460,19 @@
 erializa
-tionInputStream
+ble
 ;%0Aimport
@@ -1534,1223 +1534,304 @@
 m;%0A%0A
-import java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Encapsulates a Galileo query.%0A *%0A * @author malensek%0A */%0Apublic class Query implements ByteSerializable %7B%0A%0A    private List%3COperation%3E operations = new ArrayList%3C%3E();%0A%0A    public Query() %7B %7D%0A%0A    public Query(Operation... operations) %7B%0A        for (Operation operation : operations) %7B%0A            addOperation(operation);%0A        %7D%0A    %7D%0A%0A    public void addOperation(Operation op) %7B%0A        operations.add(op);%0A    %7D%0A%0A    public List%3COperation%3E getOperations() %7B%0A        return operations;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        String str = %22%22;%0A        for (int i = 0; i %3C operations.size(); ++i) %7B%0A            str += operations.get(i);%0A%0A            if (i %3C operations.size() - 1) %7B%0A                str += %22 %7C%7C %22;%0A            %7D%0A        %7D%0A        return str;%0A    %7D%0A%0A    @Deserialize%0A    public Query(SerializationInputStream in)%0A    throws IOException, SerializationException %7B%0A        in.readSerializableCollection(Operation.class, operations);%0A    %7D%0A%0A    @Override%0A    public void serialize(SerializationOutputStream out)%0A    throws IOException %7B%0A        out.writeSerializableCollection(operations);%0A    %7D
+/**%0A * General query interface. In SING, queries are executed against a graph%0A * (defined by its root vertex).%0A *%0A * @author malensek%0A */%0Apublic interface Query extends ByteSerializable %7B%0A%0A    public void execute(Vertex root, SerializationOutputStream out)%0A    throws IOException, QueryException;%0A
 %0A%7D%0A

Update query base interface