// Path: src/org/svetovid/io/SvetovidProcess.java
// public class SvetovidProcess {
// 
//     public final Process process;
//     public final SvetovidWriter in;
//     public final SvetovidReader out;
//     public final SvetovidReader err;
// 
//     public SvetovidProcess(Process process) {
//         this.process = process;
//         in = new DefaultSvetovidWriter(process.getOutputStream());
//         out = new DefaultSvetovidReader(process.getInputStream());
//         err = new DefaultSvetovidReader(process.getErrorStream());
//     }
// 
//     public String toString() {
//         return process.toString();
//     }
// 
//     public int waitFor() throws InterruptedException {
//         return process.waitFor();
//     }
// 
//     public boolean isAlive() {
//         try {
//             process.exitValue();
//             return false;
//         } catch(IllegalThreadStateException e) {
//             return true;
//         }
//     }
// 
//     public int exitValue() {
//         return process.exitValue();
//     }
// 
//     public void destroy() {
//         process.destroy();
//     }
// }
// 
// Path: src/org/svetovid/util/CompoundList.java
// public class CompoundList<E> extends AbstractList<E> {
// 
//     private List<List<E>> lists = new ArrayList<>();
// 
//     public CompoundList() {
//     }
// 
//     @SafeVarargs
//     public CompoundList(List<E>... lists) {
//         for (List<E> list : lists) {
//             this.lists.add(list);
//         }
//     }
// 
//     public List<E> getSublist(int index) {
//         return lists.get(index);
//     }
// 
//     public void setSublist(int index, List<E> list) {
//         lists.set(index, list);
//     }
// 
//     public int addSublist(List<E> list) {
//         lists.add(list);
//         return lists.size() - 1;
//     }
// 
//     public int insertSublist(int index, List<E> list) {
//         lists.add(index, list);
//         return index;
//     }
// 
//     public List<E> removeSublist(int index) {
//         return lists.remove(index);
//     }
// 
//     @Override
//     public int size() {
//         int size = 0;
//         for (List<E> list : lists) {
//             if (list == null) {
//                 continue;
//             }
//             size = size + list.size();
//         }
//         return size;
//     }
// 
//     @Override
//     public E get(int index) {
//         if (index < 0) {
//             throw new IndexOutOfBoundsException("Index: " + index);
//         }
//         int totalSize = 0;
//         for (List<E> list : lists) {
//             if (list == null) {
//                 continue;
//             }
//             int size = list.size();
//             if (index < size) {
//                 return list.get(index);
//             }
//             index = index - size;
//             totalSize = totalSize + size;
//         }
//         throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + totalSize);
//     }
// 
//     @Override
//     public Object[] toArray() {
//         Object[][] arrays = new Object[lists.size()][];
//         int size = 0;
//         for (int i = 0; i < lists.size(); i++) {
//             List<E> list = lists.get(i);
//             if (list == null) {
//                 continue;
//             }
//             arrays[i] = list.toArray();
//             size = size + arrays[i].length;
//         }
//         Object[] array = new Object[size];
//         int index = 0;
//         for (Object[] arr : arrays) {
//             System.arraycopy(arr, 0, array, index, arr.length);
//             index = index + arr.length;
//         }
//         return array;
//     }
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     public <T> T[] toArray(T[] a) {
//         Object[] array = toArray();
//         if (a.length < array.length) {
//             return (T[]) array;
//         }
//         System.arraycopy(array, 0, a, 0, array.length);
//         return a;
//     }
// }


import java.io.File;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.svetovid.io.SvetovidProcess;
import org.svetovid.util.CompoundList;

/*
 * Copyright 2015 Ivan Pribela
 *
 * 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.svetovid.run;



public class SvetovidJvmProcessBuilder extends SvetovidProcessBuilder {

    private List<String> executable = new ArrayList<>(1);
    {
        executable.add("java");
    }

    private List<String> classpath;
    private List<String> commandClasspath = new ArrayList<>();
    private List<String> extDirs;
    private List<String> commandExtDirs = new ArrayList<>();
    private List<String> endorsedDirs;
    private List<String> commandEndorsedDirs = new ArrayList<>();
    private List<String> libraryDirs;
    private List<String> commandLibraryDirs = new ArrayList<>();
    private Map<String, String> systemProperties = new HashMap<>();
    private List<String> commandSystemProperties = new ArrayList<>();

// Path: src/org/svetovid/io/SvetovidProcess.java
// public class SvetovidProcess {
// 
//     public final Process process;
//     public final SvetovidWriter in;
//     public final SvetovidReader out;
//     public final SvetovidReader err;
// 
//     public SvetovidProcess(Process process) {
//         this.process = process;
//         in = new DefaultSvetovidWriter(process.getOutputStream());
//         out = new DefaultSvetovidReader(process.getInputStream());
//         err = new DefaultSvetovidReader(process.getErrorStream());
//     }
// 
//     public String toString() {
//         return process.toString();
//     }
// 
//     public int waitFor() throws InterruptedException {
//         return process.waitFor();
//     }
// 
//     public boolean isAlive() {
//         try {
//             process.exitValue();
//             return false;
//         } catch(IllegalThreadStateException e) {
//             return true;
//         }
//     }
// 
//     public int exitValue() {
//         return process.exitValue();
//     }
// 
//     public void destroy() {
//         process.destroy();
//     }
// }
// 
// Path: src/org/svetovid/util/CompoundList.java
// public class CompoundList<E> extends AbstractList<E> {
// 
//     private List<List<E>> lists = new ArrayList<>();
// 
//     public CompoundList() {
//     }
// 
//     @SafeVarargs
//     public CompoundList(List<E>... lists) {
//         for (List<E> list : lists) {
//             this.lists.add(list);
//         }
//     }
// 
//     public List<E> getSublist(int index) {
//         return lists.get(index);
//     }
// 
//     public void setSublist(int index, List<E> list) {
//         lists.set(index, list);
//     }
// 
//     public int addSublist(List<E> list) {
//         lists.add(list);
//         return lists.size() - 1;
//     }
// 
//     public int insertSublist(int index, List<E> list) {
//         lists.add(index, list);
//         return index;
//     }
// 
//     public List<E> removeSublist(int index) {
//         return lists.remove(index);
//     }
// 
//     @Override
//     public int size() {
//         int size = 0;
//         for (List<E> list : lists) {
//             if (list == null) {
//                 continue;
//             }
//             size = size + list.size();
//         }
//         return size;
//     }
// 
//     @Override
//     public E get(int index) {
//         if (index < 0) {
//             throw new IndexOutOfBoundsException("Index: " + index);
//         }
//         int totalSize = 0;
//         for (List<E> list : lists) {
//             if (list == null) {
//                 continue;
//             }
//             int size = list.size();
//             if (index < size) {
//                 return list.get(index);
//             }
//             index = index - size;
//             totalSize = totalSize + size;
//         }
//         throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + totalSize);
//     }
// 
//     @Override
//     public Object[] toArray() {
//         Object[][] arrays = new Object[lists.size()][];
//         int size = 0;
//         for (int i = 0; i < lists.size(); i++) {
//             List<E> list = lists.get(i);
//             if (list == null) {
//                 continue;
//             }
//             arrays[i] = list.toArray();
//             size = size + arrays[i].length;
//         }
//         Object[] array = new Object[size];
//         int index = 0;
//         for (Object[] arr : arrays) {
//             System.arraycopy(arr, 0, array, index, arr.length);
//             index = index + arr.length;
//         }
//         return array;
//     }
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     public <T> T[] toArray(T[] a) {
//         Object[] array = toArray();
//         if (a.length < array.length) {
//             return (T[]) array;
//         }
//         System.arraycopy(array, 0, a, 0, array.length);
//         return a;
//     }
// }


// Path: src/org/svetovid/run/SvetovidJvmProcessBuilder.java
import java.io.File;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.svetovid.io.SvetovidProcess;
import org.svetovid.util.CompoundList;

/*
 * Copyright 2015 Ivan Pribela
 *
 * 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.svetovid.run;



public class SvetovidJvmProcessBuilder extends SvetovidProcessBuilder {

    private List<String> executable = new ArrayList<>(1);
    {
        executable.add("java");
    }

    private List<String> classpath;
    private List<String> commandClasspath = new ArrayList<>();
    private List<String> extDirs;
    private List<String> commandExtDirs = new ArrayList<>();
    private List<String> endorsedDirs;
    private List<String> commandEndorsedDirs = new ArrayList<>();
    private List<String> libraryDirs;
    private List<String> commandLibraryDirs = new ArrayList<>();
    private Map<String, String> systemProperties = new HashMap<>();
    private List<String> commandSystemProperties = new ArrayList<>();

    private CompoundList<String> wholeCommand = new CompoundList<String>(executable, commandClasspath, commandExtDirs, commandEndorsedDirs, commandLibraryDirs, commandSystemProperties, new ArrayList<String>(), null);
