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
syvaidya/openstego
src/main/java/com/openstego/desktop/util/cmd/PasswordInput.java
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // }
import com.openstego.desktop.OpenStegoException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;
/* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.util.cmd; /** * Utility class to handle console based password input */ public class PasswordInput { /** * Constructor is private so that this class is not instantiated */ private PasswordInput() { } /** * Method to read password from the console * * @param prompt Prompt for the password input * @return The password as entered by the user * @throws OpenStegoException Processing issue */
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // } // Path: src/main/java/com/openstego/desktop/util/cmd/PasswordInput.java import com.openstego.desktop.OpenStegoException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.util.cmd; /** * Utility class to handle console based password input */ public class PasswordInput { /** * Constructor is private so that this class is not instantiated */ private PasswordInput() { } /** * Method to read password from the console * * @param prompt Prompt for the password input * @return The password as entered by the user * @throws OpenStegoException Processing issue */
public static String readPassword(String prompt) throws OpenStegoException {
syvaidya/openstego
src/main/java/com/openstego/desktop/plugin/dwtxie/DWTXieErrors.java
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // }
import com.openstego.desktop.OpenStegoException;
/* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.plugin.dwtxie; /** * Class to store error codes for DWT Xie plugin */ public class DWTXieErrors { /** * Error Code - No cover file given */ public static final int ERR_NO_COVER_FILE = 1; /** * Error Code - Invalid signature file provided */ public static final int ERR_SIG_NOT_VALID = 2; /** * Initialize the error code - message key map */ public static void init() {
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // } // Path: src/main/java/com/openstego/desktop/plugin/dwtxie/DWTXieErrors.java import com.openstego.desktop.OpenStegoException; /* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.plugin.dwtxie; /** * Class to store error codes for DWT Xie plugin */ public class DWTXieErrors { /** * Error Code - No cover file given */ public static final int ERR_NO_COVER_FILE = 1; /** * Error Code - Invalid signature file provided */ public static final int ERR_SIG_NOT_VALID = 2; /** * Initialize the error code - message key map */ public static void init() {
OpenStegoException.addErrorCode(DWTXiePlugin.NAMESPACE, ERR_NO_COVER_FILE, "err.cover.missing");
syvaidya/openstego
src/main/java/com/openstego/desktop/plugin/dctlsb/DctLSBErrors.java
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // }
import com.openstego.desktop.OpenStegoException;
/* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.plugin.dctlsb; /** * Class to store error codes for DCT LSB plugin */ public class DctLSBErrors { /** * Error Code - Error while reading image data */ public static final int ERR_IMAGE_DATA_READ = 1; /** * Error Code - Image size insufficient for data */ public static final int IMAGE_SIZE_INSUFFICIENT = 2; /** * Initialize the error code - message key map */ public static void init() {
// Path: src/main/java/com/openstego/desktop/OpenStegoException.java // public class OpenStegoException extends Exception { // private static final long serialVersionUID = 668241029491685413L; // // /** // * Error Code - Unhandled exception // */ // static final int UNHANDLED_EXCEPTION = 0; // // /** // * Map to store error code to message key mapping // */ // private static final Map<String, String> errMsgKeyMap = new HashMap<>(); // // /** // * Error code for the exception // */ // private final int errorCode; // // /** // * Namespace for the exception // */ // private final String namespace; // // /** // * Constructor using default namespace for unhandled exceptions // * // * @param cause Original exception which caused this exception to be raised // */ // public OpenStegoException(Throwable cause) { // this(cause, OpenStego.NAMESPACE, UNHANDLED_EXCEPTION, (Object[]) null); // } // // /** // * Default constructor // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode) { // this(cause, namespace, errorCode, (Object[]) null); // } // // /** // * Constructor with a single parameter for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param param Parameter for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, String param) { // this(cause, namespace, errorCode, new Object[]{param}); // } // // /** // * Constructor which takes object array for parameters for the message // * // * @param cause Original exception which caused this exception to be raised // * @param namespace Namespace of the error // * @param errorCode Error code for the exception // * @param params Parameters for exception message // */ // public OpenStegoException(Throwable cause, String namespace, int errorCode, Object... params) { // super((OpenStego.NAMESPACE.equals(namespace) && errorCode == UNHANDLED_EXCEPTION) ? cause.toString() // : LabelUtil.getInstance(namespace).getString(errMsgKeyMap.get(namespace + errorCode), params), cause); // // this.namespace = namespace; // this.errorCode = errorCode; // } // // /** // * Get method for errorCode // * // * @return errorCode // */ // public int getErrorCode() { // return this.errorCode; // } // // /** // * Get method for namespace // * // * @return namespace // */ // public String getNamespace() { // return this.namespace; // } // // /** // * Method to add new error codes to the namespace // * // * @param namespace Namespace for the error // * @param errorCode Error code of the error // * @param labelKey Key of the label for the error // */ // public static void addErrorCode(String namespace, int errorCode, String labelKey) { // errMsgKeyMap.put(namespace + errorCode, labelKey); // } // } // Path: src/main/java/com/openstego/desktop/plugin/dctlsb/DctLSBErrors.java import com.openstego.desktop.OpenStegoException; /* * Steganography utility to hide messages into cover files * Author: Samir Vaidya (mailto:syvaidya@gmail.com) * Copyright (c) Samir Vaidya */ package com.openstego.desktop.plugin.dctlsb; /** * Class to store error codes for DCT LSB plugin */ public class DctLSBErrors { /** * Error Code - Error while reading image data */ public static final int ERR_IMAGE_DATA_READ = 1; /** * Error Code - Image size insufficient for data */ public static final int IMAGE_SIZE_INSUFFICIENT = 2; /** * Initialize the error code - message key map */ public static void init() {
OpenStegoException.addErrorCode(DctLSBPlugin.NAMESPACE, ERR_IMAGE_DATA_READ, "err.image.read");
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/operation/HierarchyWrapper.java
// Path: sorter/src/main/java/sortpom/wrapper/content/SingleNewlineInTextWrapper.java // public final class SingleNewlineInTextWrapper implements Wrapper<Content> { // public static final SingleNewlineInTextWrapper INSTANCE = new SingleNewlineInTextWrapper(); // // /** Instantiates a new wrapper, whose content will be thrown away. */ // private SingleNewlineInTextWrapper() { // } // // @Override // public Text getContent() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isContentElement() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isSortable() { // throw new UnsupportedOperationException(); // } // // @Override // public String toString() { // return "SingleNewlineInTextWrapper"; // } // } // // Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // }
import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.SingleNewlineInTextWrapper; import sortpom.wrapper.content.Wrapper; import java.util.ArrayList; import java.util.List;
package sortpom.wrapper.operation; /** * Aggregates a number of wrappers, so that they can be treated as a recursive hierarchy. * * @author Bjorn */ class HierarchyWrapper { private Wrapper<Element> elementContent; private final List<Wrapper<Content>> otherContentList = new ArrayList<>(); private final List<HierarchyWrapper> children = new ArrayList<>(); HierarchyWrapper(final Wrapper<? extends Content> wrapper) { addContent(wrapper); } @SuppressWarnings("unchecked") private void addContent(final Wrapper<? extends Content> wrapper) { if (wrapper.isContentElement()) { elementContent = (Wrapper<Element>) wrapper; } else { otherContentList.add((Wrapper<Content>) wrapper); } } /** Traverses the initial xml element wrapper and builds hierarchy */ void createWrappedStructure(final WrapperFactory factory) { HierarchyWrapper currentWrapper = null; for (Content child : castToContentList(elementContent)) { Wrapper<?> wrapper = factory.create(child);
// Path: sorter/src/main/java/sortpom/wrapper/content/SingleNewlineInTextWrapper.java // public final class SingleNewlineInTextWrapper implements Wrapper<Content> { // public static final SingleNewlineInTextWrapper INSTANCE = new SingleNewlineInTextWrapper(); // // /** Instantiates a new wrapper, whose content will be thrown away. */ // private SingleNewlineInTextWrapper() { // } // // @Override // public Text getContent() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isContentElement() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isSortable() { // throw new UnsupportedOperationException(); // } // // @Override // public String toString() { // return "SingleNewlineInTextWrapper"; // } // } // // Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // } // Path: sorter/src/main/java/sortpom/wrapper/operation/HierarchyWrapper.java import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.SingleNewlineInTextWrapper; import sortpom.wrapper.content.Wrapper; import java.util.ArrayList; import java.util.List; package sortpom.wrapper.operation; /** * Aggregates a number of wrappers, so that they can be treated as a recursive hierarchy. * * @author Bjorn */ class HierarchyWrapper { private Wrapper<Element> elementContent; private final List<Wrapper<Content>> otherContentList = new ArrayList<>(); private final List<HierarchyWrapper> children = new ArrayList<>(); HierarchyWrapper(final Wrapper<? extends Content> wrapper) { addContent(wrapper); } @SuppressWarnings("unchecked") private void addContent(final Wrapper<? extends Content> wrapper) { if (wrapper.isContentElement()) { elementContent = (Wrapper<Element>) wrapper; } else { otherContentList.add((Wrapper<Content>) wrapper); } } /** Traverses the initial xml element wrapper and builds hierarchy */ void createWrappedStructure(final WrapperFactory factory) { HierarchyWrapper currentWrapper = null; for (Content child : castToContentList(elementContent)) { Wrapper<?> wrapper = factory.create(child);
if (wrapper instanceof SingleNewlineInTextWrapper) {
Ekryd/sortpom
sorter/src/test/java/sortpom/wrapper/SingleNewlineInTextWrapperTest.java
// Path: sorter/src/main/java/sortpom/wrapper/content/SingleNewlineInTextWrapper.java // public final class SingleNewlineInTextWrapper implements Wrapper<Content> { // public static final SingleNewlineInTextWrapper INSTANCE = new SingleNewlineInTextWrapper(); // // /** Instantiates a new wrapper, whose content will be thrown away. */ // private SingleNewlineInTextWrapper() { // } // // @Override // public Text getContent() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isContentElement() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isSortable() { // throw new UnsupportedOperationException(); // } // // @Override // public String toString() { // return "SingleNewlineInTextWrapper"; // } // }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.wrapper.content.SingleNewlineInTextWrapper; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.jupiter.api.Assertions.assertThrows;
package sortpom.wrapper; /** * All method should throw exception since the element should be throw away, except for the toString method * * @author bjorn * @since 2012-06-14 */ class SingleNewlineInTextWrapperTest { @Test void testGetContent() {
// Path: sorter/src/main/java/sortpom/wrapper/content/SingleNewlineInTextWrapper.java // public final class SingleNewlineInTextWrapper implements Wrapper<Content> { // public static final SingleNewlineInTextWrapper INSTANCE = new SingleNewlineInTextWrapper(); // // /** Instantiates a new wrapper, whose content will be thrown away. */ // private SingleNewlineInTextWrapper() { // } // // @Override // public Text getContent() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isContentElement() { // throw new UnsupportedOperationException(); // } // // @Override // public boolean isSortable() { // throw new UnsupportedOperationException(); // } // // @Override // public String toString() { // return "SingleNewlineInTextWrapper"; // } // } // Path: sorter/src/test/java/sortpom/wrapper/SingleNewlineInTextWrapperTest.java import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.wrapper.content.SingleNewlineInTextWrapper; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.jupiter.api.Assertions.assertThrows; package sortpom.wrapper; /** * All method should throw exception since the element should be throw away, except for the toString method * * @author bjorn * @since 2012-06-14 */ class SingleNewlineInTextWrapperTest { @Test void testGetContent() {
final Executable testMethod = () -> SingleNewlineInTextWrapper.INSTANCE.getContent();
Ekryd/sortpom
sorter/src/main/java/sortpom/parameter/VerifyFailOnType.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import sortpom.exception.FailureException; import java.util.Arrays;
package sortpom.parameter; public enum VerifyFailOnType { XMLELEMENTS, STRICT; static VerifyFailOnType fromString(String verifyFailOn) { if (verifyFailOn == null) {
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/main/java/sortpom/parameter/VerifyFailOnType.java import sortpom.exception.FailureException; import java.util.Arrays; package sortpom.parameter; public enum VerifyFailOnType { XMLELEMENTS, STRICT; static VerifyFailOnType fromString(String verifyFailOn) { if (verifyFailOn == null) {
throw new FailureException("verifyFailOn must be either xmlElements or strict. Was: null");
Ekryd/sortpom
sorter/src/main/java/sortpom/parameter/VerifyFailType.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import sortpom.exception.FailureException;
package sortpom.parameter; /** * @author bjorn * @since 2012-08-11 */ public enum VerifyFailType { SORT, WARN, STOP; static VerifyFailType fromString(String verifyFail) { if (verifyFail == null) {
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/main/java/sortpom/parameter/VerifyFailType.java import sortpom.exception.FailureException; package sortpom.parameter; /** * @author bjorn * @since 2012-08-11 */ public enum VerifyFailType { SORT, WARN, STOP; static VerifyFailType fromString(String verifyFail) { if (verifyFail == null) {
throw new FailureException("verifyFail must be either SORT, WARN or STOP. Was: null");
Ekryd/sortpom
sorter/src/test/java/sortpom/parameter/IndentCharactersParameterTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue;
assertEquals(" ", pluginParameters.indentCharacters); } @Test void test255IndentCharacterShouldResultIn255Space() { PluginParameters pluginParameters = PluginParameters.builder() .setIndent(255, true, false) .build(); // Test for only space assertTrue(pluginParameters.indentCharacters.matches("^ *$")); assertEquals(255, pluginParameters.indentCharacters.length()); } @Test void minusOneIndentCharacterShouldResultInOneTab() { PluginParameters pluginParameters = PluginParameters.builder() .setIndent(-1, true, false) .build(); assertEquals("\t", pluginParameters.indentCharacters); } @Test void minusTwoShouldFail() { final Executable testMethod = () -> PluginParameters.builder() .setIndent(-2, true, false) .build();
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/test/java/sortpom/parameter/IndentCharactersParameterTest.java import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; assertEquals(" ", pluginParameters.indentCharacters); } @Test void test255IndentCharacterShouldResultIn255Space() { PluginParameters pluginParameters = PluginParameters.builder() .setIndent(255, true, false) .build(); // Test for only space assertTrue(pluginParameters.indentCharacters.matches("^ *$")); assertEquals(255, pluginParameters.indentCharacters.length()); } @Test void minusOneIndentCharacterShouldResultInOneTab() { PluginParameters pluginParameters = PluginParameters.builder() .setIndent(-1, true, false) .build(); assertEquals("\t", pluginParameters.indentCharacters); } @Test void minusTwoShouldFail() { final Executable testMethod = () -> PluginParameters.builder() .setIndent(-2, true, false) .build();
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/ElementSortOrderMap.java
// Path: sorter/src/main/java/sortpom/wrapper/ElementUtil.java // static String getDeepName(final Element element) { // if (element == null) { // return ""; // } // return getDeepName(element.getParentElement()) + '/' + element.getName(); // }
import org.jdom.Element; import java.util.HashMap; import java.util.Map; import static sortpom.wrapper.ElementUtil.getDeepName;
package sortpom.wrapper; /** * All elements from the chosen sort order (from predefined sort order or custom sort order) are placed in this map * along with an index that describes in which order the elements should be sorted. */ class ElementSortOrderMap { /** Contains sort order element names and their index. */ private final Map<String, Integer> elementNameSortOrderMap = new HashMap<>(); /** * Add an Xml element to the map * * @param element Xml element * @param sortOrder an index describing the sort order (lower number == element towards the start of the file) */ public void addElement(Element element, int sortOrder) {
// Path: sorter/src/main/java/sortpom/wrapper/ElementUtil.java // static String getDeepName(final Element element) { // if (element == null) { // return ""; // } // return getDeepName(element.getParentElement()) + '/' + element.getName(); // } // Path: sorter/src/main/java/sortpom/wrapper/ElementSortOrderMap.java import org.jdom.Element; import java.util.HashMap; import java.util.Map; import static sortpom.wrapper.ElementUtil.getDeepName; package sortpom.wrapper; /** * All elements from the chosen sort order (from predefined sort order or custom sort order) are placed in this map * along with an index that describes in which order the elements should be sorted. */ class ElementSortOrderMap { /** Contains sort order element names and their index. */ private final Map<String, Integer> elementNameSortOrderMap = new HashMap<>(); /** * Add an Xml element to the map * * @param element Xml element * @param sortOrder an index describing the sort order (lower number == element towards the start of the file) */ public void addElement(Element element, int sortOrder) {
final String deepName = getDeepName(element);
Ekryd/sortpom
sorter/src/test/java/sortpom/util/FileUtilExceptionsTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import refutils.ReflectionHelper; import sortpom.exception.FailureException; import java.io.File; import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy;
package sortpom.util; class FileUtilExceptionsTest { private File backupFileTemp; private File pomFileTemp; @BeforeEach void setup() throws IOException { pomFileTemp = File.createTempFile("pom", ".xml", new File("target")); pomFileTemp.deleteOnExit(); backupFileTemp = File.createTempFile("backupFile", ".xml", new File("target")); backupFileTemp.deleteOnExit(); } @Test void whenOldBackupFileCannotBeDeletedAnExceptionShouldBeThrown() { FileUtil fileUtil = createFileUtil(); doNotAccessRealBackupFile(fileUtil); //Set backup file to a directory (which raises DirectoryNotEmptyException) new ReflectionHelper(fileUtil).setField("backupFile", backupFileTemp.getParentFile()); final Executable testMethod = fileUtil::backupFile;
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/test/java/sortpom/util/FileUtilExceptionsTest.java import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import refutils.ReflectionHelper; import sortpom.exception.FailureException; import java.io.File; import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; package sortpom.util; class FileUtilExceptionsTest { private File backupFileTemp; private File pomFileTemp; @BeforeEach void setup() throws IOException { pomFileTemp = File.createTempFile("pom", ".xml", new File("target")); pomFileTemp.deleteOnExit(); backupFileTemp = File.createTempFile("backupFile", ".xml", new File("target")); backupFileTemp.deleteOnExit(); } @Test void whenOldBackupFileCannotBeDeletedAnExceptionShouldBeThrown() { FileUtil fileUtil = createFileUtil(); doNotAccessRealBackupFile(fileUtil); //Set backup file to a directory (which raises DirectoryNotEmptyException) new ReflectionHelper(fileUtil).setField("backupFile", backupFileTemp.getParentFile()); final Executable testMethod = fileUtil::backupFile;
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/test/java/sortpom/parameter/VerifyFailOnTypeTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows;
package sortpom.parameter; /** * */ class VerifyFailOnTypeTest { @Test void xmlElementsIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("STOP", "XMLElements") .build(); assertEquals(VerifyFailOnType.XMLELEMENTS, pluginParameters.verifyFailOn); } @Test void strictIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("STOP", "stRIct") .build(); assertEquals(VerifyFailOnType.STRICT, pluginParameters.verifyFailOn); } @ParameterizedTest @NullAndEmptySource @ValueSource(strings = "gurka") void verifyFailFaultyValues(String value) { final Executable testMethod = () -> PluginParameters.builder() .setVerifyFail("STOP", value) .build();
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/test/java/sortpom/parameter/VerifyFailOnTypeTest.java import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; package sortpom.parameter; /** * */ class VerifyFailOnTypeTest { @Test void xmlElementsIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("STOP", "XMLElements") .build(); assertEquals(VerifyFailOnType.XMLELEMENTS, pluginParameters.verifyFailOn); } @Test void strictIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("STOP", "stRIct") .build(); assertEquals(VerifyFailOnType.STRICT, pluginParameters.verifyFailOn); } @ParameterizedTest @NullAndEmptySource @ValueSource(strings = "gurka") void verifyFailFaultyValues(String value) { final Executable testMethod = () -> PluginParameters.builder() .setVerifyFail("STOP", value) .build();
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/test/java/sortpom/parameter/LineSeparatorParameterTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import sortpom.exception.FailureException; import java.util.stream.Stream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows;
package sortpom.parameter; class LineSeparatorParameterTest { @Test void lineSeparatorWithSomethingElseShouldThrowException() { final Executable testMethod = () -> PluginParameters.builder() .setEncoding("UTF-8") .setFormatting("***", false, true, false) .setIndent(2, false, false);
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/test/java/sortpom/parameter/LineSeparatorParameterTest.java import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import sortpom.exception.FailureException; import java.util.stream.Stream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; package sortpom.parameter; class LineSeparatorParameterTest { @Test void lineSeparatorWithSomethingElseShouldThrowException() { final Executable testMethod = () -> PluginParameters.builder() .setEncoding("UTF-8") .setFormatting("***", false, true, false) .setIndent(2, false, false);
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/test/java/sortpom/processinstruction/XmlProcessingInstructionParserTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // }
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions;
package sortpom.processinstruction; /** * @author bjorn * @since 2013-12-28 */ class XmlProcessingInstructionParserTest { private XmlProcessingInstructionParser parser;
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // Path: sorter/src/test/java/sortpom/processinstruction/XmlProcessingInstructionParserTest.java import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; package sortpom.processinstruction; /** * @author bjorn * @since 2013-12-28 */ class XmlProcessingInstructionParserTest { private XmlProcessingInstructionParser parser;
private final SortPomLogger logger = mock(SortPomLogger.class);
Ekryd/sortpom
sorter/src/test/java/sortpom/processinstruction/XmlProcessingInstructionParserTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // }
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions;
parser = new XmlProcessingInstructionParser(); parser.setup(logger); } @Test void multipleErrorsShouldBeReportedInLogger() { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + " <artifactId>sortpom</artifactId>\n" + " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n" + " <groupId>sortpom</groupId>\n" + " <modelVersion>4.0.0</modelVersion>\n" + " <name>SortPom</name>\n" + " <!-- Egenskaper för projektet -->\n" + " <properties>\n" + " <?sortpom resume?>" + "<compileSource>1.6</compileSource>\n" + " <?sortpom ignore?>" + " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" + " <?sortpom resume?>" + " </properties>\n" + " <?sortpom token='0'?>" + " <?sortpom gurka?>" + " <reporting />\n" + " <?sortpom ignore?>" + " <version>1.0.0-SNAPSHOT</version>\n" + "</project>"; final Executable testMethod = () -> parser.scanForIgnoredSections(xml);
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // Path: sorter/src/test/java/sortpom/processinstruction/XmlProcessingInstructionParserTest.java import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; parser = new XmlProcessingInstructionParser(); parser.setup(logger); } @Test void multipleErrorsShouldBeReportedInLogger() { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + " <artifactId>sortpom</artifactId>\n" + " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n" + " <groupId>sortpom</groupId>\n" + " <modelVersion>4.0.0</modelVersion>\n" + " <name>SortPom</name>\n" + " <!-- Egenskaper för projektet -->\n" + " <properties>\n" + " <?sortpom resume?>" + "<compileSource>1.6</compileSource>\n" + " <?sortpom ignore?>" + " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" + " <?sortpom resume?>" + " </properties>\n" + " <?sortpom token='0'?>" + " <?sortpom gurka?>" + " <reporting />\n" + " <?sortpom ignore?>" + " <version>1.0.0-SNAPSHOT</version>\n" + "</project>"; final Executable testMethod = () -> parser.scanForIgnoredSections(xml);
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/content/ExecutionSortedWrapper.java
// Path: sorter/src/main/java/sortpom/wrapper/content/Phase.java // static int compareTo(Phase o1, Phase o2) { // if (o1 == null) { // if (o2 == null) { // return 0; // } // return -1; // } // if (o2 == null) { // return 1; // } // if (o1 instanceof NonStandardPhase) { // if (o2 instanceof NonStandardPhase) { // return o1.getText().compareTo(o2.getText()); // } else { // return 1; // } // } // StandardPhase so1 = (StandardPhase) o1; // if (o2 instanceof NonStandardPhase) { // return -1; // } // return so1.compareTo((StandardPhase) o2); // }
import org.jdom.Content; import org.jdom.Element; import java.util.List; import static sortpom.wrapper.content.Phase.compareTo;
package sortpom.wrapper.content; /** * A wrapper that contains a execution element. The element is sorted according to: * 1 no phase and no id * 2 no phase and id (sorted by id value) * 3 standard phase and no id (sorted by Maven phase order) * 4 standard phase and id (sorted by Maven phase order and then id value) * 5 other phase and no id (sorted by phase value) * 6 other phase and id (sorted by phase value and then id value) */ public class ExecutionSortedWrapper extends SortedWrapper { private final Phase phase; private final String id; /** * Instantiates a new child element sorted wrapper with a plugin element. * * @param element the element * @param sortOrder the sort order */ public ExecutionSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); @SuppressWarnings("unchecked") List<Element> children = getContent().getChildren(); phase = children.stream() .filter(e -> e.getName().equals("phase") && e.getText() != null) .map(e -> Phase.getPhase(e.getTextTrim())) .findFirst() .orElse(null); id = children.stream() .filter(e -> e.getName().equals("id")) .map(Element::getTextTrim) .findFirst() .orElse(""); } @Override public boolean isBefore(final Wrapper<? extends Content> wrapper) { if (wrapper instanceof ExecutionSortedWrapper) { return isBeforeWrapper((ExecutionSortedWrapper) wrapper); } return super.isBefore(wrapper); } private boolean isBeforeWrapper(final ExecutionSortedWrapper wrapper) {
// Path: sorter/src/main/java/sortpom/wrapper/content/Phase.java // static int compareTo(Phase o1, Phase o2) { // if (o1 == null) { // if (o2 == null) { // return 0; // } // return -1; // } // if (o2 == null) { // return 1; // } // if (o1 instanceof NonStandardPhase) { // if (o2 instanceof NonStandardPhase) { // return o1.getText().compareTo(o2.getText()); // } else { // return 1; // } // } // StandardPhase so1 = (StandardPhase) o1; // if (o2 instanceof NonStandardPhase) { // return -1; // } // return so1.compareTo((StandardPhase) o2); // } // Path: sorter/src/main/java/sortpom/wrapper/content/ExecutionSortedWrapper.java import org.jdom.Content; import org.jdom.Element; import java.util.List; import static sortpom.wrapper.content.Phase.compareTo; package sortpom.wrapper.content; /** * A wrapper that contains a execution element. The element is sorted according to: * 1 no phase and no id * 2 no phase and id (sorted by id value) * 3 standard phase and no id (sorted by Maven phase order) * 4 standard phase and id (sorted by Maven phase order and then id value) * 5 other phase and no id (sorted by phase value) * 6 other phase and id (sorted by phase value and then id value) */ public class ExecutionSortedWrapper extends SortedWrapper { private final Phase phase; private final String id; /** * Instantiates a new child element sorted wrapper with a plugin element. * * @param element the element * @param sortOrder the sort order */ public ExecutionSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); @SuppressWarnings("unchecked") List<Element> children = getContent().getChildren(); phase = children.stream() .filter(e -> e.getName().equals("phase") && e.getText() != null) .map(e -> Phase.getPhase(e.getTextTrim())) .findFirst() .orElse(null); id = children.stream() .filter(e -> e.getName().equals("id")) .map(Element::getTextTrim) .findFirst() .orElse(""); } @Override public boolean isBefore(final Wrapper<? extends Content> wrapper) { if (wrapper instanceof ExecutionSortedWrapper) { return isBeforeWrapper((ExecutionSortedWrapper) wrapper); } return super.isBefore(wrapper); } private boolean isBeforeWrapper(final ExecutionSortedWrapper wrapper) {
int compare = compareTo(phase, wrapper.phase);
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/operation/GetContentStructureOperation.java
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // }
import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.Wrapper;
package sortpom.wrapper.operation; /** * Xml hierarchy operation that returns xml content from wrappers. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * @author bjorn * @since 2013-11-02 */ class GetContentStructureOperation implements HierarchyWrapperOperation { private Element activeElement; private final Element parentElement; /** Initial element does not have any parent */ GetContentStructureOperation() { this.parentElement = null; } private GetContentStructureOperation(Element parentElement) { this.parentElement = parentElement; } /** Add all 'other content' to the parent xml element */ @Override
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // } // Path: sorter/src/main/java/sortpom/wrapper/operation/GetContentStructureOperation.java import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.Wrapper; package sortpom.wrapper.operation; /** * Xml hierarchy operation that returns xml content from wrappers. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * @author bjorn * @since 2013-11-02 */ class GetContentStructureOperation implements HierarchyWrapperOperation { private Element activeElement; private final Element parentElement; /** Initial element does not have any parent */ GetContentStructureOperation() { this.parentElement = null; } private GetContentStructureOperation(Element parentElement) { this.parentElement = parentElement; } /** Add all 'other content' to the parent xml element */ @Override
public void processOtherContent(Wrapper<Content> content) {
Ekryd/sortpom
sorter/src/main/java/sortpom/processinstruction/XmlProcessingInstructionParser.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // }
import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger;
package sortpom.processinstruction; /** * Handling for xml processing instructions in the pom file. Supports ignore and resume * * @author bjorn * @since 2013-12-28 */ public class XmlProcessingInstructionParser { private final IgnoredSectionsStore ignoredSectionsStore = new IgnoredSectionsStore(); private String originalXml;
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // Path: sorter/src/main/java/sortpom/processinstruction/XmlProcessingInstructionParser.java import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; package sortpom.processinstruction; /** * Handling for xml processing instructions in the pom file. Supports ignore and resume * * @author bjorn * @since 2013-12-28 */ public class XmlProcessingInstructionParser { private final IgnoredSectionsStore ignoredSectionsStore = new IgnoredSectionsStore(); private String originalXml;
private SortPomLogger logger;
Ekryd/sortpom
sorter/src/main/java/sortpom/processinstruction/XmlProcessingInstructionParser.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // }
import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger;
package sortpom.processinstruction; /** * Handling for xml processing instructions in the pom file. Supports ignore and resume * * @author bjorn * @since 2013-12-28 */ public class XmlProcessingInstructionParser { private final IgnoredSectionsStore ignoredSectionsStore = new IgnoredSectionsStore(); private String originalXml; private SortPomLogger logger; private boolean containsIgnoredSections = false; public void setup(SortPomLogger logger) { this.logger = logger; } /** Checks if pom file contains any processing instructions */ public void scanForIgnoredSections(String originalXml) { this.originalXml = originalXml; SortpomPiScanner sortpomPiScanner = new SortpomPiScanner(logger); sortpomPiScanner.scan(originalXml); if (sortpomPiScanner.isScanError()) {
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // // Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // Path: sorter/src/main/java/sortpom/processinstruction/XmlProcessingInstructionParser.java import sortpom.exception.FailureException; import sortpom.logger.SortPomLogger; package sortpom.processinstruction; /** * Handling for xml processing instructions in the pom file. Supports ignore and resume * * @author bjorn * @since 2013-12-28 */ public class XmlProcessingInstructionParser { private final IgnoredSectionsStore ignoredSectionsStore = new IgnoredSectionsStore(); private String originalXml; private SortPomLogger logger; private boolean containsIgnoredSections = false; public void setup(SortPomLogger logger) { this.logger = logger; } /** Checks if pom file contains any processing instructions */ public void scanForIgnoredSections(String originalXml) { this.originalXml = originalXml; SortpomPiScanner sortpomPiScanner = new SortpomPiScanner(logger); sortpomPiScanner.scan(originalXml); if (sortpomPiScanner.isScanError()) {
throw new FailureException(sortpomPiScanner.getFirstError());
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/content/PluginSortedWrapper.java
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // }
import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List;
package sortpom.wrapper.content; /** * A wrapper that contains a plugin element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class PluginSortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a plugin element. * * @param element the element * @param sortOrder the sort order */ public PluginSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // } // Path: sorter/src/main/java/sortpom/wrapper/content/PluginSortedWrapper.java import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List; package sortpom.wrapper.content; /** * A wrapper that contains a plugin element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class PluginSortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a plugin element. * * @param element the element * @param sortOrder the sort order */ public PluginSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
public void setSortOrder(DependencySortOrder dependencySortOrder) {
Ekryd/sortpom
sorter/src/main/java/sortpom/processinstruction/SortpomPiScanner.java
// Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // // Path: sorter/src/main/java/sortpom/processinstruction/InstructionType.java // enum InstructionType { // IGNORE, RESUME; // // /** non-xml compliant pattern, see http://www.cs.sfu.ca/~cameron/REX.html#IV.2 */ // static final Pattern INSTRUCTION_PATTERN = Pattern.compile("(?i)<\\?sortpom\\s+([\\w\"'*= ]*)\\s*\\?>"); // static final Pattern IGNORE_SECTIONS_PATTERN = Pattern.compile( // "(?is)<\\?sortpom\\s+" + IGNORE + "\\s*\\?>.*?<\\?sortpom\\s+" + RESUME + "\\s*\\?>"); // static final Pattern TOKEN_PATTERN = Pattern.compile("(?i)<\\?sortpom\\s+token='(\\d+)'\\s*\\?>"); // // public InstructionType next() { // if (this == IGNORE) { // return RESUME; // } // return IGNORE; // } // // public static boolean containsType(String instruction) { // return IGNORE.name().equalsIgnoreCase(instruction) || RESUME.name().equalsIgnoreCase(instruction); // } // // public boolean matches(String instruction) { // return this.name().equalsIgnoreCase(instruction); // } // }
import sortpom.logger.SortPomLogger; import java.util.regex.Matcher; import static sortpom.processinstruction.InstructionType.*;
package sortpom.processinstruction; /** * Check the pom file for processing instructions and verifies that they are correct and balanced * * @author bjorn * @since 2013-12-28 */ class SortpomPiScanner { private final SortPomLogger logger;
// Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // // Path: sorter/src/main/java/sortpom/processinstruction/InstructionType.java // enum InstructionType { // IGNORE, RESUME; // // /** non-xml compliant pattern, see http://www.cs.sfu.ca/~cameron/REX.html#IV.2 */ // static final Pattern INSTRUCTION_PATTERN = Pattern.compile("(?i)<\\?sortpom\\s+([\\w\"'*= ]*)\\s*\\?>"); // static final Pattern IGNORE_SECTIONS_PATTERN = Pattern.compile( // "(?is)<\\?sortpom\\s+" + IGNORE + "\\s*\\?>.*?<\\?sortpom\\s+" + RESUME + "\\s*\\?>"); // static final Pattern TOKEN_PATTERN = Pattern.compile("(?i)<\\?sortpom\\s+token='(\\d+)'\\s*\\?>"); // // public InstructionType next() { // if (this == IGNORE) { // return RESUME; // } // return IGNORE; // } // // public static boolean containsType(String instruction) { // return IGNORE.name().equalsIgnoreCase(instruction) || RESUME.name().equalsIgnoreCase(instruction); // } // // public boolean matches(String instruction) { // return this.name().equalsIgnoreCase(instruction); // } // } // Path: sorter/src/main/java/sortpom/processinstruction/SortpomPiScanner.java import sortpom.logger.SortPomLogger; import java.util.regex.Matcher; import static sortpom.processinstruction.InstructionType.*; package sortpom.processinstruction; /** * Check the pom file for processing instructions and verifies that they are correct and balanced * * @author bjorn * @since 2013-12-28 */ class SortpomPiScanner { private final SortPomLogger logger;
private InstructionType expectedNextInstruction = IGNORE;
Ekryd/sortpom
sorter/src/test/java/sortpom/sort/XmlProcessorTest.java
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // }
import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil;
package sortpom.sort; class XmlProcessorTest { @Test final void testSortXmlAttributes() throws Exception {
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // } // Path: sorter/src/test/java/sortpom/sort/XmlProcessorTest.java import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil; package sortpom.sort; class XmlProcessorTest { @Test final void testSortXmlAttributes() throws Exception {
XmlProcessorTestUtil.create()
Ekryd/sortpom
sorter/src/test/java/sortpom/processinstruction/SortpomPiScannerTest.java
// Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // }
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions;
package sortpom.processinstruction; /** * @author bjorn * @since 2013-12-28 */ class SortpomPiScannerTest { private SortpomPiScanner sortpomPiScanner;
// Path: sorter/src/main/java/sortpom/logger/SortPomLogger.java // public interface SortPomLogger { // /** // * Send a message to the log in the <b>warn</b> error level. // * // * @param content warning message // */ // void warn(String content); // // /** // * Send a message to the log in the <b>info</b> error level. // * // * @param content info message // */ // void info(String content); // // /** // * Send a message to the log in the <b>error</b> error level. // * // * @param content error message // */ // void error(String content); // } // Path: sorter/src/test/java/sortpom/processinstruction/SortpomPiScannerTest.java import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sortpom.logger.SortPomLogger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; package sortpom.processinstruction; /** * @author bjorn * @since 2013-12-28 */ class SortpomPiScannerTest { private SortpomPiScanner sortpomPiScanner;
private final SortPomLogger logger = mock(SortPomLogger.class);
Ekryd/sortpom
sorter/src/main/java/sortpom/verify/ElementComparator.java
// Path: sorter/src/main/java/sortpom/util/XmlOrderedResult.java // public final class XmlOrderedResult { // private final boolean ordered; // private final String errorMessage; // // private XmlOrderedResult(boolean ordered, String errorMessage) { // this.ordered = ordered; // this.errorMessage = errorMessage; // } // // /** pom file was ordered */ // public static XmlOrderedResult ordered() { // return new XmlOrderedResult(true, ""); // } // // /** The xml elements was not in the right order */ // public static XmlOrderedResult nameDiffers(String originalElementName, String newElementName) { // return new XmlOrderedResult(false, String.format("The xml element <%s> should be placed before <%s>", // newElementName, originalElementName)); // } // // /** The child elements of two elements differ. Example: When dependencies should be sorted */ // public static XmlOrderedResult childElementDiffers(String name, int originalSize, int newSize) { // return new XmlOrderedResult(false, String.format( // "The xml element <%s> with %s child elements should be placed before element <%s> with %s child elements", // name, newSize, name, originalSize)); // } // // /** The texts inside two elements differ. Example: when maven properties should be sorted */ // public static XmlOrderedResult textContentDiffers(String name, String originalElementText, String newElementText) { // return new XmlOrderedResult(false, String.format("The xml element <%s>%s</%s> should be placed before <%s>%s</%s>", // name, newElementText, name, name, originalElementText, name)); // } // // public static XmlOrderedResult lineDiffers(int lineNumber, String sortedXmlLine) { // return new XmlOrderedResult(false, String.format("The line %d is not considered sorted, should be %s", // lineNumber, sortedXmlLine)); // } // // public static XmlOrderedResult lineSeparatorCharactersDiffer() { // return new XmlOrderedResult(false, "The line separator characters differ from sorted pom"); // } // // /** Returns true when verification tells that the pom file was sorted */ // public boolean isOrdered() { // return ordered; // } // // /** An error message that describes what went wrong with the verification operation */ // public String getErrorMessage() { // return errorMessage; // } // // }
import org.jdom.Element; import sortpom.util.XmlOrderedResult; import java.util.List;
package sortpom.verify; /** * @author bjorn * @since 2012-07-01 */ public class ElementComparator { private final Element originalElement; private final Element newElement; public ElementComparator(Element originalElement, Element newElement) { this.originalElement = originalElement; this.newElement = newElement; }
// Path: sorter/src/main/java/sortpom/util/XmlOrderedResult.java // public final class XmlOrderedResult { // private final boolean ordered; // private final String errorMessage; // // private XmlOrderedResult(boolean ordered, String errorMessage) { // this.ordered = ordered; // this.errorMessage = errorMessage; // } // // /** pom file was ordered */ // public static XmlOrderedResult ordered() { // return new XmlOrderedResult(true, ""); // } // // /** The xml elements was not in the right order */ // public static XmlOrderedResult nameDiffers(String originalElementName, String newElementName) { // return new XmlOrderedResult(false, String.format("The xml element <%s> should be placed before <%s>", // newElementName, originalElementName)); // } // // /** The child elements of two elements differ. Example: When dependencies should be sorted */ // public static XmlOrderedResult childElementDiffers(String name, int originalSize, int newSize) { // return new XmlOrderedResult(false, String.format( // "The xml element <%s> with %s child elements should be placed before element <%s> with %s child elements", // name, newSize, name, originalSize)); // } // // /** The texts inside two elements differ. Example: when maven properties should be sorted */ // public static XmlOrderedResult textContentDiffers(String name, String originalElementText, String newElementText) { // return new XmlOrderedResult(false, String.format("The xml element <%s>%s</%s> should be placed before <%s>%s</%s>", // name, newElementText, name, name, originalElementText, name)); // } // // public static XmlOrderedResult lineDiffers(int lineNumber, String sortedXmlLine) { // return new XmlOrderedResult(false, String.format("The line %d is not considered sorted, should be %s", // lineNumber, sortedXmlLine)); // } // // public static XmlOrderedResult lineSeparatorCharactersDiffer() { // return new XmlOrderedResult(false, "The line separator characters differ from sorted pom"); // } // // /** Returns true when verification tells that the pom file was sorted */ // public boolean isOrdered() { // return ordered; // } // // /** An error message that describes what went wrong with the verification operation */ // public String getErrorMessage() { // return errorMessage; // } // // } // Path: sorter/src/main/java/sortpom/verify/ElementComparator.java import org.jdom.Element; import sortpom.util.XmlOrderedResult; import java.util.List; package sortpom.verify; /** * @author bjorn * @since 2012-07-01 */ public class ElementComparator { private final Element originalElement; private final Element newElement; public ElementComparator(Element originalElement, Element newElement) { this.originalElement = originalElement; this.newElement = newElement; }
public XmlOrderedResult isElementOrdered() {
Ekryd/sortpom
sorter/src/test/java/sortpom/wrapper/UnsortedWrapperTest.java
// Path: sorter/src/main/java/sortpom/wrapper/content/UnsortedWrapper.java // public class UnsortedWrapper<T extends Content> implements Wrapper<T> { // // /** The wrapped dom content. */ // private final T content; // // /** // * Instantiates a new unsorted wrapper. // * // * @param content the content // */ // public UnsortedWrapper(final T content) { // this.content = content; // } // // /** @see Wrapper#getContent() */ // @Override // public T getContent() { // return content; // } // // /** @see Wrapper#isBefore(Wrapper) */ // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException("Cannot be sorted"); // } // // /** @see Wrapper#isContentElement() */ // @Override // public boolean isContentElement() { // return content instanceof Element; // } // // /** @see Wrapper#isSortable() */ // @Override // public boolean isSortable() { // return false; // } // // @Override // public String toString() { // return "UnsortedWrapper{" + // "content=" + content + // '}'; // } // }
import org.jdom.Text; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.wrapper.content.UnsortedWrapper; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertThrows;
package sortpom.wrapper; /** * @author bjorn * @since 2012-06-14 */ class UnsortedWrapperTest { @Test void testIsBefore() {
// Path: sorter/src/main/java/sortpom/wrapper/content/UnsortedWrapper.java // public class UnsortedWrapper<T extends Content> implements Wrapper<T> { // // /** The wrapped dom content. */ // private final T content; // // /** // * Instantiates a new unsorted wrapper. // * // * @param content the content // */ // public UnsortedWrapper(final T content) { // this.content = content; // } // // /** @see Wrapper#getContent() */ // @Override // public T getContent() { // return content; // } // // /** @see Wrapper#isBefore(Wrapper) */ // @Override // public boolean isBefore(final Wrapper<? extends Content> wrapper) { // throw new UnsupportedOperationException("Cannot be sorted"); // } // // /** @see Wrapper#isContentElement() */ // @Override // public boolean isContentElement() { // return content instanceof Element; // } // // /** @see Wrapper#isSortable() */ // @Override // public boolean isSortable() { // return false; // } // // @Override // public String toString() { // return "UnsortedWrapper{" + // "content=" + content + // '}'; // } // } // Path: sorter/src/test/java/sortpom/wrapper/UnsortedWrapperTest.java import org.jdom.Text; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import sortpom.wrapper.content.UnsortedWrapper; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertThrows; package sortpom.wrapper; /** * @author bjorn * @since 2012-06-14 */ class UnsortedWrapperTest { @Test void testIsBefore() {
final Executable testMethod = () -> new UnsortedWrapper<Text>(null)
Ekryd/sortpom
sorter/src/main/java/sortpom/parameter/LineSeparatorUtil.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import sortpom.exception.FailureException; import java.nio.charset.Charset; import java.util.Arrays;
package sortpom.parameter; /** * Encapsulates LineSeparation logic. * * @author bjorn */ public class LineSeparatorUtil { private final String string; /** * Creates a line separator and makes sure that it is either &#92;n, &#92;r or &#92;r&#92;n * * @param lineSeparatorString The line separator characters */ LineSeparatorUtil(final String lineSeparatorString) { string = lineSeparatorString.replace("\\r", "\r").replace("\\n", "\n"); if (isIllegalString()) {
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/main/java/sortpom/parameter/LineSeparatorUtil.java import sortpom.exception.FailureException; import java.nio.charset.Charset; import java.util.Arrays; package sortpom.parameter; /** * Encapsulates LineSeparation logic. * * @author bjorn */ public class LineSeparatorUtil { private final String string; /** * Creates a line separator and makes sure that it is either &#92;n, &#92;r or &#92;r&#92;n * * @param lineSeparatorString The line separator characters */ LineSeparatorUtil(final String lineSeparatorString) { string = lineSeparatorString.replace("\\r", "\r").replace("\\n", "\n"); if (isIllegalString()) {
throw new FailureException(
Ekryd/sortpom
sorter/src/test/java/sortpom/parameter/VerifyFailParameterTest.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows;
package sortpom.parameter; class VerifyFailParameterTest { @Test void stopIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("sToP", "strict") .build(); assertEquals(VerifyFailType.STOP, pluginParameters.verifyFailType); } @Test void warnIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("wArN", "strict") .build(); assertEquals(VerifyFailType.WARN, pluginParameters.verifyFailType); } @Test void sortIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("sOrT", "strict") .build(); assertEquals(VerifyFailType.SORT, pluginParameters.verifyFailType); } @ParameterizedTest @NullAndEmptySource @ValueSource(strings = "gurka") void verifyFailFaultyValues(String value) { final Executable testMethod = () -> PluginParameters.builder() .setVerifyFail(value, "strict") .build();
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/test/java/sortpom/parameter/VerifyFailParameterTest.java import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import sortpom.exception.FailureException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; package sortpom.parameter; class VerifyFailParameterTest { @Test void stopIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("sToP", "strict") .build(); assertEquals(VerifyFailType.STOP, pluginParameters.verifyFailType); } @Test void warnIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("wArN", "strict") .build(); assertEquals(VerifyFailType.WARN, pluginParameters.verifyFailType); } @Test void sortIgnoreCaseValueIsOk() { PluginParameters pluginParameters = PluginParameters.builder() .setVerifyFail("sOrT", "strict") .build(); assertEquals(VerifyFailType.SORT, pluginParameters.verifyFailType); } @ParameterizedTest @NullAndEmptySource @ValueSource(strings = "gurka") void verifyFailFaultyValues(String value) { final Executable testMethod = () -> PluginParameters.builder() .setVerifyFail(value, "strict") .build();
final FailureException thrown = assertThrows(FailureException.class, testMethod);
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/content/ChildElementSorter.java
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // }
import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Function;
package sortpom.wrapper.content; /** * @author bjorn * @since 2012-09-20 */ public class ChildElementSorter { static final ChildElementSorter EMPTY_SORTER = new ChildElementSorter(); private static final String GROUP_ID_NAME = "GROUPID"; private static final String EMPTY_PLUGIN_GROUP_ID_VALUE = "org.apache.maven.plugins"; private final LinkedHashMap<String, String> childElementTextMappedBySortedNames = new LinkedHashMap<>();
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // } // Path: sorter/src/main/java/sortpom/wrapper/content/ChildElementSorter.java import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Function; package sortpom.wrapper.content; /** * @author bjorn * @since 2012-09-20 */ public class ChildElementSorter { static final ChildElementSorter EMPTY_SORTER = new ChildElementSorter(); private static final String GROUP_ID_NAME = "GROUPID"; private static final String EMPTY_PLUGIN_GROUP_ID_VALUE = "org.apache.maven.plugins"; private final LinkedHashMap<String, String> childElementTextMappedBySortedNames = new LinkedHashMap<>();
public ChildElementSorter(DependencySortOrder dependencySortOrder, List<Element> children) {
Ekryd/sortpom
sorter/src/test/java/sortpom/SortPomServiceTest.java
// Path: sorter/src/main/java/sortpom/util/XmlOrderedResult.java // public final class XmlOrderedResult { // private final boolean ordered; // private final String errorMessage; // // private XmlOrderedResult(boolean ordered, String errorMessage) { // this.ordered = ordered; // this.errorMessage = errorMessage; // } // // /** pom file was ordered */ // public static XmlOrderedResult ordered() { // return new XmlOrderedResult(true, ""); // } // // /** The xml elements was not in the right order */ // public static XmlOrderedResult nameDiffers(String originalElementName, String newElementName) { // return new XmlOrderedResult(false, String.format("The xml element <%s> should be placed before <%s>", // newElementName, originalElementName)); // } // // /** The child elements of two elements differ. Example: When dependencies should be sorted */ // public static XmlOrderedResult childElementDiffers(String name, int originalSize, int newSize) { // return new XmlOrderedResult(false, String.format( // "The xml element <%s> with %s child elements should be placed before element <%s> with %s child elements", // name, newSize, name, originalSize)); // } // // /** The texts inside two elements differ. Example: when maven properties should be sorted */ // public static XmlOrderedResult textContentDiffers(String name, String originalElementText, String newElementText) { // return new XmlOrderedResult(false, String.format("The xml element <%s>%s</%s> should be placed before <%s>%s</%s>", // name, newElementText, name, name, originalElementText, name)); // } // // public static XmlOrderedResult lineDiffers(int lineNumber, String sortedXmlLine) { // return new XmlOrderedResult(false, String.format("The line %d is not considered sorted, should be %s", // lineNumber, sortedXmlLine)); // } // // public static XmlOrderedResult lineSeparatorCharactersDiffer() { // return new XmlOrderedResult(false, "The line separator characters differ from sorted pom"); // } // // /** Returns true when verification tells that the pom file was sorted */ // public boolean isOrdered() { // return ordered; // } // // /** An error message that describes what went wrong with the verification operation */ // public String getErrorMessage() { // return errorMessage; // } // // }
import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import refutils.ReflectionHelper; import sortpom.util.XmlOrderedResult; import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mockStatic;
package sortpom; /** * */ class SortPomServiceTest { private final SortPomService service = new SortPomService(); private final ReflectionHelper serviceHelper = new ReflectionHelper(service); @Test void equalStringShouldBeSame() { setOriginalAndSortedXml("hello", "hello");
// Path: sorter/src/main/java/sortpom/util/XmlOrderedResult.java // public final class XmlOrderedResult { // private final boolean ordered; // private final String errorMessage; // // private XmlOrderedResult(boolean ordered, String errorMessage) { // this.ordered = ordered; // this.errorMessage = errorMessage; // } // // /** pom file was ordered */ // public static XmlOrderedResult ordered() { // return new XmlOrderedResult(true, ""); // } // // /** The xml elements was not in the right order */ // public static XmlOrderedResult nameDiffers(String originalElementName, String newElementName) { // return new XmlOrderedResult(false, String.format("The xml element <%s> should be placed before <%s>", // newElementName, originalElementName)); // } // // /** The child elements of two elements differ. Example: When dependencies should be sorted */ // public static XmlOrderedResult childElementDiffers(String name, int originalSize, int newSize) { // return new XmlOrderedResult(false, String.format( // "The xml element <%s> with %s child elements should be placed before element <%s> with %s child elements", // name, newSize, name, originalSize)); // } // // /** The texts inside two elements differ. Example: when maven properties should be sorted */ // public static XmlOrderedResult textContentDiffers(String name, String originalElementText, String newElementText) { // return new XmlOrderedResult(false, String.format("The xml element <%s>%s</%s> should be placed before <%s>%s</%s>", // name, newElementText, name, name, originalElementText, name)); // } // // public static XmlOrderedResult lineDiffers(int lineNumber, String sortedXmlLine) { // return new XmlOrderedResult(false, String.format("The line %d is not considered sorted, should be %s", // lineNumber, sortedXmlLine)); // } // // public static XmlOrderedResult lineSeparatorCharactersDiffer() { // return new XmlOrderedResult(false, "The line separator characters differ from sorted pom"); // } // // /** Returns true when verification tells that the pom file was sorted */ // public boolean isOrdered() { // return ordered; // } // // /** An error message that describes what went wrong with the verification operation */ // public String getErrorMessage() { // return errorMessage; // } // // } // Path: sorter/src/test/java/sortpom/SortPomServiceTest.java import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import refutils.ReflectionHelper; import sortpom.util.XmlOrderedResult; import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mockStatic; package sortpom; /** * */ class SortPomServiceTest { private final SortPomService service = new SortPomService(); private final ReflectionHelper serviceHelper = new ReflectionHelper(service); @Test void equalStringShouldBeSame() { setOriginalAndSortedXml("hello", "hello");
XmlOrderedResult result = service.isOriginalXmlStringSorted();
Ekryd/sortpom
sorter/src/main/java/sortpom/parameter/IndentCharacters.java
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // }
import sortpom.exception.FailureException; import java.util.Arrays;
package sortpom.parameter; /** * Encapsulates functionality to get indent characters from the nrOfIndentSpace * parameter */ class IndentCharacters { /** Indicates that a tab character should be used instead of spaces. */ private static final int INDENT_TAB = -1; private static final int MAX_INDENT_SPACES = 255; private final int nrOfIndentSpace; IndentCharacters(int nrOfIndentSpace) { this.nrOfIndentSpace = nrOfIndentSpace; } /** * Gets the indent characters from parameter. * * @return the indent characters */ public String getIndentCharacters() { if (nrOfIndentSpace == 0) { return ""; } if (nrOfIndentSpace == INDENT_TAB) { return "\t"; } if (nrOfIndentSpace < INDENT_TAB || nrOfIndentSpace > MAX_INDENT_SPACES) {
// Path: sorter/src/main/java/sortpom/exception/FailureException.java // public class FailureException extends RuntimeException { // public FailureException(String msg, Throwable cause) { // super(msg, cause); // } // // public FailureException(String msg) { // super(msg); // } // } // Path: sorter/src/main/java/sortpom/parameter/IndentCharacters.java import sortpom.exception.FailureException; import java.util.Arrays; package sortpom.parameter; /** * Encapsulates functionality to get indent characters from the nrOfIndentSpace * parameter */ class IndentCharacters { /** Indicates that a tab character should be used instead of spaces. */ private static final int INDENT_TAB = -1; private static final int MAX_INDENT_SPACES = 255; private final int nrOfIndentSpace; IndentCharacters(int nrOfIndentSpace) { this.nrOfIndentSpace = nrOfIndentSpace; } /** * Gets the indent characters from parameter. * * @return the indent characters */ public String getIndentCharacters() { if (nrOfIndentSpace == 0) { return ""; } if (nrOfIndentSpace == INDENT_TAB) { return "\t"; } if (nrOfIndentSpace < INDENT_TAB || nrOfIndentSpace > MAX_INDENT_SPACES) {
throw new FailureException("nrOfIndentSpace cannot be below -1 or above 255, was: " + nrOfIndentSpace);
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/content/DependencySortedWrapper.java
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // }
import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List;
package sortpom.wrapper.content; /** * A wrapper that contains a dependency element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class DependencySortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a dependency element. * * @param element the element * @param sortOrder the sort order */ public DependencySortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // } // Path: sorter/src/main/java/sortpom/wrapper/content/DependencySortedWrapper.java import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List; package sortpom.wrapper.content; /** * A wrapper that contains a dependency element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class DependencySortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a dependency element. * * @param element the element * @param sortOrder the sort order */ public DependencySortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
public void setSortOrder(DependencySortOrder childElementNames) {
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/operation/SortAttributesOperation.java
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // }
import org.jdom.Attribute; import org.jdom.Element; import sortpom.wrapper.content.Wrapper; import java.util.ArrayList; import java.util.Comparator; import java.util.List;
package sortpom.wrapper.operation; /** * Xml hierarchy operation that sort all attributes of xml elements. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * @author bjorn * @since 2013-11-01 */ class SortAttributesOperation implements HierarchyWrapperOperation { private static final Comparator<Attribute> ATTRIBUTE_COMPARATOR = Comparator.comparing(Attribute::getName); /** Sort attributes of each element */ @Override
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // } // Path: sorter/src/main/java/sortpom/wrapper/operation/SortAttributesOperation.java import org.jdom.Attribute; import org.jdom.Element; import sortpom.wrapper.content.Wrapper; import java.util.ArrayList; import java.util.Comparator; import java.util.List; package sortpom.wrapper.operation; /** * Xml hierarchy operation that sort all attributes of xml elements. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * @author bjorn * @since 2013-11-01 */ class SortAttributesOperation implements HierarchyWrapperOperation { private static final Comparator<Attribute> ATTRIBUTE_COMPARATOR = Comparator.comparing(Attribute::getName); /** Sort attributes of each element */ @Override
public void processElement(Wrapper<Element> elementWrapper) {
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/content/ExclusionSortedWrapper.java
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // }
import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List;
package sortpom.wrapper.content; /** * A wrapper that contains a exclusion element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class ExclusionSortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a exclusion element. * * @param element the element * @param sortOrder the sort order */ public ExclusionSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
// Path: sorter/src/main/java/sortpom/parameter/DependencySortOrder.java // public class DependencySortOrder { // private final String childElementNameList; // private Collection<String> childElementNames; // // /** // * Create an instance of the DependencySortOrder // * // * @param childElementNameList the plugin parameter argument // */ // public DependencySortOrder(String childElementNameList) { // this.childElementNameList = childElementNameList == null ? "" : childElementNameList; // } // // /** // * Gets a list of which elements the dependencies should be sorted after. Example: // * If the list returns "scope, groupId" then the dependencies should be sorted first by scope and then by // * groupId. // * // * @return a list of xml element names // */ // public Collection<String> getChildElementNames() { // if (childElementNames == null) { // childElementNames = Collections.unmodifiableList(Arrays.asList(parseChildElementNameList())); // } // return childElementNames; // } // // private String[] parseChildElementNameList() { // String list = childElementNameList.replaceAll("\\s", ""); // if (list.isEmpty()) { // return new String[0]; // } // return list.split("[;,:]"); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueTrue() { // return "true".equalsIgnoreCase(childElementNameList); // } // // /** Earlier versions only accepted the values 'true' and 'false' as parameter values */ // public boolean isDeprecatedValueFalse() { // return "false".equalsIgnoreCase(childElementNameList); // } // // /** If the dependencies should be unsorted */ // public boolean isNoSorting() { // return getChildElementNames().isEmpty(); // } // // @Override // public String toString() { // return "DependencySortOrder{" + // "childElementNames=" + getChildElementNames() + // '}'; // } // } // Path: sorter/src/main/java/sortpom/wrapper/content/ExclusionSortedWrapper.java import org.jdom.Content; import org.jdom.Element; import sortpom.parameter.DependencySortOrder; import java.util.List; package sortpom.wrapper.content; /** * A wrapper that contains a exclusion element. The element is sorted according to a predetermined order. * * @author Bjorn Ekryd */ public class ExclusionSortedWrapper extends SortedWrapper { private ChildElementSorter childElementSorter = ChildElementSorter.EMPTY_SORTER; /** * Instantiates a new child element sorted wrapper with a exclusion element. * * @param element the element * @param sortOrder the sort order */ public ExclusionSortedWrapper(final Element element, final int sortOrder) { super(element, sortOrder); } @SuppressWarnings("unchecked")
public void setSortOrder(DependencySortOrder childElementNames) {
Ekryd/sortpom
sorter/src/main/java/sortpom/wrapper/operation/ToStringOperation.java
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // }
import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.Wrapper; import java.util.List;
package sortpom.wrapper.operation; /** * Xml hierarchy operation that returns xml content as readable text. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * * @author bjorn * @since 2013-11-02 */ class ToStringOperation implements HierarchyWrapperOperation { private static final String INDENT = " "; private static final int INDENT_LENGTH = INDENT.length(); private final StringBuilder builder; private final String baseIndent; private boolean processFirstOtherContent; ToStringOperation() { builder = new StringBuilder(); baseIndent = INDENT; } private ToStringOperation(StringBuilder builder, String baseIndent) { this.builder = builder; this.baseIndent = INDENT + baseIndent; } /** Add text before each element */ @Override public void startOfProcess() { String previousBaseIndent = baseIndent.substring(INDENT_LENGTH); builder.append(previousBaseIndent).append("HierarchyWrapper{\n"); processFirstOtherContent = true; } /** Add each 'other element' to string */ @Override
// Path: sorter/src/main/java/sortpom/wrapper/content/Wrapper.java // public interface Wrapper<T extends Content> { // // /** // * Gets the wrapped content. // * // * @return the content // */ // T getContent(); // // /** // * Checks if wrapper should be placed before another wrapper. // * // * @param wrapper the wrapper // * @return true, if is before // */ // boolean isBefore(Wrapper<? extends Content> wrapper); // // /** // * Checks if is content is of type Element. Default behaviour is that it contains an element. // * // * @return true, if is content element // */ // default boolean isContentElement() { // return true; // } // // /** // * Checks if wrapper should be sorted. Default behaviour is that it that the Wrapper is sortable. // * // * @return true, if is sortable // */ // default boolean isSortable() { // return true; // } // // /** // * Output debug-friendly string // * // * @param indent The indentation indicates nested elements // * @return The debug string // */ // default String toString(String indent) { // return indent + toString(); // } // // } // Path: sorter/src/main/java/sortpom/wrapper/operation/ToStringOperation.java import org.jdom.Content; import org.jdom.Element; import sortpom.wrapper.content.Wrapper; import java.util.List; package sortpom.wrapper.operation; /** * Xml hierarchy operation that returns xml content as readable text. Used by * Used in HierarchyWrapper.processOperation(HierarchyWrapperOperation operation) * * @author bjorn * @since 2013-11-02 */ class ToStringOperation implements HierarchyWrapperOperation { private static final String INDENT = " "; private static final int INDENT_LENGTH = INDENT.length(); private final StringBuilder builder; private final String baseIndent; private boolean processFirstOtherContent; ToStringOperation() { builder = new StringBuilder(); baseIndent = INDENT; } private ToStringOperation(StringBuilder builder, String baseIndent) { this.builder = builder; this.baseIndent = INDENT + baseIndent; } /** Add text before each element */ @Override public void startOfProcess() { String previousBaseIndent = baseIndent.substring(INDENT_LENGTH); builder.append(previousBaseIndent).append("HierarchyWrapper{\n"); processFirstOtherContent = true; } /** Add each 'other element' to string */ @Override
public void processOtherContent(Wrapper<Content> content) {
Ekryd/sortpom
sorter/src/test/java/sortpom/verify/ExpandEmptyElementTest.java
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // }
import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil;
package sortpom.verify; class ExpandEmptyElementTest { @Test void trueExpandedParameterAndTrueExpandedElementShouldNotAffectVerify() throws Exception {
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // } // Path: sorter/src/test/java/sortpom/verify/ExpandEmptyElementTest.java import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil; package sortpom.verify; class ExpandEmptyElementTest { @Test void trueExpandedParameterAndTrueExpandedElementShouldNotAffectVerify() throws Exception {
XmlProcessorTestUtil.create()
Ekryd/sortpom
sorter/src/test/java/sortpom/verify/XmlProcessorTest.java
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // }
import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil;
package sortpom.verify; class XmlProcessorTest { @Test final void testSortXmlAttributesShouldNotAffectVerify() throws Exception {
// Path: sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java // public class XmlProcessorTestUtil { // private boolean sortAlphabeticalOnly = false; // private boolean keepBlankLines = false; // private boolean indentBlankLines = false; // private String predefinedSortOrder = "recommended_2008_06"; // private boolean expandEmptyElements = true; // private String lineSeparator = "\r\n"; // // private XmlProcessor xmlProcessor; // private XmlOutputGenerator xmlOutputGenerator; // private boolean spaceBeforeCloseEmptyElement = true; // private boolean sortModules = false; // private String sortDependencies; // private String sortPlugins; // private boolean sortProperties = false; // // // public static XmlProcessorTestUtil create() { // return new XmlProcessorTestUtil(); // } // // private XmlProcessorTestUtil() { // } // // public void testInputAndExpected(final String inputFileName, final String expectedFileName) throws Exception { // String actual = sortXmlAndReturnResult(inputFileName); // // final String expected = IOUtils.toString(new FileInputStream(expectedFileName), StandardCharsets.UTF_8); // // assertEquals(expected, actual); // } // // public String sortXmlAndReturnResult(String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // return xmlOutputGenerator.getSortedXml(xmlProcessor.getNewDocument()); // } // // public void testVerifyXmlIsOrdered(final String inputFileName) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // assertTrue(xmlProcessor.isXmlOrdered().isOrdered()); // } // // public void testVerifyXmlIsNotOrdered(final String inputFileName, String infoMessage) throws Exception { // setup(inputFileName); // xmlProcessor.sortXml(); // XmlOrderedResult xmlOrdered = xmlProcessor.isXmlOrdered(); // assertFalse(xmlOrdered.isOrdered()); // assertEquals(infoMessage, xmlOrdered.getErrorMessage()); // } // // private void setup(String inputFileName) throws Exception { // PluginParameters pluginParameters = PluginParameters.builder() // .setPomFile(null) // .setFileOutput(false, ".bak", null, false) // .setEncoding("UTF-8") // .setFormatting(lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines) // .setIndent(2, indentBlankLines, false) // .setSortOrder(predefinedSortOrder + ".xml", null) // .setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false).build(); // final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8); // // final FileUtil fileUtil = new FileUtil(); // fileUtil.setup(pluginParameters); // // WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil); // ((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters); // // xmlProcessor = new XmlProcessor(wrapperFactory); // // xmlOutputGenerator = new XmlOutputGenerator(); // xmlOutputGenerator.setup(pluginParameters); // // if (sortAlphabeticalOnly) { // wrapperFactory = new WrapperFactory() { // // @Override // public HierarchyRootWrapper createFromRootElement(final Element rootElement) { // return new HierarchyRootWrapper(new AlphabeticalSortedWrapper(rootElement)); // } // // @SuppressWarnings("unchecked") // @Override // public <T extends Content> Wrapper<T> create(final T content) { // if (content instanceof Element) { // Element element = (Element) content; // return (Wrapper<T>) new AlphabeticalSortedWrapper(element); // } // return new UnsortedWrapper<>(content); // } // // }; // } else { // new ReflectionHelper(wrapperFactory).setField(fileUtil); // } // new ReflectionHelper(xmlProcessor).setField(wrapperFactory); // xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); // } // // public XmlProcessorTestUtil sortAlphabeticalOnly() { // sortAlphabeticalOnly = true; // return this; // } // // public XmlProcessorTestUtil keepBlankLines() { // keepBlankLines = true; // return this; // } // // public XmlProcessorTestUtil lineSeparator(String lineSeparator) { // this.lineSeparator = lineSeparator; // return this; // } // // public XmlProcessorTestUtil indentBlankLines() { // indentBlankLines = true; // return this; // } // // public XmlProcessorTestUtil predefinedSortOrder(String predefinedSortOrder) { // this.predefinedSortOrder = predefinedSortOrder; // return this; // } // // public XmlProcessorTestUtil sortModules() { // this.sortModules = true; // return this; // } // // public XmlProcessorTestUtil sortDependencies(String sortDependencies) { // this.sortDependencies = sortDependencies; // return this; // } // // public XmlProcessorTestUtil sortPlugins(String sortPlugins) { // this.sortPlugins = sortPlugins; // return this; // } // // public XmlProcessorTestUtil noSpaceBeforeCloseEmptyElement() { // this.spaceBeforeCloseEmptyElement = false; // return this; // } // // public XmlProcessorTestUtil sortProperties() { // this.sortProperties = true; // return this; // } // // public XmlProcessorTestUtil expandEmptyElements(boolean expand) { // this.expandEmptyElements = expand; // return this; // } // } // Path: sorter/src/test/java/sortpom/verify/XmlProcessorTest.java import org.junit.jupiter.api.Test; import sortpom.util.XmlProcessorTestUtil; package sortpom.verify; class XmlProcessorTest { @Test final void testSortXmlAttributesShouldNotAffectVerify() throws Exception {
XmlProcessorTestUtil.create()
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/registry/RegFactory.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.registry; public class RegFactory { //private List<String> subkeys = new ArrayList<String>(); private List<String> programs = new ArrayList<String>(); public RegFactory() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { super(); listPrograms();//Gets the list of all installed programs in the list "programs" } public String winVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value = WinRegistry.readString ( WinRegistry.HKEY_LOCAL_MACHINE, //HKEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", //Key "ProductName"); //ValueName return value; } public void javaVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value; String version = null; for (String key:programs) { value = WinRegistry.readString (WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayName"); if (value != null) { // search if java installed if (value.toLowerCase().contains("java")) { System.out.print(key+"/"+value+"; "); version = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayVersion");
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/registry/RegFactory.java import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.registry; public class RegFactory { //private List<String> subkeys = new ArrayList<String>(); private List<String> programs = new ArrayList<String>(); public RegFactory() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { super(); listPrograms();//Gets the list of all installed programs in the list "programs" } public String winVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value = WinRegistry.readString ( WinRegistry.HKEY_LOCAL_MACHINE, //HKEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", //Key "ProductName"); //ValueName return value; } public void javaVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value; String version = null; for (String key:programs) { value = WinRegistry.readString (WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayName"); if (value != null) { // search if java installed if (value.toLowerCase().contains("java")) { System.out.print(key+"/"+value+"; "); version = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayVersion");
Out.print(LOG_LEVEL.DEBUG, "Java Version: " + version);// display installed version
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/registry/RegFactory.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.registry; public class RegFactory { //private List<String> subkeys = new ArrayList<String>(); private List<String> programs = new ArrayList<String>(); public RegFactory() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { super(); listPrograms();//Gets the list of all installed programs in the list "programs" } public String winVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value = WinRegistry.readString ( WinRegistry.HKEY_LOCAL_MACHINE, //HKEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", //Key "ProductName"); //ValueName return value; } public void javaVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value; String version = null; for (String key:programs) { value = WinRegistry.readString (WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayName"); if (value != null) { // search if java installed if (value.toLowerCase().contains("java")) { System.out.print(key+"/"+value+"; "); version = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayVersion");
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/registry/RegFactory.java import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.registry; public class RegFactory { //private List<String> subkeys = new ArrayList<String>(); private List<String> programs = new ArrayList<String>(); public RegFactory() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { super(); listPrograms();//Gets the list of all installed programs in the list "programs" } public String winVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value = WinRegistry.readString ( WinRegistry.HKEY_LOCAL_MACHINE, //HKEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", //Key "ProductName"); //ValueName return value; } public void javaVersion() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { String value; String version = null; for (String key:programs) { value = WinRegistry.readString (WinRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayName"); if (value != null) { // search if java installed if (value.toLowerCase().contains("java")) { System.out.print(key+"/"+value+"; "); version = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+key, "DisplayVersion");
Out.print(LOG_LEVEL.DEBUG, "Java Version: " + version);// display installed version
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/URLValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class URLValidator implements Validator { @Override public boolean isValid(String url) { if ("http://".startsWith(url) || "https://".startsWith(url)) return true; if (url.equals("") || url.startsWith("http://") || url.startsWith("https://")) return true;
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/URLValidator.java import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class URLValidator implements Validator { @Override public boolean isValid(String url) { if ("http://".startsWith(url) || "https://".startsWith(url)) return true; if (url.equals("") || url.startsWith("http://") || url.startsWith("https://")) return true;
Out.print(LOG_LEVEL.DEBUG, "URL format incorrect: " + url);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/URLValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class URLValidator implements Validator { @Override public boolean isValid(String url) { if ("http://".startsWith(url) || "https://".startsWith(url)) return true; if (url.equals("") || url.startsWith("http://") || url.startsWith("https://")) return true;
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/URLValidator.java import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class URLValidator implements Validator { @Override public boolean isValid(String url) { if ("http://".startsWith(url) || "https://".startsWith(url)) return true; if (url.equals("") || url.startsWith("http://") || url.startsWith("https://")) return true;
Out.print(LOG_LEVEL.DEBUG, "URL format incorrect: " + url);
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/AppConfig.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // }
import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig;
package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // } // Path: src/main/java/com/dcp/sm/logic/model/config/AppConfig.java import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig; package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes
private BUILD_MODE buildMode = BUILD_MODE.IZPACK_BUILD;
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/AppConfig.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // }
import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig;
package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes private BUILD_MODE buildMode = BUILD_MODE.IZPACK_BUILD; // Default Configurations private SetupConfig defaultSetupConfig;
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // } // Path: src/main/java/com/dcp/sm/logic/model/config/AppConfig.java import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig; package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes private BUILD_MODE buildMode = BUILD_MODE.IZPACK_BUILD; // Default Configurations private SetupConfig defaultSetupConfig;
private IzpackConfig defaultIzpackConf;
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/AppConfig.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // }
import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig;
package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes private BUILD_MODE buildMode = BUILD_MODE.IZPACK_BUILD; // Default Configurations private SetupConfig defaultSetupConfig; private IzpackConfig defaultIzpackConf;
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum BUILD_MODE { // DEFAULT("IzPack"), // IZPACK_BUILD("IzPack"),//Default // NUGET_BUILD("NuGet"); // // private String _value; // private BUILD_MODE(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/IzpackConfig.java // public class IzpackConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 1550797914797285496L; // // // Packaging Split option // private boolean split = false;//Split option // private int splitSize = 0;//Split size // // Web Area // private boolean webSetup = false;//Web Setup option // private String webUrl = "";//Web HTTP server URL // private WebConfig webConfig;// SFTP Web config // // public IzpackConfig() // { // this.webConfig = new WebConfig(); // } // public IzpackConfig(IzpackConfig izpackConf) // { // this.split = izpackConf.split; // this.splitSize = izpackConf.splitSize; // this.webSetup = izpackConf.webSetup; // this.webUrl = izpackConf.webUrl; // this.webConfig = new WebConfig(izpackConf.webConfig); // } // // public boolean isSplit() { return split; } // public void setSplit(boolean split) { this.split = split; } // // public int getSplitSize() { return splitSize; } // public void setSplitSize(int splitSizeInMB) { this.splitSize = splitSizeInMB * (1024*1024); } // // public boolean isWebSetup() { return webSetup; } // public void setWebSetup(boolean webSetup) { this.webSetup = webSetup; } // // public String getWebUrl() { return webUrl; } // public void setWebUrl(String webUrl) { this.webUrl = webUrl; } // // public WebConfig getWebConfig() { return webConfig; } // public void setWebConfig(WebConfig webConfig) { this.webConfig = webConfig; } // // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/NugetConfig.java // public class NugetConfig implements Serializable // { // /** // * class written to workspace file: conf.dcp // * from AppConfig class // */ // private static final long serialVersionUID = 829663743614405550L; // // // Nuget options // private String feedUrl = "http://";// default feed url // private int stepNbr = 3;// step number (default 3) // // public NugetConfig() // { // } // public NugetConfig(NugetConfig nugetConf) // { // this.feedUrl = nugetConf.feedUrl; // this.stepNbr = nugetConf.stepNbr; // } // // // Nuget options methods // public String getFeedUrl() { return feedUrl; } // public void setFeedUrl(String feedUrl) { this.feedUrl = feedUrl; } // public int getStepNbr() { return stepNbr; } // public void setStepNbr(int stepNbr) { this.stepNbr = stepNbr; } // // } // Path: src/main/java/com/dcp/sm/logic/model/config/AppConfig.java import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.LinkedList; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import com.dcp.sm.logic.factory.TypeFactory.BUILD_MODE; import com.dcp.sm.logic.model.config.build.IzpackConfig; import com.dcp.sm.logic.model.config.build.NugetConfig; package com.dcp.sm.logic.model.config; /** * DevComPack Application workspace configuration data * @author SSAIDELI * */ public class AppConfig implements Serializable { /** * class written to workspace file: conf.dcp */ private static final long serialVersionUID = 1194986597451209924L; // Constants private transient final static int MAX_RECENT_DIRECTORIES = 5; private transient final static int MAX_RECENT_PROJECTS = 3; // Flag transient private boolean modified = false; public boolean isModified() { return modified; } public void setModified(boolean modified) { this.modified = modified; } // Assistant flag private boolean help = true; // Attributes private String appName; private String appVersion; // Data private LinkedList<File> recentDirs = new LinkedList<File>(); private LinkedList<File> recentProjects = new LinkedList<File>(); // Workspace private float scanHorSplitPaneRatio = 0.25f; private float setVerSplitPaneRatio = 0.6f; private float setHorSplitPaneRatio = 0.7f; // Modes private BUILD_MODE buildMode = BUILD_MODE.IZPACK_BUILD; // Default Configurations private SetupConfig defaultSetupConfig; private IzpackConfig defaultIzpackConf;
private NugetConfig defaultNugetConf;
DevComPack/setupmaker
src/main/java/com/dcp/sm/main/log/Out.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // }
import java.io.PrintStream; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import org.apache.pivot.wtk.ApplicationContext; import org.apache.pivot.wtk.Component; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL;
package com.dcp.sm.main.log; public class Out { //Log private static List<String> log = new ArrayList<String>();//Global Log public static List<String> getLog() { return log; } private static int displayLevel = 1;//logs to display must be >= than this private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log public static List<String> getCompileLog() { return compileLog; } //Pivot GUI Component Repaint for log update private static Component logger = null; public static Component getLogger() { return logger; } public static void setLogger(Component logger) { Out.logger = logger; } //Clear the stream cache public static void clearCompileLog() { compileLog.clear(); } //Add a new empty line public static void newLine() {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // Path: src/main/java/com/dcp/sm/main/log/Out.java import java.io.PrintStream; import org.apache.pivot.collections.ArrayList; import org.apache.pivot.collections.List; import org.apache.pivot.wtk.ApplicationContext; import org.apache.pivot.wtk.Component; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; package com.dcp.sm.main.log; public class Out { //Log private static List<String> log = new ArrayList<String>();//Global Log public static List<String> getLog() { return log; } private static int displayLevel = 1;//logs to display must be >= than this private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log public static List<String> getCompileLog() { return compileLog; } //Pivot GUI Component Repaint for log update private static Component logger = null; public static Component getLogger() { return logger; } public static void setLogger(Component logger) { Out.logger = logger; } //Clear the stream cache public static void clearCompileLog() { compileLog.clear(); } //Add a new empty line public static void newLine() {
print(LOG_LEVEL.INFO, "");
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/IOFactory.java
// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java // public class JsonSimpleReader // { // private JSONParser parser; // private FileReader json_file; // private JSONObject obj; // // public JsonSimpleReader(String file_name) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // } // // public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // obj = (JSONObject) obj.get(root_obj); // } // // public int readInt(String name) { // return (Integer) obj.get(name); // } // // public String readString(String name) { // return (String) obj.get(name); // } // // @SuppressWarnings("unchecked") // public List<String> readStringList(String name) { // JSONArray msg = (JSONArray) obj.get(name); // List<String> list = new ArrayList<String>(); // Iterator<String> iterator = msg.iterator(); // while(iterator.hasNext()) { // list.add(iterator.next()); // } // return list; // } // @SuppressWarnings("unchecked") // public String[] readStringArray(String name) { // JSONArray msg = (JSONArray) obj.get(name); // String[] arr = new String[msg.size()]; // Iterator<String> iterator = msg.iterator(); // for(int i=0;iterator.hasNext();i++) { // arr[i] = iterator.next(); // } // return arr; // } // // public void close() throws IOException { // json_file.close(); // } // // // @SuppressWarnings("unchecked") // public static void main(String[] args) // { // JSONParser parser = new JSONParser(); // // try { // // Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt")); // // JSONObject jsonObject = (JSONObject) obj; // // String name = (String) jsonObject.get("name"); // System.out.println(name); // // long age = (Long) jsonObject.get("age"); // System.out.println(age); // // // loop array // JSONArray msg = (JSONArray) jsonObject.get("messages"); // Iterator<String> iterator = msg.iterator(); // while (iterator.hasNext()) { // System.out.println(iterator.next()); // } // // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (ParseException e) { // e.printStackTrace(); // } // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // }
import java.io.File; import java.io.IOException; import org.apache.pivot.util.Filter; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.media.Image; import org.json.simple.parser.ParseException; import com.dcp.sm.config.io.json.JsonSimpleReader; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE;
package com.dcp.sm.config.io; /** * Input/Output Factory * @author SSAIDELI */ public class IOFactory { //ISO3 language codes public static String[] iso3Codes; //File type extensions public static String[] archiveExt;// = {"zip", "rar", "jar", "iso"}; public static String[] exeExt;// = {"exe", "jar", "cmd", "sh", "bat"}; public static String[] setupExt;// = {"msi"}; public static String[] docExt;// = {"txt", "pdf", "doc", "docx", "xml", "rtf", "odt", "xls", "xlsx", "csv"}; public static String[] imgExt;// = {"bmp", "jpg", "jpeg", "gif", "png", "ico"}; public static String[] webExt;// = {"html", "htm", "php", "js", "asp", "aspx", "css"}; public static String[] soundExt;// = {"wav", "mp3", "ogg", "wma"}; public static String[] vidExt;// = {"mp4", "mpg", "mpeg", "wmv", "avi", "mkv"}; public static String[] custExt;//User defined custom extensions /** * Returns file type of a file * @param f: file * @return FILE_TYPE */
// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java // public class JsonSimpleReader // { // private JSONParser parser; // private FileReader json_file; // private JSONObject obj; // // public JsonSimpleReader(String file_name) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // } // // public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // obj = (JSONObject) obj.get(root_obj); // } // // public int readInt(String name) { // return (Integer) obj.get(name); // } // // public String readString(String name) { // return (String) obj.get(name); // } // // @SuppressWarnings("unchecked") // public List<String> readStringList(String name) { // JSONArray msg = (JSONArray) obj.get(name); // List<String> list = new ArrayList<String>(); // Iterator<String> iterator = msg.iterator(); // while(iterator.hasNext()) { // list.add(iterator.next()); // } // return list; // } // @SuppressWarnings("unchecked") // public String[] readStringArray(String name) { // JSONArray msg = (JSONArray) obj.get(name); // String[] arr = new String[msg.size()]; // Iterator<String> iterator = msg.iterator(); // for(int i=0;iterator.hasNext();i++) { // arr[i] = iterator.next(); // } // return arr; // } // // public void close() throws IOException { // json_file.close(); // } // // // @SuppressWarnings("unchecked") // public static void main(String[] args) // { // JSONParser parser = new JSONParser(); // // try { // // Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt")); // // JSONObject jsonObject = (JSONObject) obj; // // String name = (String) jsonObject.get("name"); // System.out.println(name); // // long age = (Long) jsonObject.get("age"); // System.out.println(age); // // // loop array // JSONArray msg = (JSONArray) jsonObject.get("messages"); // Iterator<String> iterator = msg.iterator(); // while (iterator.hasNext()) { // System.out.println(iterator.next()); // } // // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (ParseException e) { // e.printStackTrace(); // } // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // Path: src/main/java/com/dcp/sm/config/io/IOFactory.java import java.io.File; import java.io.IOException; import org.apache.pivot.util.Filter; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.media.Image; import org.json.simple.parser.ParseException; import com.dcp.sm.config.io.json.JsonSimpleReader; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; package com.dcp.sm.config.io; /** * Input/Output Factory * @author SSAIDELI */ public class IOFactory { //ISO3 language codes public static String[] iso3Codes; //File type extensions public static String[] archiveExt;// = {"zip", "rar", "jar", "iso"}; public static String[] exeExt;// = {"exe", "jar", "cmd", "sh", "bat"}; public static String[] setupExt;// = {"msi"}; public static String[] docExt;// = {"txt", "pdf", "doc", "docx", "xml", "rtf", "odt", "xls", "xlsx", "csv"}; public static String[] imgExt;// = {"bmp", "jpg", "jpeg", "gif", "png", "ico"}; public static String[] webExt;// = {"html", "htm", "php", "js", "asp", "aspx", "css"}; public static String[] soundExt;// = {"wav", "mp3", "ogg", "wma"}; public static String[] vidExt;// = {"mp4", "mpg", "mpeg", "wmv", "avi", "mkv"}; public static String[] custExt;//User defined custom extensions /** * Returns file type of a file * @param f: file * @return FILE_TYPE */
public static FILE_TYPE getFileType(File f) {
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/IOFactory.java
// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java // public class JsonSimpleReader // { // private JSONParser parser; // private FileReader json_file; // private JSONObject obj; // // public JsonSimpleReader(String file_name) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // } // // public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // obj = (JSONObject) obj.get(root_obj); // } // // public int readInt(String name) { // return (Integer) obj.get(name); // } // // public String readString(String name) { // return (String) obj.get(name); // } // // @SuppressWarnings("unchecked") // public List<String> readStringList(String name) { // JSONArray msg = (JSONArray) obj.get(name); // List<String> list = new ArrayList<String>(); // Iterator<String> iterator = msg.iterator(); // while(iterator.hasNext()) { // list.add(iterator.next()); // } // return list; // } // @SuppressWarnings("unchecked") // public String[] readStringArray(String name) { // JSONArray msg = (JSONArray) obj.get(name); // String[] arr = new String[msg.size()]; // Iterator<String> iterator = msg.iterator(); // for(int i=0;iterator.hasNext();i++) { // arr[i] = iterator.next(); // } // return arr; // } // // public void close() throws IOException { // json_file.close(); // } // // // @SuppressWarnings("unchecked") // public static void main(String[] args) // { // JSONParser parser = new JSONParser(); // // try { // // Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt")); // // JSONObject jsonObject = (JSONObject) obj; // // String name = (String) jsonObject.get("name"); // System.out.println(name); // // long age = (Long) jsonObject.get("age"); // System.out.println(age); // // // loop array // JSONArray msg = (JSONArray) jsonObject.get("messages"); // Iterator<String> iterator = msg.iterator(); // while (iterator.hasNext()) { // System.out.println(iterator.next()); // } // // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (ParseException e) { // e.printStackTrace(); // } // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // }
import java.io.File; import java.io.IOException; import org.apache.pivot.util.Filter; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.media.Image; import org.json.simple.parser.ParseException; import com.dcp.sm.config.io.json.JsonSimpleReader; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE;
//public static String jarListeners;// = libPath+"/dcp-listeners.jar"; public static String jarResources;// = libPath+"/dcp-resources.jar"; //Ant build files public static String xmlIzpackAntBuild;// = antPath+"/izpack-target.xml"; public static String xmlRunAntBuild;// = antPath+"/run-target.xml"; public static String xmlDebugAntBuild;// = antPath+"/debug-target.xml"; //Bat files public static String batClean;// = batPath+"/clean.bat"; //izpack spec files public static String xmlProcessPanelSpec;// = xmlPath+"/ProcessPanelSpec.xml"; public static String xmlShortcutPanelSpec;// = xmlPath+"/ShortcutPanelSpec.xml"; public static String xmlRegistrySpec;// = xmlPath+"/RegistrySpec.xml"; // chocolatey files public static String psChocolateyInstall;// = psPath+"/ChocolateyInstall.ps1" public static String psChocolateyUninstall;// = psPath+"/ChocolateyUninstall.ps1" public static String saveFile = "";//"save.dcp"; public static void setSaveFile(String canonicalPath) { if (canonicalPath.length() > 0 && !canonicalPath.endsWith("."+IOFactory.dcpFileExt)) {//add file extension if not given canonicalPath = canonicalPath.concat("."+IOFactory.dcpFileExt); } saveFile = canonicalPath; } /** * Load settings from JSON file: settings.json * @throws ParseException * @throws IOException */ private static boolean loadSettings(String json_file) throws IOException, ParseException {
// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java // public class JsonSimpleReader // { // private JSONParser parser; // private FileReader json_file; // private JSONObject obj; // // public JsonSimpleReader(String file_name) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // } // // public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException // { // parser = new JSONParser(); // json_file = new FileReader(file_name); // obj = (JSONObject) parser.parse(json_file); // obj = (JSONObject) obj.get(root_obj); // } // // public int readInt(String name) { // return (Integer) obj.get(name); // } // // public String readString(String name) { // return (String) obj.get(name); // } // // @SuppressWarnings("unchecked") // public List<String> readStringList(String name) { // JSONArray msg = (JSONArray) obj.get(name); // List<String> list = new ArrayList<String>(); // Iterator<String> iterator = msg.iterator(); // while(iterator.hasNext()) { // list.add(iterator.next()); // } // return list; // } // @SuppressWarnings("unchecked") // public String[] readStringArray(String name) { // JSONArray msg = (JSONArray) obj.get(name); // String[] arr = new String[msg.size()]; // Iterator<String> iterator = msg.iterator(); // for(int i=0;iterator.hasNext();i++) { // arr[i] = iterator.next(); // } // return arr; // } // // public void close() throws IOException { // json_file.close(); // } // // // @SuppressWarnings("unchecked") // public static void main(String[] args) // { // JSONParser parser = new JSONParser(); // // try { // // Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt")); // // JSONObject jsonObject = (JSONObject) obj; // // String name = (String) jsonObject.get("name"); // System.out.println(name); // // long age = (Long) jsonObject.get("age"); // System.out.println(age); // // // loop array // JSONArray msg = (JSONArray) jsonObject.get("messages"); // Iterator<String> iterator = msg.iterator(); // while (iterator.hasNext()) { // System.out.println(iterator.next()); // } // // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (ParseException e) { // e.printStackTrace(); // } // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // Path: src/main/java/com/dcp/sm/config/io/IOFactory.java import java.io.File; import java.io.IOException; import org.apache.pivot.util.Filter; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.media.Image; import org.json.simple.parser.ParseException; import com.dcp.sm.config.io.json.JsonSimpleReader; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; //public static String jarListeners;// = libPath+"/dcp-listeners.jar"; public static String jarResources;// = libPath+"/dcp-resources.jar"; //Ant build files public static String xmlIzpackAntBuild;// = antPath+"/izpack-target.xml"; public static String xmlRunAntBuild;// = antPath+"/run-target.xml"; public static String xmlDebugAntBuild;// = antPath+"/debug-target.xml"; //Bat files public static String batClean;// = batPath+"/clean.bat"; //izpack spec files public static String xmlProcessPanelSpec;// = xmlPath+"/ProcessPanelSpec.xml"; public static String xmlShortcutPanelSpec;// = xmlPath+"/ShortcutPanelSpec.xml"; public static String xmlRegistrySpec;// = xmlPath+"/RegistrySpec.xml"; // chocolatey files public static String psChocolateyInstall;// = psPath+"/ChocolateyInstall.ps1" public static String psChocolateyUninstall;// = psPath+"/ChocolateyUninstall.ps1" public static String saveFile = "";//"save.dcp"; public static void setSaveFile(String canonicalPath) { if (canonicalPath.length() > 0 && !canonicalPath.endsWith("."+IOFactory.dcpFileExt)) {//add file extension if not given canonicalPath = canonicalPath.concat("."+IOFactory.dcpFileExt); } saveFile = canonicalPath; } /** * Load settings from JSON file: settings.json * @throws ParseException * @throws IOException */ private static boolean loadSettings(String json_file) throws IOException, ParseException {
JsonSimpleReader json_ext = new JsonSimpleReader(json_file, "extensions");
DevComPack/setupmaker
src/main/java/com/dcp/sm/main/log/StreamDisplay.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL;
package com.dcp.sm.main.log; public class StreamDisplay { private static boolean noError = true;//If the error stream returned an error or not (true->not) private static int timeout = 1000;//Stream waiting timeout (1s) private static boolean wait = true;//Waits for a stream (or not) /** * Sets the display to wait or not for a stream result * Should be called before and after the function * to recover its state to the default one (true) */ public static void setWait(boolean wait) { StreamDisplay.wait = wait; } /* * Sets the timeout waiting period * the WAIT function must be activated */ public static void setTimeout(int TIMEOUT) { if (TIMEOUT<100) TIMEOUT=100; StreamDisplay.timeout = TIMEOUT; } //Display the generated output of a stream @SuppressWarnings({"unused", "static-access"})
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // Path: src/main/java/com/dcp/sm/main/log/StreamDisplay.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; package com.dcp.sm.main.log; public class StreamDisplay { private static boolean noError = true;//If the error stream returned an error or not (true->not) private static int timeout = 1000;//Stream waiting timeout (1s) private static boolean wait = true;//Waits for a stream (or not) /** * Sets the display to wait or not for a stream result * Should be called before and after the function * to recover its state to the default one (true) */ public static void setWait(boolean wait) { StreamDisplay.wait = wait; } /* * Sets the timeout waiting period * the WAIT function must be activated */ public static void setTimeout(int TIMEOUT) { if (TIMEOUT<100) TIMEOUT=100; StreamDisplay.timeout = TIMEOUT; } //Display the generated output of a stream @SuppressWarnings({"unused", "static-access"})
private static boolean mono_display (LOG_LEVEL level, InputStream STDOUT, InputStream STDERR) throws IOException, InterruptedException {
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/PathValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
* @param path: to validate * @param required: if path must be defined * @return int: error code * 0 - no error * 1 - required path not defined * 2 - path doesn't exist on disk */ private static int pathValidate(String path, boolean required) { assert path != null; if (path.length() == 0) return (required == true)?1:0; File f = new File(path); if (f.exists()) return 0; return 2; } @Override public boolean isValid(String s) { int err = pathValidate(s, required); if (err != 0) { switch(err) { case 1: component.setTooltipText("Path is required"); break; case 2: component.setTooltipText("Path doesn't exist on this filesystem!"); break; }
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/PathValidator.java import java.io.File; import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; * @param path: to validate * @param required: if path must be defined * @return int: error code * 0 - no error * 1 - required path not defined * 2 - path doesn't exist on disk */ private static int pathValidate(String path, boolean required) { assert path != null; if (path.length() == 0) return (required == true)?1:0; File f = new File(path); if (f.exists()) return 0; return 2; } @Override public boolean isValid(String s) { int err = pathValidate(s, required); if (err != 0) { switch(err) { case 1: component.setTooltipText("Path is required"); break; case 2: component.setTooltipText("Path doesn't exist on this filesystem!"); break; }
Out.print(LOG_LEVEL.DEBUG, "Path error: " + s);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/PathValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
* @param path: to validate * @param required: if path must be defined * @return int: error code * 0 - no error * 1 - required path not defined * 2 - path doesn't exist on disk */ private static int pathValidate(String path, boolean required) { assert path != null; if (path.length() == 0) return (required == true)?1:0; File f = new File(path); if (f.exists()) return 0; return 2; } @Override public boolean isValid(String s) { int err = pathValidate(s, required); if (err != 0) { switch(err) { case 1: component.setTooltipText("Path is required"); break; case 2: component.setTooltipText("Path doesn't exist on this filesystem!"); break; }
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/PathValidator.java import java.io.File; import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; * @param path: to validate * @param required: if path must be defined * @return int: error code * 0 - no error * 1 - required path not defined * 2 - path doesn't exist on disk */ private static int pathValidate(String path, boolean required) { assert path != null; if (path.length() == 0) return (required == true)?1:0; File f = new File(path); if (f.exists()) return 0; return 2; } @Override public boolean isValid(String s) { int err = pathValidate(s, required); if (err != 0) { switch(err) { case 1: component.setTooltipText("Path is required"); break; case 2: component.setTooltipText("Path doesn't exist on this filesystem!"); break; }
Out.print(LOG_LEVEL.DEBUG, "Path error: " + s);
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // }
import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE;
package com.dcp.sm.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application private String appName="";//Application name private String appVersion="";//Application version private int appWidth=800, appHeight=600 ;//Application dimensions private boolean resizable = false;//If window is resizable // Author private String authorName="";//Author Name private String authorEmail="";//Author Email private String appURL="";//Application URL // Resources private String readmePath="";//Readme Path private String licensePath="";//License Path private String logoPath="";//Logo Path private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // } // Path: src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE; package com.dcp.sm.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application private String appName="";//Application name private String appVersion="";//Application version private int appWidth=800, appHeight=600 ;//Application dimensions private boolean resizable = false;//If window is resizable // Author private String authorName="";//Author Name private String authorEmail="";//Author Email private String appURL="";//Application URL // Resources private String readmePath="";//Readme Path private String licensePath="";//License Path private String logoPath="";//Logo Path private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path
private SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // }
import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE;
package com.dcp.sm.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application private String appName="";//Application name private String appVersion="";//Application version private int appWidth=800, appHeight=600 ;//Application dimensions private boolean resizable = false;//If window is resizable // Author private String authorName="";//Author Name private String authorEmail="";//Author Email private String appURL="";//Application URL // Resources private String readmePath="";//Readme Path private String licensePath="";//License Path private String logoPath="";//Logo Path private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path private SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // } // Path: src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE; package com.dcp.sm.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application private String appName="";//Application name private String appVersion="";//Application version private int appWidth=800, appHeight=600 ;//Application dimensions private boolean resizable = false;//If window is resizable // Author private String authorName="";//Author Name private String authorEmail="";//Author Email private String appURL="";//Application URL // Resources private String readmePath="";//Readme Path private String licensePath="";//License Path private String logoPath="";//Logo Path private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path private SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
private SCAN_FOLDER scanFolder = SCAN_FOLDER.PACK_FOLDER;// Scan folders as packs (v1.2)
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // }
import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE;
private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path private SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2) private SCAN_FOLDER scanFolder = SCAN_FOLDER.PACK_FOLDER;// Scan folders as packs (v1.2) private boolean scanFolderTarget = false;// folder target mode (v1.2) // Configuration private String installPath = "";//Default install directory path private boolean forcePath = false;//Whether to force an install path or not private boolean registryCheck = false;//Activate registry check for installed version private boolean scriptGen = false;//Activate script generation at end of Setup // Shortcuts private boolean shortcuts = true;//Activate shortcuts creation private boolean folderShortcut = false;//Make a shortcut for global install path private boolean shToStartMenu = true;//Install shortcuts to start menu private boolean shToDesktop = false;//Install shortcuts to desktop public SetupConfig(String APPNAME, String APPVERSION) { appName = APPNAME; appVersion = APPVERSION; Map<String, String> sysEnv = System.getenv();
// Path: src/main/java/com/dcp/sm/config/io/OSValidator.java // public class OSValidator // { // private static String OS = System.getProperty("os.name").toLowerCase(); // // public static void main(String[] args) { // System.out.println(OS); // // if (isWindows()) { // System.out.println("This is Windows"); // } else if (isMac()) { // System.out.println("This is Mac"); // } else if (isUnix()) { // System.out.println("This is Unix or Linux"); // } else if (isSolaris()) { // System.out.println("This is Solaris"); // } else { // System.out.println("Your OS is not support!!"); // } // } // // public static boolean isWindows() { // return (OS.indexOf("win") >= 0); // } // // public static boolean isMac() { // return (OS.indexOf("mac") >= 0); // } // // public static boolean isUnix() { // return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); // } // // public static boolean isSolaris() { // return (OS.indexOf("sunos") >= 0); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN // } // Path: src/main/java/com/dcp/sm/logic/model/config/SetupConfig.java import java.io.Serializable; import java.util.Map; import com.dcp.sm.config.io.OSValidator; import com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER; import com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE; private String sideLogoPath="";//Side Logo Path // Langpacks private boolean lp_eng = true; private boolean lp_fra = false; private boolean lp_deu = false; private boolean lp_spa = false; private boolean lp_cus = false; private String lp_iso = "", lp_path = ""; // Scan private String srcPath = "";//Packs source path private SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2) private SCAN_FOLDER scanFolder = SCAN_FOLDER.PACK_FOLDER;// Scan folders as packs (v1.2) private boolean scanFolderTarget = false;// folder target mode (v1.2) // Configuration private String installPath = "";//Default install directory path private boolean forcePath = false;//Whether to force an install path or not private boolean registryCheck = false;//Activate registry check for installed version private boolean scriptGen = false;//Activate script generation at end of Setup // Shortcuts private boolean shortcuts = true;//Activate shortcuts creation private boolean folderShortcut = false;//Make a shortcut for global install path private boolean shToStartMenu = true;//Install shortcuts to start menu private boolean shToDesktop = false;//Install shortcuts to desktop public SetupConfig(String APPNAME, String APPVERSION) { appName = APPNAME; appVersion = APPVERSION; Map<String, String> sysEnv = System.getenv();
if (OSValidator.isWindows()) {// Windows
DevComPack/setupmaker
src/main/java/dcp/logic/model/config/SetupConfig.java
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER cast() // { // switch(this) { // case DEFAULT: // case PACK_FOLDER: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.PACK_FOLDER; // case GROUP_FOLDER: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.GROUP_FOLDER; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN; // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE cast() // { // switch(this) { // case DEFAULT: // case SIMPLE_SCAN: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.SIMPLE_SCAN; // case RECURSIVE_SCAN: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.RECURSIVE_SCAN; // } // } // }
import java.io.Serializable; import dcp.logic.factory.TypeFactory.SCAN_FOLDER; import dcp.logic.factory.TypeFactory.SCAN_MODE;
package dcp.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application public String appName="";//Application name public String appVersion="";//Application version public int appWidth=800, appHeight=600 ;//Application dimensions public boolean resizable = false;//If window is resizable // Author public String authorName="";//Author Name public String authorEmail="";//Author Email public String appURL="";//Application URL // Resources public String readmePath="";//Readme Path public String licensePath="";//License Path public String logoPath="";//Logo Path public String sideLogoPath="";//Side Logo Path // Langpacks public boolean lp_eng = true; public boolean lp_fra = false; public boolean lp_deu = false; public boolean lp_spa = false; public boolean lp_cus = false; public String lp_iso = "", lp_path = ""; // Scan public String srcPath = "";//Packs source path
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER cast() // { // switch(this) { // case DEFAULT: // case PACK_FOLDER: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.PACK_FOLDER; // case GROUP_FOLDER: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.GROUP_FOLDER; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN; // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE cast() // { // switch(this) { // case DEFAULT: // case SIMPLE_SCAN: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.SIMPLE_SCAN; // case RECURSIVE_SCAN: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.RECURSIVE_SCAN; // } // } // } // Path: src/main/java/dcp/logic/model/config/SetupConfig.java import java.io.Serializable; import dcp.logic.factory.TypeFactory.SCAN_FOLDER; import dcp.logic.factory.TypeFactory.SCAN_MODE; package dcp.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application public String appName="";//Application name public String appVersion="";//Application version public int appWidth=800, appHeight=600 ;//Application dimensions public boolean resizable = false;//If window is resizable // Author public String authorName="";//Author Name public String authorEmail="";//Author Email public String appURL="";//Application URL // Resources public String readmePath="";//Readme Path public String licensePath="";//License Path public String logoPath="";//Logo Path public String sideLogoPath="";//Side Logo Path // Langpacks public boolean lp_eng = true; public boolean lp_fra = false; public boolean lp_deu = false; public boolean lp_spa = false; public boolean lp_cus = false; public String lp_iso = "", lp_path = ""; // Scan public String srcPath = "";//Packs source path
public SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
DevComPack/setupmaker
src/main/java/dcp/logic/model/config/SetupConfig.java
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER cast() // { // switch(this) { // case DEFAULT: // case PACK_FOLDER: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.PACK_FOLDER; // case GROUP_FOLDER: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.GROUP_FOLDER; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN; // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE cast() // { // switch(this) { // case DEFAULT: // case SIMPLE_SCAN: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.SIMPLE_SCAN; // case RECURSIVE_SCAN: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.RECURSIVE_SCAN; // } // } // }
import java.io.Serializable; import dcp.logic.factory.TypeFactory.SCAN_FOLDER; import dcp.logic.factory.TypeFactory.SCAN_MODE;
package dcp.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application public String appName="";//Application name public String appVersion="";//Application version public int appWidth=800, appHeight=600 ;//Application dimensions public boolean resizable = false;//If window is resizable // Author public String authorName="";//Author Name public String authorEmail="";//Author Email public String appURL="";//Application URL // Resources public String readmePath="";//Readme Path public String licensePath="";//License Path public String logoPath="";//Logo Path public String sideLogoPath="";//Side Logo Path // Langpacks public boolean lp_eng = true; public boolean lp_fra = false; public boolean lp_deu = false; public boolean lp_spa = false; public boolean lp_cus = false; public String lp_iso = "", lp_path = ""; // Scan public String srcPath = "";//Packs source path public SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_FOLDER { // DEFAULT("pack"), // PACK_FOLDER("pack"),//Default // GROUP_FOLDER("group"); // // private String _value; // private SCAN_FOLDER(String value) // { // _value = value; // } // @Override // public String toString() // { // return this._value; // } // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER cast() // { // switch(this) { // case DEFAULT: // case PACK_FOLDER: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.PACK_FOLDER; // case GROUP_FOLDER: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_FOLDER.GROUP_FOLDER; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum SCAN_MODE { // DEFAULT, // SIMPLE_SCAN,//Default // RECURSIVE_SCAN; // // public com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE cast() // { // switch(this) { // case DEFAULT: // case SIMPLE_SCAN: // default: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.SIMPLE_SCAN; // case RECURSIVE_SCAN: // return com.dcp.sm.logic.factory.TypeFactory.SCAN_MODE.RECURSIVE_SCAN; // } // } // } // Path: src/main/java/dcp/logic/model/config/SetupConfig.java import java.io.Serializable; import dcp.logic.factory.TypeFactory.SCAN_FOLDER; import dcp.logic.factory.TypeFactory.SCAN_MODE; package dcp.logic.model.config; /** * IzPack exported setup info configuration */ public class SetupConfig implements Serializable { /** * Generated serial for file save */ private static final long serialVersionUID = 4289372637132381636L; // Application public String appName="";//Application name public String appVersion="";//Application version public int appWidth=800, appHeight=600 ;//Application dimensions public boolean resizable = false;//If window is resizable // Author public String authorName="";//Author Name public String authorEmail="";//Author Email public String appURL="";//Application URL // Resources public String readmePath="";//Readme Path public String licensePath="";//License Path public String logoPath="";//Logo Path public String sideLogoPath="";//Side Logo Path // Langpacks public boolean lp_eng = true; public boolean lp_fra = false; public boolean lp_deu = false; public boolean lp_spa = false; public boolean lp_cus = false; public String lp_iso = "", lp_path = ""; // Scan public String srcPath = "";//Packs source path public SCAN_MODE scanMode = SCAN_MODE.SIMPLE_SCAN;// Scan mode (v1.2)
public SCAN_FOLDER scanFolder = SCAN_FOLDER.PACK_FOLDER;// Scan folders as packs (v1.2)
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/Iso3Validator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class Iso3Validator implements Validator { @Override public boolean isValid(String s) { if (s.equals(""))//Empty string return true; if (s.length() != 3) {// should be 3 characters
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/Iso3Validator.java import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class Iso3Validator implements Validator { @Override public boolean isValid(String s) { if (s.equals(""))//Empty string return true; if (s.length() != 3) {// should be 3 characters
Out.print(LOG_LEVEL.DEBUG, "ISO3 format incorrect: " + s);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/Iso3Validator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class Iso3Validator implements Validator { @Override public boolean isValid(String s) { if (s.equals(""))//Empty string return true; if (s.length() != 3) {// should be 3 characters
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/Iso3Validator.java import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class Iso3Validator implements Validator { @Override public boolean isValid(String s) { if (s.equals(""))//Empty string return true; if (s.length() != 3) {// should be 3 characters
Out.print(LOG_LEVEL.DEBUG, "ISO3 format incorrect: " + s);
DevComPack/setupmaker
src/test/java/com/dcp/setupmaker/AppTest.java
// Path: src/main/java/com/dcp/sm/App.java // public class App // { // public static void main( String[] args ) // { // if (args.length > 0) // Command Line Function // { // Out.setLogger(null); // Out.print(LOG_LEVEL.INFO, "Command Line compiling enabled"); // Out.print(LOG_LEVEL.INFO, "Loading application..."); // new Master(); // // for (String s: args) { // if (new File(s).exists() && s.endsWith(".dcp")) { // Out.print(LOG_LEVEL.INFO, "Processing dcp file: " + s); // System.out.println(); // // Master.facade.process(s);// compile save file with izpack // } // else { // Out.print(LOG_LEVEL.ERR, "Filepath doesn't exist or file is incorrect! Please give a valid path to a dcp save file."); // } // } // } // else // GUI Application // { // // Apache Pivot bugfix for Java VM versions containing '_' // String javaVersionFix = System.getProperty("java.runtime.version").split("_")[0]; // System.setProperty("java.vm.version", javaVersionFix); // Out.print(LOG_LEVEL.INFO, "Fixing Java version to v" + System.getProperty("java.vm.version")); // // DesktopApplicationContext.main(Master.class, args); // } // } // }
import static org.junit.Assert.*; import java.io.File; import org.junit.Ignore; import org.junit.Test; import com.dcp.sm.App;
package com.dcp.setupmaker; public class AppTest { @Ignore @Test public void testCL() { String[] args = {"saves/dcp.dcp"};
// Path: src/main/java/com/dcp/sm/App.java // public class App // { // public static void main( String[] args ) // { // if (args.length > 0) // Command Line Function // { // Out.setLogger(null); // Out.print(LOG_LEVEL.INFO, "Command Line compiling enabled"); // Out.print(LOG_LEVEL.INFO, "Loading application..."); // new Master(); // // for (String s: args) { // if (new File(s).exists() && s.endsWith(".dcp")) { // Out.print(LOG_LEVEL.INFO, "Processing dcp file: " + s); // System.out.println(); // // Master.facade.process(s);// compile save file with izpack // } // else { // Out.print(LOG_LEVEL.ERR, "Filepath doesn't exist or file is incorrect! Please give a valid path to a dcp save file."); // } // } // } // else // GUI Application // { // // Apache Pivot bugfix for Java VM versions containing '_' // String javaVersionFix = System.getProperty("java.runtime.version").split("_")[0]; // System.setProperty("java.vm.version", javaVersionFix); // Out.print(LOG_LEVEL.INFO, "Fixing Java version to v" + System.getProperty("java.vm.version")); // // DesktopApplicationContext.main(Master.class, args); // } // } // } // Path: src/test/java/com/dcp/setupmaker/AppTest.java import static org.junit.Assert.*; import java.io.File; import org.junit.Ignore; import org.junit.Test; import com.dcp.sm.App; package com.dcp.setupmaker; public class AppTest { @Ignore @Test public void testCL() { String[] args = {"saves/dcp.dcp"};
App.main(args);
DevComPack/setupmaker
src/main/java/com/dcp/sm/web/sftp/JschFactory.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpProgressMonitor; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
session.setOutputStream(System.out); session.setConfig("StrictHostKeyChecking", "no"); session.setTimeout(30000); session.connect(); channel = session.openChannel("sftp"); channel.setOutputStream(System.out); channel.connect(); } /** * Send a file to server path via SFTP * @param src * @param path * @throws SftpException */ public void put(final File src, String path) throws SftpException { if (!path.endsWith("/")) path = path.concat("/"); if (path.startsWith("/")) path = path.substring(1); ChannelSftp sftp = (ChannelSftp) channel; SftpProgressMonitor progress = new SftpProgressMonitor() { @Override public void init(int arg0, String arg1, String arg2, long arg3) { System.out.println("File transfer begin.."); } @Override public void end() {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/web/sftp/JschFactory.java import java.io.File; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpProgressMonitor; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; session.setOutputStream(System.out); session.setConfig("StrictHostKeyChecking", "no"); session.setTimeout(30000); session.connect(); channel = session.openChannel("sftp"); channel.setOutputStream(System.out); channel.connect(); } /** * Send a file to server path via SFTP * @param src * @param path * @throws SftpException */ public void put(final File src, String path) throws SftpException { if (!path.endsWith("/")) path = path.concat("/"); if (path.startsWith("/")) path = path.substring(1); ChannelSftp sftp = (ChannelSftp) channel; SftpProgressMonitor progress = new SftpProgressMonitor() { @Override public void init(int arg0, String arg1, String arg2, long arg3) { System.out.println("File transfer begin.."); } @Override public void end() {
Out.print(LOG_LEVEL.INFO, "Upload of file "+ src.getName() +" succeeded.");
DevComPack/setupmaker
src/main/java/com/dcp/sm/web/sftp/JschFactory.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpProgressMonitor; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
session.setOutputStream(System.out); session.setConfig("StrictHostKeyChecking", "no"); session.setTimeout(30000); session.connect(); channel = session.openChannel("sftp"); channel.setOutputStream(System.out); channel.connect(); } /** * Send a file to server path via SFTP * @param src * @param path * @throws SftpException */ public void put(final File src, String path) throws SftpException { if (!path.endsWith("/")) path = path.concat("/"); if (path.startsWith("/")) path = path.substring(1); ChannelSftp sftp = (ChannelSftp) channel; SftpProgressMonitor progress = new SftpProgressMonitor() { @Override public void init(int arg0, String arg1, String arg2, long arg3) { System.out.println("File transfer begin.."); } @Override public void end() {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/web/sftp/JschFactory.java import java.io.File; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpProgressMonitor; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; session.setOutputStream(System.out); session.setConfig("StrictHostKeyChecking", "no"); session.setTimeout(30000); session.connect(); channel = session.openChannel("sftp"); channel.setOutputStream(System.out); channel.connect(); } /** * Send a file to server path via SFTP * @param src * @param path * @throws SftpException */ public void put(final File src, String path) throws SftpException { if (!path.endsWith("/")) path = path.concat("/"); if (path.startsWith("/")) path = path.substring(1); ChannelSftp sftp = (ChannelSftp) channel; SftpProgressMonitor progress = new SftpProgressMonitor() { @Override public void init(int arg0, String arg1, String arg2, long arg3) { System.out.println("File transfer begin.."); } @Override public void end() {
Out.print(LOG_LEVEL.INFO, "Upload of file "+ src.getName() +" succeeded.");
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/BatWriter.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.io; public class BatWriter { private File file; public String getTargetFile() throws IOException { return file.getCanonicalPath(); } public BatWriter(String FILE_PATH) throws IOException { file = new File(FILE_PATH); if (!file.exists()) file.createNewFile(); } //Write setup install batch commands //cmd: msiexec /package "path/to/setupFile.msi" /passive /norestart public void writeSetup(String pack_name, boolean silent_install) throws IOException {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/io/BatWriter.java import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.io; public class BatWriter { private File file; public String getTargetFile() throws IOException { return file.getCanonicalPath(); } public BatWriter(String FILE_PATH) throws IOException { file = new File(FILE_PATH); if (!file.exists()) file.createNewFile(); } //Write setup install batch commands //cmd: msiexec /package "path/to/setupFile.msi" /passive /norestart public void writeSetup(String pack_name, boolean silent_install) throws IOException {
Out.print(LOG_LEVEL.INFO, "Writing setup command to: " + file.getAbsolutePath());
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/BatWriter.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.io; public class BatWriter { private File file; public String getTargetFile() throws IOException { return file.getCanonicalPath(); } public BatWriter(String FILE_PATH) throws IOException { file = new File(FILE_PATH); if (!file.exists()) file.createNewFile(); } //Write setup install batch commands //cmd: msiexec /package "path/to/setupFile.msi" /passive /norestart public void writeSetup(String pack_name, boolean silent_install) throws IOException {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/io/BatWriter.java import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.io; public class BatWriter { private File file; public String getTargetFile() throws IOException { return file.getCanonicalPath(); } public BatWriter(String FILE_PATH) throws IOException { file = new File(FILE_PATH); if (!file.exists()) file.createNewFile(); } //Write setup install batch commands //cmd: msiexec /package "path/to/setupFile.msi" /passive /norestart public void writeSetup(String pack_name, boolean silent_install) throws IOException {
Out.print(LOG_LEVEL.INFO, "Writing setup command to: " + file.getAbsolutePath());
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> {
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> {
IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> { IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class String appName; public TaskIzpackRun(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);;
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> { IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class String appName; public TaskIzpackRun(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);;
Out.setLogger(LOGGER);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> { IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class String appName; public TaskIzpackRun(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);; Out.setLogger(LOGGER); this.appName = appName; } @Override public Boolean execute() throws TaskExecutionException { try { if (compiler.run(appName) != 0)
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackRun.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackRun extends Task<Boolean> { IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class String appName; public TaskIzpackRun(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);; Out.setLogger(LOGGER); this.appName = appName; } @Override public Boolean execute() throws TaskExecutionException { try { if (compiler.run(appName) != 0)
Out.print(LOG_LEVEL.ERR, "Install aborted!");
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/VersionValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class VersionValidator implements Validator { private Component component; private String tooltipText = "Version"; private boolean required; public VersionValidator(Component component, boolean required) { assert component != null; this.component = component; this.required = required; } @Override public boolean isValid(String str) { if (str.length() == 0) return !required; if (str.length() > 20 || !str.matches("[0-9]+([.][0-9]+)*")) { component.setTooltipText("[Version format incorrect x[.x]*]");
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/VersionValidator.java import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class VersionValidator implements Validator { private Component component; private String tooltipText = "Version"; private boolean required; public VersionValidator(Component component, boolean required) { assert component != null; this.component = component; this.required = required; } @Override public boolean isValid(String str) { if (str.length() == 0) return !required; if (str.length() > 20 || !str.matches("[0-9]+([.][0-9]+)*")) { component.setTooltipText("[Version format incorrect x[.x]*]");
Out.print(LOG_LEVEL.DEBUG, "Pack version format incorrect: " + str);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/VersionValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class VersionValidator implements Validator { private Component component; private String tooltipText = "Version"; private boolean required; public VersionValidator(Component component, boolean required) { assert component != null; this.component = component; this.required = required; } @Override public boolean isValid(String str) { if (str.length() == 0) return !required; if (str.length() > 20 || !str.matches("[0-9]+([.][0-9]+)*")) { component.setTooltipText("[Version format incorrect x[.x]*]");
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/VersionValidator.java import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class VersionValidator implements Validator { private Component component; private String tooltipText = "Version"; private boolean required; public VersionValidator(Component component, boolean required) { assert component != null; this.component = component; this.required = required; } @Override public boolean isValid(String str) { if (str.length() == 0) return !required; if (str.length() > 20 || !str.matches("[0-9]+([.][0-9]+)*")) { component.setTooltipText("[Version format incorrect x[.x]*]");
Out.print(LOG_LEVEL.DEBUG, "Pack version format incorrect: " + str);
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/Pack.java
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // }
import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM;
package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // } // Path: src/main/java/com/dcp/sm/logic/model/Pack.java import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM; package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name
private FILE_TYPE fileType = FILE_TYPE.File;//File type
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/Pack.java
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // }
import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM;
package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name private FILE_TYPE fileType = FILE_TYPE.File;//File type private double size = 0;//File Size in bytes private String path = "";//File Absolute Path
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // } // Path: src/main/java/com/dcp/sm/logic/model/Pack.java import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM; package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name private FILE_TYPE fileType = FILE_TYPE.File;//File type private double size = 0;//File Size in bytes private String path = "";//File Absolute Path
private INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
DevComPack/setupmaker
src/main/java/com/dcp/sm/logic/model/Pack.java
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // }
import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM;
package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name private FILE_TYPE fileType = FILE_TYPE.File;//File type private double size = 0;//File Size in bytes private String path = "";//File Absolute Path private INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
// Path: src/main/java/com/dcp/sm/logic/factory/GroupFactory.java // public class GroupFactory // { // private static List<Group> groups = new ArrayList<Group>(); // public static List<Group> getGroups() { return groups; } // // //Returns Group of PATH // public static Group get(String[] path) { // return get(CastFactory.pathToString(path)); // } // public static Group get(String path) { // if (path == null) return null; // for(Group G:groups) // if (G.getPath().equalsIgnoreCase(path)) // return G; // return null; // } // public static List<Group> getByName(String name) { // if (name==null) return null; // List<Group> list = new ArrayList<Group>(); // for(Group G:groups) // if (G.getName().equalsIgnoreCase(name)) // list.add(G); // return list; // } // // //Returns index of Group or -1 if not found // public static int indexOf(Group G) { // return groups.indexOf(G); // } // // //Add a new group // public static boolean addGroup(Group group) { // if (indexOf(group) == -1) {//Group not already created // groups.add(group); // if (group.getParent() != null) {//Has parent group // group.getParent().addChild(group);//Set the parent's child // } // Out.print(LOG_LEVEL.DEBUG, "Group added: " + group.getName()); // return true; // } // else {//Group already present // return false; // } // } // // //Remove a group (+sub groups) // public static void removeGroup(Group group) { // if (group.getParent() != null) {//If has parent // Group PARENT = group.getParent(); // PARENT.removeChild(group);//Cascade delete // } // for (Group G:group.getChildren())//Childs delete // groups.remove(G); // // String name = group.getName(); // groups.remove(group); // Out.print(LOG_LEVEL.DEBUG, "Group deleted with cascade: " + name); // } // // //Clear all groups // public static void clear() { // groups.clear(); // Out.print(LOG_LEVEL.DEBUG, "All Groups erased."); // } // // //Returns Group root of G // public static Group getRoot(Group group) { // if (group.getParent() != null) { // Group ROOT = group.getParent(); // while(ROOT.getParent() != null) // ROOT = ROOT.getParent(); // return ROOT; // } // else return group;//Is a root // } // // //Returns the roots // public static List<Group> getRoots() { // List<Group> ROOTS = new ArrayList<Group>(); // for(Group G:groups) // if (G.getParent() == null) // ROOTS.add(G); // return ROOTS; // } // // public static boolean hasParent(Group src, Group trgt) { // assert trgt != null; // if (src.equals(trgt)) // return true; // if (src.getParent() != null) // return hasParent(src.getParent(), trgt); // return false; // } // // //Returns path from root to Group // public static String[] getPath(Group group) { // java.util.List<String> backList = new java.util.ArrayList<String>(); // //Return back in hierarchy // Group Gtmp = group; // do { // backList.add(Gtmp.getName()); // Gtmp = Gtmp.getParent(); // } while(Gtmp != null); // //Copy the hierarchy from top to bottom // String[] PATH = new String[backList.size()]; // int i = 0; // for(ListIterator<String> it = backList.listIterator(backList.size()); // it.hasPrevious();) { // PATH[i++] = it.previous(); // } // return PATH; // } // // /** // * @return groups length // */ // public static int getCount() // { // return groups.getLength(); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC // } // Path: src/main/java/com/dcp/sm/logic/model/Pack.java import java.io.File; import java.io.Serializable; import java.util.regex.Pattern; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.content.TreeNode; import org.apache.pivot.wtk.media.Image; import com.dcp.sm.logic.factory.GroupFactory; import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE; import com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE; import com.dcp.sm.logic.factory.TypeFactory.PLATFORM; package com.dcp.sm.logic.model; /** * Pack Model * @author Said * */ public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations private Group group = null;//Pack member of this group private String installGroups = "";//Install Groups * private Group dependsOnGroup = null;//Group dependency private Pack dependsOnPack = null;//Pack dependency //Attributes private String name = "";//File Name private FILE_TYPE fileType = FILE_TYPE.File;//File type private double size = 0;//File Size in bytes private String path = "";//File Absolute Path private INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
private PLATFORM installOs = PLATFORM.ALL;//Install OS
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/compile/AntCompiler.java
// Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import com.dcp.sm.main.log.Out;
consoleLogger.setErrorPrintStream(System.err); consoleLogger.setMessageOutputLevel(Project.MSG_INFO); project.addBuildListener(consoleLogger); //Log using Out class project.addBuildListener(new BuildListener() { @Override public void taskStarted(BuildEvent ev) { } @Override public void taskFinished(BuildEvent ev) { } @Override public void targetStarted(BuildEvent ev) { } @Override public void targetFinished(BuildEvent ev) { } @Override public void messageLogged(BuildEvent ev) { if (ev.getPriority() == Project.MSG_INFO || //ev.getPriority() == Project.MSG_VERBOSE || ev.getPriority() == Project.MSG_WARN || ev.getPriority() == Project.MSG_ERR)
// Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/compile/AntCompiler.java import java.io.File; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import com.dcp.sm.main.log.Out; consoleLogger.setErrorPrintStream(System.err); consoleLogger.setMessageOutputLevel(Project.MSG_INFO); project.addBuildListener(consoleLogger); //Log using Out class project.addBuildListener(new BuildListener() { @Override public void taskStarted(BuildEvent ev) { } @Override public void taskFinished(BuildEvent ev) { } @Override public void targetStarted(BuildEvent ev) { } @Override public void targetFinished(BuildEvent ev) { } @Override public void messageLogged(BuildEvent ev) { if (ev.getPriority() == Project.MSG_INFO || //ev.getPriority() == Project.MSG_VERBOSE || ev.getPriority() == Project.MSG_WARN || ev.getPriority() == Project.MSG_ERR)
Out.log(log_tag.toLowerCase()+"> "+ev.getMessage());
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> {
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> {
private IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> { private IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class private String appName; public TaskIzpackDebug(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> { private IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class private String appName; public TaskIzpackDebug(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath);
Out.setLogger(LOGGER);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> { private IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class private String appName; public TaskIzpackDebug(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath); Out.setLogger(LOGGER); this.appName = appName; } @Override public Boolean execute() throws TaskExecutionException { try { if (compiler.debug(appName) == 0) {
// Path: src/main/java/com/dcp/sm/config/compile/IzpackAntCompiler.java // public class IzpackAntCompiler { // // private String target_file = ""; // // /** // * Change the target file // * @param TARGET_FILE // */ // public void setTarget(String TARGET_FILE) { // target_file = TARGET_FILE; // } // /** // * Get target install file // * @return // */ // public String getTarget() { // return target_file; // } // // /** // * Compile IzPack using Ant Task defined target // * @return int // */ // private int antCompile() { // AntCompiler comp = new AntCompiler(IOFactory.xmlIzpackAntBuild, "izpack"); // // comp.runTarget("izpack-standalone"); // return 0; // } // // /** // * Public compile function, uses one compile method from above // * @return int // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int compile() throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // { // return antCompile(); // } // // /** // * Run IzPack generated package using Ant Task defined target with Trace mode enabled // * @return int // */ // private int antDebug(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlDebugAntBuild, appName); // // comp.runTarget("debug"); // return 0; // } // // /** // * Public debug function, uses one compile method from above // * @throws IOException // * @throws InterruptedException // */ // public int debug(String appName) throws IOException, InterruptedException { // return antDebug(appName); // } // // /** // * Run IzPack generated package using Ant Task defined target // * @return int // */ // private int antRun(String appName) { // AntCompiler comp = new AntCompiler(IOFactory.xmlRunAntBuild, appName); // // comp.runTarget("run"); // return 0; // } // // /** // * Public run function, uses one run method from above // * @throws IOException // * @throws InterruptedException // * @throws IllegalArgumentException // * @throws IllegalAccessException // * @throws InvocationTargetException // */ // public int run(String appName) throws IOException, InterruptedException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // return antRun(appName); // } // // } // // Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/tasks/TaskIzpackDebug.java import java.io.IOException; import org.apache.pivot.util.concurrent.Task; import org.apache.pivot.util.concurrent.TaskExecutionException; import org.apache.pivot.wtk.Component; import com.dcp.sm.config.compile.IzpackAntCompiler; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.tasks; public class TaskIzpackDebug extends Task<Boolean> { private IzpackAntCompiler compiler = new IzpackAntCompiler();//IzPack Compiler Class private String appName; public TaskIzpackDebug(String TargetPath, Component LOGGER, String appName) { compiler.setTarget(TargetPath); Out.setLogger(LOGGER); this.appName = appName; } @Override public Boolean execute() throws TaskExecutionException { try { if (compiler.debug(appName) == 0) {
Out.print(LOG_LEVEL.INFO, "Install success.");
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/frames/SftpDialog.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/WebConfig.java // public class WebConfig implements Serializable // { // /** // * web configuration saved on the web.dcp file // */ // private static final long serialVersionUID = 1439240538763028358L; // // transient private boolean enabled = false; // if web mode is enabled // // private String host = ""; // private String user = ""; // private String pass = ""; // private String remoteDir = ""; // private String path = ""; // // // public WebConfig() // { // } // public WebConfig(WebConfig webConfig) // { // this.host = webConfig.host; // this.user = webConfig.user; // this.pass = webConfig.pass; // this.remoteDir = webConfig.remoteDir; // this.path = webConfig.path; // } // // // public boolean isEnabled() // { // return enabled; // } // public void setEnabled(boolean enabled) // { // this.enabled = enabled; // } // // public String getHost() // { // return host; // } // public void setHost(String host) // { // this.host = host; // } // public String getUser() // { // return user; // } // public void setUser(String user) // { // this.user = user; // } // public String getPass() // { // return pass; // } // public void setPass(String pass) // { // this.pass = pass; // } // public String getRemoteDir() // { // return remoteDir; // } // public void setRemoteDir(String remoteDir) // { // this.remoteDir = remoteDir; // } // public String getPath() // { // return path; // } // public void setPath(String path) // { // this.path = path; // } // // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.URL; import org.apache.pivot.beans.BXML; import org.apache.pivot.beans.Bindable; import org.apache.pivot.collections.Map; import org.apache.pivot.util.Resources; import org.apache.pivot.wtk.Border; import org.apache.pivot.wtk.Button; import org.apache.pivot.wtk.ButtonPressListener; import org.apache.pivot.wtk.ButtonStateListener; import org.apache.pivot.wtk.Checkbox; import org.apache.pivot.wtk.Dialog; import org.apache.pivot.wtk.PushButton; import org.apache.pivot.wtk.TextInput; import org.apache.pivot.wtk.TextInputContentListener; import org.apache.pivot.wtk.Button.State; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.logic.model.config.build.WebConfig; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.frames; /** * SFTP Dialog * @author ssaideli * */ public class SftpDialog extends Dialog implements Bindable { @BXML private Checkbox cbEnable; @BXML private Border formArea; @BXML private TextInput inHost; @BXML private TextInput inUser; @BXML private TextInput inPass; @BXML private TextInput inRemDir; @BXML private TextInput inPath; @BXML private PushButton btSave, btLoad;
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/logic/model/config/build/WebConfig.java // public class WebConfig implements Serializable // { // /** // * web configuration saved on the web.dcp file // */ // private static final long serialVersionUID = 1439240538763028358L; // // transient private boolean enabled = false; // if web mode is enabled // // private String host = ""; // private String user = ""; // private String pass = ""; // private String remoteDir = ""; // private String path = ""; // // // public WebConfig() // { // } // public WebConfig(WebConfig webConfig) // { // this.host = webConfig.host; // this.user = webConfig.user; // this.pass = webConfig.pass; // this.remoteDir = webConfig.remoteDir; // this.path = webConfig.path; // } // // // public boolean isEnabled() // { // return enabled; // } // public void setEnabled(boolean enabled) // { // this.enabled = enabled; // } // // public String getHost() // { // return host; // } // public void setHost(String host) // { // this.host = host; // } // public String getUser() // { // return user; // } // public void setUser(String user) // { // this.user = user; // } // public String getPass() // { // return pass; // } // public void setPass(String pass) // { // this.pass = pass; // } // public String getRemoteDir() // { // return remoteDir; // } // public void setRemoteDir(String remoteDir) // { // this.remoteDir = remoteDir; // } // public String getPath() // { // return path; // } // public void setPath(String path) // { // this.path = path; // } // // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/frames/SftpDialog.java import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.URL; import org.apache.pivot.beans.BXML; import org.apache.pivot.beans.Bindable; import org.apache.pivot.collections.Map; import org.apache.pivot.util.Resources; import org.apache.pivot.wtk.Border; import org.apache.pivot.wtk.Button; import org.apache.pivot.wtk.ButtonPressListener; import org.apache.pivot.wtk.ButtonStateListener; import org.apache.pivot.wtk.Checkbox; import org.apache.pivot.wtk.Dialog; import org.apache.pivot.wtk.PushButton; import org.apache.pivot.wtk.TextInput; import org.apache.pivot.wtk.TextInputContentListener; import org.apache.pivot.wtk.Button.State; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.logic.model.config.build.WebConfig; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.frames; /** * SFTP Dialog * @author ssaideli * */ public class SftpDialog extends Dialog implements Bindable { @BXML private Checkbox cbEnable; @BXML private Border formArea; @BXML private TextInput inHost; @BXML private TextInput inUser; @BXML private TextInput inPass; @BXML private TextInput inRemDir; @BXML private TextInput inPath; @BXML private PushButton btSave, btLoad;
private WebConfig webConfig;
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/NameValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class NameValidator implements Validator { private Component component; private String tooltipText = "Name"; private boolean required; private boolean id; public NameValidator(Component component, boolean required, boolean id) { assert component != null; this.component = component; this.required = required; this.id = id; } @Override public boolean isValid(String str) { if (str.length() == 0) return !this.required; if (!(str.matches("[a-zA-Z._\\-0-9]+") || (!id && str.matches("[a-zA-Z._\\-0-9 ]+")) )) {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/NameValidator.java import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class NameValidator implements Validator { private Component component; private String tooltipText = "Name"; private boolean required; private boolean id; public NameValidator(Component component, boolean required, boolean id) { assert component != null; this.component = component; this.required = required; this.id = id; } @Override public boolean isValid(String str) { if (str.length() == 0) return !this.required; if (!(str.matches("[a-zA-Z._\\-0-9]+") || (!id && str.matches("[a-zA-Z._\\-0-9 ]+")) )) {
Out.print(LOG_LEVEL.DEBUG, "Pack name incorrect: " + str);
DevComPack/setupmaker
src/main/java/com/dcp/sm/gui/pivot/validators/NameValidator.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.gui.pivot.validators; public class NameValidator implements Validator { private Component component; private String tooltipText = "Name"; private boolean required; private boolean id; public NameValidator(Component component, boolean required, boolean id) { assert component != null; this.component = component; this.required = required; this.id = id; } @Override public boolean isValid(String str) { if (str.length() == 0) return !this.required; if (!(str.matches("[a-zA-Z._\\-0-9]+") || (!id && str.matches("[a-zA-Z._\\-0-9 ]+")) )) {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/gui/pivot/validators/NameValidator.java import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.validation.Validator; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.gui.pivot.validators; public class NameValidator implements Validator { private Component component; private String tooltipText = "Name"; private boolean required; private boolean id; public NameValidator(Component component, boolean required, boolean id) { assert component != null; this.component = component; this.required = required; this.id = id; } @Override public boolean isValid(String str) { if (str.length() == 0) return !this.required; if (!(str.matches("[a-zA-Z._\\-0-9]+") || (!id && str.matches("[a-zA-Z._\\-0-9 ]+")) )) {
Out.print(LOG_LEVEL.DEBUG, "Pack name incorrect: " + str);
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/TextWriter.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.io; public class TextWriter { //Setting default install directory (in res/default-dir.txt) public static void writeInstallPath(String path) throws IOException {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/io/TextWriter.java import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.io; public class TextWriter { //Setting default install directory (in res/default-dir.txt) public static void writeInstallPath(String path) throws IOException {
Out.print(LOG_LEVEL.INFO, "Setting default output directory: " + path);
DevComPack/setupmaker
src/main/java/com/dcp/sm/config/io/TextWriter.java
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // }
import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out;
package com.dcp.sm.config.io; public class TextWriter { //Setting default install directory (in res/default-dir.txt) public static void writeInstallPath(String path) throws IOException {
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java // public enum LOG_LEVEL { // DEBUG(0, "DEBUG"), // INFO(1, "INFO"), // WARN(2, "WARNING"), // ERR(3, "ERROR"); // // private int _level; // private String _tag; // private LOG_LEVEL(int level, String tag) // { // _level = level; // _tag = tag; // } // @Override // public String toString() // { // return this._tag; // } // // public int value() // { // return this._level; // } // } // // Path: src/main/java/com/dcp/sm/main/log/Out.java // public class Out // { // //Log // private static List<String> log = new ArrayList<String>();//Global Log // public static List<String> getLog() { return log; } // private static int displayLevel = 1;//logs to display must be >= than this // // private static List<String> compileLog = new ArrayList<String>();//Izpack compile Log // public static List<String> getCompileLog() { return compileLog; } // // //Pivot GUI Component Repaint for log update // private static Component logger = null; // public static Component getLogger() { return logger; } // public static void setLogger(Component logger) { Out.logger = logger; } // // //Clear the stream cache // public static void clearCompileLog() { // compileLog.clear(); // } // // //Add a new empty line // public static void newLine() { // print(LOG_LEVEL.INFO, ""); // } // // /** // * Prints a string to the output stream // * @param text: log text // * @param outStream: output stream // */ // public static void print(String text, PrintStream outStream) { // outStream.println(text); // } // // /** // * print text with a tag // * format: [TAG] TXT // * @param TAG: tag name // * @param TXT: text to log // */ // public static void print(LOG_LEVEL level, String msg) { // print("["+level.toString()+"] "+msg, System.out); // log.add(msg); // final String log_TXT = msg; // // if (level.value() >= displayLevel)// display if >= than threshold // log(log_TXT); // } // // public static void log(final String msg) { // ApplicationContext.queueCallback(new Runnable() {//Enqueue GUI display repaint // @Override public void run() // { // compileLog.add(msg); // if (getLogger() != null) getLogger().repaint();//Component update // } // }); // } // // } // Path: src/main/java/com/dcp/sm/config/io/TextWriter.java import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.dcp.sm.logic.factory.TypeFactory.LOG_LEVEL; import com.dcp.sm.main.log.Out; package com.dcp.sm.config.io; public class TextWriter { //Setting default install directory (in res/default-dir.txt) public static void writeInstallPath(String path) throws IOException {
Out.print(LOG_LEVEL.INFO, "Setting default output directory: " + path);
DevComPack/setupmaker
src/main/java/dcp/logic/model/Pack.java
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // }
import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM;
package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // } // Path: src/main/java/dcp/logic/model/Pack.java import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM; package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name
public FILE_TYPE fileType = FILE_TYPE.File;//File type
DevComPack/setupmaker
src/main/java/dcp/logic/model/Pack.java
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // }
import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM;
package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name public FILE_TYPE fileType = FILE_TYPE.File;//File type public double size = 0;//File Size in bytes public String path = "";//File Absolute Path
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // } // Path: src/main/java/dcp/logic/model/Pack.java import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM; package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name public FILE_TYPE fileType = FILE_TYPE.File;//File type public double size = 0;//File Size in bytes public String path = "";//File Absolute Path
public INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
DevComPack/setupmaker
src/main/java/dcp/logic/model/Pack.java
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // }
import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM;
package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name public FILE_TYPE fileType = FILE_TYPE.File;//File type public double size = 0;//File Size in bytes public String path = "";//File Absolute Path public INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
// Path: src/main/java/dcp/logic/factory/TypeFactory.java // public static enum FILE_TYPE { // File, // Folder, // Archive, // Executable, // Setup, // Document, // Image, // Web, // Sound, // Video, // Custom; // // public com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE cast() // { // switch(this) { // case File: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.File; // case Folder: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Folder; // case Archive: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Archive; // case Executable: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Executable; // case Setup: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Setup; // case Document: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Document; // case Image: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Image; // case Web: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Web; // case Sound: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Sound; // case Video: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Video; // case Custom: // default: // return com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE.Custom; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum INSTALL_TYPE { // DEFAULT, // COPY, // EXTRACT, // EXECUTE; // // public com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE cast() // { // switch(this) { // default: // case DEFAULT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.DEFAULT; // case COPY: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.COPY; // case EXTRACT: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXTRACT; // case EXECUTE: // return com.dcp.sm.logic.factory.TypeFactory.INSTALL_TYPE.EXECUTE; // } // } // } // // Path: src/main/java/dcp/logic/factory/TypeFactory.java // public enum PLATFORM { // ALL, // WINDOWS, // LINUX, // MAC; // // public com.dcp.sm.logic.factory.TypeFactory.PLATFORM cast() // { // switch(this) { // default: // case ALL: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.ALL; // case WINDOWS: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.WINDOWS; // case LINUX: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.LINUX; // case MAC: // return com.dcp.sm.logic.factory.TypeFactory.PLATFORM.MAC; // } // } // } // Path: src/main/java/dcp/logic/model/Pack.java import java.io.Serializable; import dcp.logic.factory.TypeFactory.FILE_TYPE; import dcp.logic.factory.TypeFactory.INSTALL_TYPE; import dcp.logic.factory.TypeFactory.PLATFORM; package dcp.logic.model; public class Pack implements Serializable { /** * Write Pack data to save file */ private static final long serialVersionUID = -8775694196832301518L; //Relations public Group group = null;//Pack member of this group public String installGroups = "";//Install Groups * public Group dependsOnGroup = null;//Group dependency public Pack dependsOnPack = null;//Pack dependency //Attributes public String name = "";//File Name public FILE_TYPE fileType = FILE_TYPE.File;//File type public double size = 0;//File Size in bytes public String path = "";//File Absolute Path public INSTALL_TYPE installType = INSTALL_TYPE.COPY;//Install Type
public PLATFORM installOs = PLATFORM.ALL;//Install OS
onebeartoe/media-players
music-visualizer/src/main/java/org/onebeartoe/fxexperienceplayer/FxExperiencePlayer.java
// Path: music-visualizer/src/main/java/org/onebeartoe/juke/javafx/demo/MusicVisualizerLedMatrixListener.java // public class MusicVisualizerLedMatrixListener implements LedMatrixListener // { // private Pixel pixel; // // private PixelEnvironment pixelEnvironment; // // public MusicVisualizerLedMatrixListener(PixelEnvironment environment) // { // pixelEnvironment = environment; // } // // @Override // public Pixel getPixel() // { // return pixel; // } // // @Override // public void ledMatrixReady(RgbLedMatrix matrix) // { // pixel = new Pixel(pixelEnvironment.LED_MATRIX, pixelEnvironment.currentResolution); // pixel.matrix = matrix; // // scrollWelcomeMessage(); // // // delay for a bit // Sleeper.sleepo(3000); // // pixel.stopExistingTimer(); // // // // } // // private void scrollWelcomeMessage() // { // pixel.setScrollingText("Music Visualizer"); // pixel.scrollText(); // } // }
import ioio.lib.api.exception.ConnectionLostException; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.binding.DoubleBinding; import javafx.beans.binding.StringBinding; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener.Change; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Orientation; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.effect.DropShadowBuilder; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.media.AudioSpectrumListener; import javafx.scene.media.EqualizerBand; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Line; import javafx.scene.shape.LineBuilder; import javafx.scene.text.Font; import javafx.scene.transform.Rotate; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.stage.WindowEvent; import javafx.util.Duration; import javafx.util.Pair; import org.onebeartoe.juke.javafx.demo.MusicVisualizerLedMatrixListener; import org.onebeartoe.pixel.LedMatrixListener; import org.onebeartoe.pixel.PixelEnvironment; import org.onebeartoe.pixel.PixelIntegration; import org.onebeartoe.pixel.hardware.Pixel;
{ if (!playList.getSongs().isEmpty()) { curreentSongIndex = 0; play(curreentSongIndex); } else { trackLabel.setText("No songs found"); timeLabel.setText(""); nameLabel.setText(""); if (mediaPlayer != null) { mediaPlayer.stop(); mediaPlayer.setAudioSpectrumListener(null); } for (int i = 0; i < 10; i++) { vuMeters[i].setValue(0); } leftVU.set(0); rightVU.set(0); } } }); // load initial playlist playList.load("http://ia600402.us.archive.org/11/items/their_finest_hour_vol1/their_finest_hour_vol1_files.xml"); // keep this commented call to load() so that we know how to add songs to the playlist // playList.load("http://www.archive.org/download/their_finest_hour_vol3/their_finest_hour_vol3_files.xml");
// Path: music-visualizer/src/main/java/org/onebeartoe/juke/javafx/demo/MusicVisualizerLedMatrixListener.java // public class MusicVisualizerLedMatrixListener implements LedMatrixListener // { // private Pixel pixel; // // private PixelEnvironment pixelEnvironment; // // public MusicVisualizerLedMatrixListener(PixelEnvironment environment) // { // pixelEnvironment = environment; // } // // @Override // public Pixel getPixel() // { // return pixel; // } // // @Override // public void ledMatrixReady(RgbLedMatrix matrix) // { // pixel = new Pixel(pixelEnvironment.LED_MATRIX, pixelEnvironment.currentResolution); // pixel.matrix = matrix; // // scrollWelcomeMessage(); // // // delay for a bit // Sleeper.sleepo(3000); // // pixel.stopExistingTimer(); // // // // } // // private void scrollWelcomeMessage() // { // pixel.setScrollingText("Music Visualizer"); // pixel.scrollText(); // } // } // Path: music-visualizer/src/main/java/org/onebeartoe/fxexperienceplayer/FxExperiencePlayer.java import ioio.lib.api.exception.ConnectionLostException; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.binding.DoubleBinding; import javafx.beans.binding.StringBinding; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener.Change; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Orientation; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.effect.DropShadowBuilder; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.media.AudioSpectrumListener; import javafx.scene.media.EqualizerBand; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Line; import javafx.scene.shape.LineBuilder; import javafx.scene.text.Font; import javafx.scene.transform.Rotate; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.stage.WindowEvent; import javafx.util.Duration; import javafx.util.Pair; import org.onebeartoe.juke.javafx.demo.MusicVisualizerLedMatrixListener; import org.onebeartoe.pixel.LedMatrixListener; import org.onebeartoe.pixel.PixelEnvironment; import org.onebeartoe.pixel.PixelIntegration; import org.onebeartoe.pixel.hardware.Pixel; { if (!playList.getSongs().isEmpty()) { curreentSongIndex = 0; play(curreentSongIndex); } else { trackLabel.setText("No songs found"); timeLabel.setText(""); nameLabel.setText(""); if (mediaPlayer != null) { mediaPlayer.stop(); mediaPlayer.setAudioSpectrumListener(null); } for (int i = 0; i < 10; i++) { vuMeters[i].setValue(0); } leftVU.set(0); rightVU.set(0); } } }); // load initial playlist playList.load("http://ia600402.us.archive.org/11/items/their_finest_hour_vol1/their_finest_hour_vol1_files.xml"); // keep this commented call to load() so that we know how to add songs to the playlist // playList.load("http://www.archive.org/download/their_finest_hour_vol3/their_finest_hour_vol3_files.xml");
ledPanelListener = new MusicVisualizerLedMatrixListener(pixelEnvironment);
onebeartoe/media-players
jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/controls/current/song/ControlsServlet.java
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // }
import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain;
package org.onebeartoe.media.players.randomjuke.ee.controls.current.song; /** * This class sets up the View for the RandomJuke controls. * * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/controls/*"}) public class ControlsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("att-key", "sring-value"); String dispatchLocation = "/WEB-INF/jsp/controls/initialize/index.jsp";
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // } // Path: jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/controls/current/song/ControlsServlet.java import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain; package org.onebeartoe.media.players.randomjuke.ee.controls.current.song; /** * This class sets up the View for the RandomJuke controls. * * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/controls/*"}) public class ControlsServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("att-key", "sring-value"); String dispatchLocation = "/WEB-INF/jsp/controls/initialize/index.jsp";
if( JukeMain.isInitiiaized() )
onebeartoe/media-players
pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/therandombit/Tocar.java
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/softtone/SoftTonePort.java // public static final int PIEZO_PIN = 3;
import com.pi4j.wiringpi.Gpio; import static com.pi4j.wiringpi.Gpio.delay; import static com.pi4j.wiringpi.Gpio.delayMicroseconds; import com.pi4j.wiringpi.SoftTone; import static org.onebeartoe.media.piezo.ports.softtone.SoftTonePort.PIEZO_PIN;
int LTS_r[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; int melod[] = {e, e, e, c, e, g, G, c, G, E, A, B, Bb, A, G, e, g, a, f, g, e, c, d, B, c}; int ritmo[] = {6, 12, 12, 6, 12, 24, 24, 18, 18, 18, 12, 12, 6, 12, 8, 8, 8, 12, 6, 12, 12, 6, 6, 6, 12}; public Tocar() { } void loop() { // TODO: FIX THE 42 for (int i=0; i<melod.length; i++) { int tom = melod[i]; int tempo = ritmo[i]; long tvalue = tempo * vel; tocar(tom, tvalue); delayMicroseconds(1000); //pausa entre notas! } delay(1000); } public static void main(String[] args) throws InterruptedException { Gpio.wiringPiSetup();
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/softtone/SoftTonePort.java // public static final int PIEZO_PIN = 3; // Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/therandombit/Tocar.java import com.pi4j.wiringpi.Gpio; import static com.pi4j.wiringpi.Gpio.delay; import static com.pi4j.wiringpi.Gpio.delayMicroseconds; import com.pi4j.wiringpi.SoftTone; import static org.onebeartoe.media.piezo.ports.softtone.SoftTonePort.PIEZO_PIN; int LTS_r[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; int melod[] = {e, e, e, c, e, g, G, c, G, E, A, B, Bb, A, G, e, g, a, f, g, e, c, d, B, c}; int ritmo[] = {6, 12, 12, 6, 12, 24, 24, 18, 18, 18, 12, 12, 6, 12, 8, 8, 8, 12, 6, 12, 12, 6, 6, 6, 12}; public Tocar() { } void loop() { // TODO: FIX THE 42 for (int i=0; i<melod.length; i++) { int tom = melod[i]; int tempo = ritmo[i]; long tvalue = tempo * vel; tocar(tom, tvalue); delayMicroseconds(1000); //pausa entre notas! } delay(1000); } public static void main(String[] args) throws InterruptedException { Gpio.wiringPiSetup();
SoftTone.softToneCreate(PIEZO_PIN);
onebeartoe/media-players
jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/RandomJukeFrameBufferServlet.java
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // }
import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain; import org.onebeartoe.system.Sleeper;
package org.onebeartoe.media.players.randomjuke.ee; /** * This servlet initializes the JavaFX components used by the media player * service. */ @WebServlet(urlPatterns = {"/frame-buffer-screen"}) public class RandomJukeFrameBufferServlet extends HttpServlet { private Logger logger; @Override public void destroy() {
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // } // Path: jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/RandomJukeFrameBufferServlet.java import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain; import org.onebeartoe.system.Sleeper; package org.onebeartoe.media.players.randomjuke.ee; /** * This servlet initializes the JavaFX components used by the media player * service. */ @WebServlet(urlPatterns = {"/frame-buffer-screen"}) public class RandomJukeFrameBufferServlet extends HttpServlet { private Logger logger; @Override public void destroy() {
JukeMain.shutdown();
onebeartoe/media-players
jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java
// Path: jukebox-networking/src/main/java/onebeartoe/juke/network/EmptyMediaListException.java // public class EmptyMediaListException extends Exception // { // public EmptyMediaListException() // { // // } // }
import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import static javafx.application.Application.launch; import javafx.stage.Stage; import onebeartoe.juke.network.EmptyMediaListException;
randomJuke.printStartDescription(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { System.out.println("launching..."); launch(args); System.out.println("launched!"); } public static String nextSong() { String message; try { randomJuke.playNextSong(); message = randomJuke.currentSongTitle; }
// Path: jukebox-networking/src/main/java/onebeartoe/juke/network/EmptyMediaListException.java // public class EmptyMediaListException extends Exception // { // public EmptyMediaListException() // { // // } // } // Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import static javafx.application.Application.launch; import javafx.stage.Stage; import onebeartoe.juke.network.EmptyMediaListException; randomJuke.printStartDescription(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { System.out.println("launching..."); launch(args); System.out.println("launched!"); } public static String nextSong() { String message; try { randomJuke.playNextSong(); message = randomJuke.currentSongTitle; }
catch (EmptyMediaListException ex)
onebeartoe/media-players
pi-ezo/src/test/java/org/onebeartoe/media/piezo/ports/rtttl/BuiltInSongsTest.java
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlSong.java // public static final int TITLE_LENGTH_MAX = 50;
import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import static org.junit.Assert.*; import static org.onebeartoe.media.piezo.ports.rtttl.RtttlSong.TITLE_LENGTH_MAX;
public void tearDown() { } /** * Test of getSongs method, of class BuiltInSongs. */ @org.junit.Test public void testGetSongs() { List<RtttlSong> result = builtInSongs.getSongs(); assertNotNull(result); int size = result.size(); assertTrue(size > 0); } @org.junit.Test public void testTitleLengths() { List<RtttlSong> result = builtInSongs.getSongs(); for(RtttlSong song : result) { String title = song.getTitle(); assertNotNull(title); int length = title.length(); assertTrue(length != 0);
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlSong.java // public static final int TITLE_LENGTH_MAX = 50; // Path: pi-ezo/src/test/java/org/onebeartoe/media/piezo/ports/rtttl/BuiltInSongsTest.java import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import static org.junit.Assert.*; import static org.onebeartoe.media.piezo.ports.rtttl.RtttlSong.TITLE_LENGTH_MAX; public void tearDown() { } /** * Test of getSongs method, of class BuiltInSongs. */ @org.junit.Test public void testGetSongs() { List<RtttlSong> result = builtInSongs.getSongs(); assertNotNull(result); int size = result.size(); assertTrue(size > 0); } @org.junit.Test public void testTitleLengths() { List<RtttlSong> result = builtInSongs.getSongs(); for(RtttlSong song : result) { String title = song.getTitle(); assertNotNull(title); int length = title.length(); assertTrue(length != 0);
assertTrue(length <= TITLE_LENGTH_MAX);
onebeartoe/media-players
pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlService.java
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/softtone/SoftTonePort.java // public static final int PIEZO_PIN = 3;
import com.pi4j.wiringpi.Gpio; import com.pi4j.wiringpi.SoftTone; import java.util.List; import static org.onebeartoe.media.piezo.ports.softtone.SoftTonePort.PIEZO_PIN;
package org.onebeartoe.media.piezo.ports.rtttl; /** * This class uses the built in RTTTL songs to play ring tones on a piezo buzzer. * * @author Roberto Marquez */ public class RtttlService { BuiltInSongs builtInSongs = new BuiltInSongs(); public RtttlService() { Gpio.wiringPiSetup(); } public void playSong(int id) throws InterruptedException { List<RtttlSong> songs = builtInSongs.getSongs(); RtttlSong song = songs.get(id); String data = song.getData(); playSong(data); } public void playSong(String rtttl) {
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/softtone/SoftTonePort.java // public static final int PIEZO_PIN = 3; // Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlService.java import com.pi4j.wiringpi.Gpio; import com.pi4j.wiringpi.SoftTone; import java.util.List; import static org.onebeartoe.media.piezo.ports.softtone.SoftTonePort.PIEZO_PIN; package org.onebeartoe.media.piezo.ports.rtttl; /** * This class uses the built in RTTTL songs to play ring tones on a piezo buzzer. * * @author Roberto Marquez */ public class RtttlService { BuiltInSongs builtInSongs = new BuiltInSongs(); public RtttlService() { Gpio.wiringPiSetup(); } public void playSong(int id) throws InterruptedException { List<RtttlSong> songs = builtInSongs.getSongs(); RtttlSong song = songs.get(id); String data = song.getData(); playSong(data); } public void playSong(String rtttl) {
SoftTone.softToneCreate(PIEZO_PIN);
onebeartoe/media-players
pi-ezo/src/main/java/org/onebeartoe/media/piezo/PlaySongHttpHandler.java
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlService.java // public class RtttlService // { // BuiltInSongs builtInSongs = new BuiltInSongs(); // // public RtttlService() // { // Gpio.wiringPiSetup(); // } // // public void playSong(int id) throws InterruptedException // { // List<RtttlSong> songs = builtInSongs.getSongs(); // // RtttlSong song = songs.get(id); // // // String data = song.getData(); // // playSong(data); // } // // public void playSong(String rtttl) // { // SoftTone.softToneCreate(PIEZO_PIN); // // RingToneTextTransferLanguage app = new RingToneTextTransferLanguage(); // // try // { // app.play_rtttl(rtttl); // } // catch(Exception e) // { // e.printStackTrace(); // } // finally // { // SoftTone.softToneStop(PIEZO_PIN); // } // } // }
import com.pi4j.system.NetworkInfo; import com.pi4j.system.SystemInfo; import com.sun.net.httpserver.HttpExchange; import java.net.URI; import java.util.logging.Level; import java.util.logging.Logger; import org.onebeartoe.media.piezo.ports.rtttl.RtttlService; import org.onebeartoe.network.TextHttpHandler;
package org.onebeartoe.media.piezo; /** * * @author Roberto Marquez */ public class PlaySongHttpHandler extends TextHttpHandler {
// Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/ports/rtttl/RtttlService.java // public class RtttlService // { // BuiltInSongs builtInSongs = new BuiltInSongs(); // // public RtttlService() // { // Gpio.wiringPiSetup(); // } // // public void playSong(int id) throws InterruptedException // { // List<RtttlSong> songs = builtInSongs.getSongs(); // // RtttlSong song = songs.get(id); // // // String data = song.getData(); // // playSong(data); // } // // public void playSong(String rtttl) // { // SoftTone.softToneCreate(PIEZO_PIN); // // RingToneTextTransferLanguage app = new RingToneTextTransferLanguage(); // // try // { // app.play_rtttl(rtttl); // } // catch(Exception e) // { // e.printStackTrace(); // } // finally // { // SoftTone.softToneStop(PIEZO_PIN); // } // } // } // Path: pi-ezo/src/main/java/org/onebeartoe/media/piezo/PlaySongHttpHandler.java import com.pi4j.system.NetworkInfo; import com.pi4j.system.SystemInfo; import com.sun.net.httpserver.HttpExchange; import java.net.URI; import java.util.logging.Level; import java.util.logging.Logger; import org.onebeartoe.media.piezo.ports.rtttl.RtttlService; import org.onebeartoe.network.TextHttpHandler; package org.onebeartoe.media.piezo; /** * * @author Roberto Marquez */ public class PlaySongHttpHandler extends TextHttpHandler {
protected RtttlService rtttlService;
onebeartoe/media-players
jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/controls/current/song/NextSongServlet.java
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // }
import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain; import org.onebeartoe.web.PlainTextResponseServlet;
package org.onebeartoe.media.players.randomjuke.ee.controls.current.song; /** * This class process requests to play the next song. * * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/controls/song/next"}) public class NextSongServlet extends PlainTextResponseServlet { @Override protected String buildText(HttpServletRequest request, HttpServletResponse response) { String message; try {
// Path: jukebox-se/src/main/java/org/onebeartoe/juke/ui/JukeMain.java // public class JukeMain extends Application // { // private static RandomJuke randomJuke; // // public static boolean isInitiiaized() // { // // at this point, so long as the randomjuke object is not null, then it // // is considered initialized // // return randomJuke != null; // } // // public static String discoverSongLists() // { // String result; // // if(randomJuke == null) // { // result = "cannot discover media lists while randomJuke is null"; // } // else // { // List<String> songListUrls = new ArrayList(); // songListUrls.add("file:///home/roberto/Versioning/world/betoland/music/Unorganized/"); // // songListUrls.add("file:///Users/lando/Versioning/world/betoland-world/music/Unorganized/"); // // randomJuke.setSongListUrls(songListUrls); // // result = "song lists discovered"; // } // // return result; // } // // @Override // public void start(Stage stage) throws Exception // { // Parameters parameters = getParameters(); // List<String> raw = parameters.getRaw(); // String [] args = raw.toArray( new String[0] ); // // randomJuke = new RandomJuke(args); // // randomJuke.printStartDescription(); // } // // /** // * The main() method is ignored in correctly deployed JavaFX application. // * main() serves only as fallback in case the application can not be // * launched through deployment artifacts, e.g., in IDEs with limited FX // * support. NetBeans ignores main(). // * // * @param args the command line arguments // */ // public static void main(String[] args) // { // System.out.println("launching..."); // // launch(args); // // System.out.println("launched!"); // } // // public static String nextSong() // { // String message; // // try // { // randomJuke.playNextSong(); // // message = randomJuke.currentSongTitle; // } // catch (EmptyMediaListException ex) // { // Logger.getLogger(JukeMain.class.getName()).log(Level.SEVERE, null, ex); // // message = "ERROR-21720: " + ex.getClass().getSimpleName() + " - " + ex.getMessage(); // } // // return message; // } // // public static void shutdown() // { // //TODO: is there anything to do here? // // // controller.stopThreads(); // } // } // Path: jukebox-ee/src/main/java/org/onebeartoe/media/players/randomjuke/ee/controls/current/song/NextSongServlet.java import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.juke.ui.JukeMain; import org.onebeartoe.web.PlainTextResponseServlet; package org.onebeartoe.media.players.randomjuke.ee.controls.current.song; /** * This class process requests to play the next song. * * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/controls/song/next"}) public class NextSongServlet extends PlainTextResponseServlet { @Override protected String buildText(HttpServletRequest request, HttpServletResponse response) { String message; try {
message = JukeMain.nextSong();
velo/flexmojos
flexmojos-testing/flexmojos-tester/src/main/java/net/flexmojos/oss/test/launcher/AsVmLauncher.java
// Path: flexmojos-testing/flexmojos-tester/src/main/java/net/flexmojos/oss/test/TestRequest.java // public class TestRequest // { // // private String[] adlCommand; // // private boolean allowHeadlessMode = true; // // private int firstConnectionTimeout; // // private String[] flashplayerCommand; // // private Integer[] flashPlayerReturnCodesToIgnore; // // private File swf; // // private File swfDescriptor; // // private int testControlPort; // // private int testPort; // // private int testTimeout; // // private boolean useAirDebugLauncher; // // public String[] getAdlCommand() // { // return adlCommand; // } // // public boolean getAllowHeadlessMode() // { // return this.allowHeadlessMode; // } // // public int getFirstConnectionTimeout() // { // return firstConnectionTimeout; // } // // public String[] getFlashplayerCommand() // { // return this.flashplayerCommand; // } // // public Integer[] getFlashPlayerReturnCodesToIgnore() { // return flashPlayerReturnCodesToIgnore; // } // // public File getSwf() // { // return swf; // } // // public File getSwfDescriptor() // { // return swfDescriptor; // } // // public int getTestControlPort() // { // return testControlPort; // } // // public int getTestPort() // { // return testPort; // } // // public int getTestTimeout() // { // return testTimeout; // } // // public boolean getUseAirDebugLauncher() // { // return useAirDebugLauncher; // } // // public void setAdlCommand( String... adlCommand ) // { // this.adlCommand = adlCommand; // } // // public void setAllowHeadlessMode( boolean allowHeadlessMode ) // { // this.allowHeadlessMode = allowHeadlessMode; // } // // public void setFirstConnectionTimeout( int firstConnectionTimeout ) // { // this.firstConnectionTimeout = firstConnectionTimeout; // } // // public void setFlashplayerCommand( String... flashplayerCommand ) // { // this.flashplayerCommand = flashplayerCommand; // } // // public void setFlashPlayerReturnCodesToIgnore(Integer[] flashPlayerReturnCodesToIgnore) { // this.flashPlayerReturnCodesToIgnore = flashPlayerReturnCodesToIgnore; // } // // public void setSwf( File swf ) // { // this.swf = swf; // } // // public void setSwfDescriptor( File swfDescriptor ) // { // this.swfDescriptor = swfDescriptor; // } // // public void setTestControlPort( int testControlPort ) // { // this.testControlPort = testControlPort; // } // // public void setTestPort( int testPort ) // { // this.testPort = testPort; // } // // public void setTestTimeout( int testTimeout ) // { // this.testTimeout = testTimeout; // } // // public void setUseAirDebugLauncher( boolean useAirDebugLauncher ) // { // this.useAirDebugLauncher = useAirDebugLauncher; // } // }
import net.flexmojos.oss.test.ThreadStatus; import net.flexmojos.oss.util.OSUtils; import net.flexmojos.oss.util.PathUtil; import static net.flexmojos.oss.util.CollectionUtils.*; import java.awt.GraphicsEnvironment; import java.io.File; import java.io.IOException; import java.util.Arrays; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.StreamConsumer; import org.codehaus.plexus.util.cli.StreamPumper; import net.flexmojos.oss.test.AbstractControlledThread; import net.flexmojos.oss.test.ControlledThread; import net.flexmojos.oss.test.TestRequest;
} catch ( IOException e ) { throw new LaunchFlashPlayerException( "Failed to create xvfb-run error-file!", e ); } try { final String[] cmdArray = merge( new String[]{ "xvfb-run", "-a", "-e", log.getAbsolutePath() }, asvmCommand, new String[] { targetFile } ); getLogger().debug( "[LAUNCHER] Executing command: " + Arrays.toString( cmdArray ) ); process = Runtime.getRuntime().exec( cmdArray ); } catch ( IOException e ) { throw new LaunchFlashPlayerException( "Failed to launch runtime (executable file name: '" + asvmCommand[0] + "') " + "in headless environment.", e ); } } /** * Run the SWF that contains the FlexUnit tests. * * @param request the TestRequest instance. * @throws LaunchFlashPlayerException Thrown if the flash player fails to launch. * @throws InvalidSwfException Thrown if the requested test swf cannot be found or is not set. */
// Path: flexmojos-testing/flexmojos-tester/src/main/java/net/flexmojos/oss/test/TestRequest.java // public class TestRequest // { // // private String[] adlCommand; // // private boolean allowHeadlessMode = true; // // private int firstConnectionTimeout; // // private String[] flashplayerCommand; // // private Integer[] flashPlayerReturnCodesToIgnore; // // private File swf; // // private File swfDescriptor; // // private int testControlPort; // // private int testPort; // // private int testTimeout; // // private boolean useAirDebugLauncher; // // public String[] getAdlCommand() // { // return adlCommand; // } // // public boolean getAllowHeadlessMode() // { // return this.allowHeadlessMode; // } // // public int getFirstConnectionTimeout() // { // return firstConnectionTimeout; // } // // public String[] getFlashplayerCommand() // { // return this.flashplayerCommand; // } // // public Integer[] getFlashPlayerReturnCodesToIgnore() { // return flashPlayerReturnCodesToIgnore; // } // // public File getSwf() // { // return swf; // } // // public File getSwfDescriptor() // { // return swfDescriptor; // } // // public int getTestControlPort() // { // return testControlPort; // } // // public int getTestPort() // { // return testPort; // } // // public int getTestTimeout() // { // return testTimeout; // } // // public boolean getUseAirDebugLauncher() // { // return useAirDebugLauncher; // } // // public void setAdlCommand( String... adlCommand ) // { // this.adlCommand = adlCommand; // } // // public void setAllowHeadlessMode( boolean allowHeadlessMode ) // { // this.allowHeadlessMode = allowHeadlessMode; // } // // public void setFirstConnectionTimeout( int firstConnectionTimeout ) // { // this.firstConnectionTimeout = firstConnectionTimeout; // } // // public void setFlashplayerCommand( String... flashplayerCommand ) // { // this.flashplayerCommand = flashplayerCommand; // } // // public void setFlashPlayerReturnCodesToIgnore(Integer[] flashPlayerReturnCodesToIgnore) { // this.flashPlayerReturnCodesToIgnore = flashPlayerReturnCodesToIgnore; // } // // public void setSwf( File swf ) // { // this.swf = swf; // } // // public void setSwfDescriptor( File swfDescriptor ) // { // this.swfDescriptor = swfDescriptor; // } // // public void setTestControlPort( int testControlPort ) // { // this.testControlPort = testControlPort; // } // // public void setTestPort( int testPort ) // { // this.testPort = testPort; // } // // public void setTestTimeout( int testTimeout ) // { // this.testTimeout = testTimeout; // } // // public void setUseAirDebugLauncher( boolean useAirDebugLauncher ) // { // this.useAirDebugLauncher = useAirDebugLauncher; // } // } // Path: flexmojos-testing/flexmojos-tester/src/main/java/net/flexmojos/oss/test/launcher/AsVmLauncher.java import net.flexmojos.oss.test.ThreadStatus; import net.flexmojos.oss.util.OSUtils; import net.flexmojos.oss.util.PathUtil; import static net.flexmojos.oss.util.CollectionUtils.*; import java.awt.GraphicsEnvironment; import java.io.File; import java.io.IOException; import java.util.Arrays; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.StreamConsumer; import org.codehaus.plexus.util.cli.StreamPumper; import net.flexmojos.oss.test.AbstractControlledThread; import net.flexmojos.oss.test.ControlledThread; import net.flexmojos.oss.test.TestRequest; } catch ( IOException e ) { throw new LaunchFlashPlayerException( "Failed to create xvfb-run error-file!", e ); } try { final String[] cmdArray = merge( new String[]{ "xvfb-run", "-a", "-e", log.getAbsolutePath() }, asvmCommand, new String[] { targetFile } ); getLogger().debug( "[LAUNCHER] Executing command: " + Arrays.toString( cmdArray ) ); process = Runtime.getRuntime().exec( cmdArray ); } catch ( IOException e ) { throw new LaunchFlashPlayerException( "Failed to launch runtime (executable file name: '" + asvmCommand[0] + "') " + "in headless environment.", e ); } } /** * Run the SWF that contains the FlexUnit tests. * * @param request the TestRequest instance. * @throws LaunchFlashPlayerException Thrown if the flash player fails to launch. * @throws InvalidSwfException Thrown if the requested test swf cannot be found or is not set. */
public void start( TestRequest request )
velo/flexmojos
flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/DefaultFlexCompiler.java
// Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/interceptor/FlexToolInterceptor.java // public interface FlexToolInterceptor { // // String[] intercept(FlexToolGroup flexToolGroup, FlexTool flexTool, String[] args); // // }
import net.flexmojos.oss.compiler.command.CommandUtil; import net.flexmojos.oss.compiler.command.Result; import net.flexmojos.oss.compiler.util.FlexCompilerArgumentParser; import java.lang.reflect.Method; import java.util.List; import java.util.Map; import net.flexmojos.oss.compiler.interceptor.FlexToolInterceptor; import org.apache.flex.tools.FlexTool; import org.apache.flex.tools.FlexToolGroup; import org.apache.flex.tools.FlexToolRegistry; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import net.flexmojos.oss.compiler.command.Command;
/** * Flexmojos is a set of maven goals to allow maven users to compile, * optimize and test Flex SWF, Flex SWC, Air SWF and Air SWC. * Copyright (C) 2008-2012 Marvin Froeder <marvin@flexmojos.net> * * 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 net.flexmojos.oss.compiler; @Component( role = FlexCompiler.class ) public class DefaultFlexCompiler extends AbstractLogEnabled implements FlexCompiler { @Requirement private FlexCompilerArgumentParser parser;
// Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/interceptor/FlexToolInterceptor.java // public interface FlexToolInterceptor { // // String[] intercept(FlexToolGroup flexToolGroup, FlexTool flexTool, String[] args); // // } // Path: flexmojos-sandbox/flexmojos-flex-compiler/src/main/java/net/flexmojos/oss/compiler/DefaultFlexCompiler.java import net.flexmojos.oss.compiler.command.CommandUtil; import net.flexmojos.oss.compiler.command.Result; import net.flexmojos.oss.compiler.util.FlexCompilerArgumentParser; import java.lang.reflect.Method; import java.util.List; import java.util.Map; import net.flexmojos.oss.compiler.interceptor.FlexToolInterceptor; import org.apache.flex.tools.FlexTool; import org.apache.flex.tools.FlexToolGroup; import org.apache.flex.tools.FlexToolRegistry; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import net.flexmojos.oss.compiler.command.Command; /** * Flexmojos is a set of maven goals to allow maven users to compile, * optimize and test Flex SWF, Flex SWC, Air SWF and Air SWC. * Copyright (C) 2008-2012 Marvin Froeder <marvin@flexmojos.net> * * 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 net.flexmojos.oss.compiler; @Component( role = FlexCompiler.class ) public class DefaultFlexCompiler extends AbstractLogEnabled implements FlexCompiler { @Requirement private FlexCompilerArgumentParser parser;
@Requirement( role = FlexToolInterceptor.class )
aidhog/blabel
src/main/java/cl/uchile/dcc/blabel/lean/DFSGraphLeaning.java
// Path: src/main/java/cl/uchile/dcc/blabel/label/util/Orbits.java // public class Orbits { // // // only non-trivial ones // Partition<Node> orbits = new Partition<Node>(); // // public Orbits(){ // super(); // } // // public int countOrbits(){ // return orbits.partitions; // } // // public int maxOrbit(){ // int max = 0; // for(TreeSet<Node> o:orbits.values()){ // if(o.size()>max) // max = o.size(); // } // return max; // } // // public boolean addAndCompose(HashMap<Node,Node> auto){ // return updateOrbits(auto, this.orbits); // } // // public TreeSet<Node> getNonTrivialOrbit(Node n){ // return orbits.getPartition(n); // } // // private boolean updateOrbits(HashMap<Node,Node> auto, Partition<Node> orbits){ // boolean add = false; // for(Map.Entry<Node, Node> e:auto.entrySet()){ // if(!e.getKey().equals(e.getValue())){ // add |= orbits.addPair(e.getKey(), e.getValue()); // } // } // return add; // } // // /** // * See if the given nodes form an orbit in the known automorphisms. // * // * @param nodes // * @return // */ // public boolean isOrbit(Collection<Node> nodes){ // if(nodes==null || nodes.isEmpty()){ // throw new IllegalArgumentException("Expecting non-null, non-empty input for orbit detection"); // } // Iterator<Node> i = nodes.iterator(); // // TreeSet<Node> o = orbits.get(i.next()); // if(o==null) // return false; // return o.containsAll(nodes); // } // // // public static HashMap<Node,Node> inverse(HashMap<Node,Node> auto){ // HashMap<Node,Node> inv = new HashMap<Node,Node>(auto.size()); // for(Map.Entry<Node, Node> e : auto.entrySet()){ // inv.put(e.getValue(), e.getKey()); // } // return inv; // } // // public static HashMap<Node,Node> comp(HashMap<Node,Node> a1, HashMap<Node,Node> a2){ // HashMap<Node,Node> comp = new HashMap<Node,Node>(a1.size()); // for(Map.Entry<Node, Node> e : a1.entrySet()){ // Node c = a2.get(e.getValue()); // if(c==null){ // throw new IllegalArgumentException("Not an automorphism"); // } // comp.put(e.getKey(), c); // } // return comp; // } // } // // Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // }
import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.TreeSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.NodeComparator; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import org.semanticweb.yars.stats.Count; import cl.uchile.dcc.blabel.label.util.Orbits; import cl.uchile.dcc.blabel.lean.util.Bindings;
Count<Node> timesBound = new Count<Node>(); if(initialMap!=null && !initialMap.isEmpty()){ startingSolution.putAll(initialMap); for(Map.Entry<BNode, Node> e: initialMap.entrySet()){ timesBound.add(e.getValue()); } } HashMap<BNode,Node> hom = join(queryCopy, startingSolution, timesBound); return hom; } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private HashMap<BNode,Node> join(ArrayList<Node[]> todo, HashMap<BNode,Node> partialSol, Count<Node> timesBound) throws InterruptedException{ if (Thread.interrupted()) { throw new InterruptedException(); } joins++; Node[] current = todo.remove(0);
// Path: src/main/java/cl/uchile/dcc/blabel/label/util/Orbits.java // public class Orbits { // // // only non-trivial ones // Partition<Node> orbits = new Partition<Node>(); // // public Orbits(){ // super(); // } // // public int countOrbits(){ // return orbits.partitions; // } // // public int maxOrbit(){ // int max = 0; // for(TreeSet<Node> o:orbits.values()){ // if(o.size()>max) // max = o.size(); // } // return max; // } // // public boolean addAndCompose(HashMap<Node,Node> auto){ // return updateOrbits(auto, this.orbits); // } // // public TreeSet<Node> getNonTrivialOrbit(Node n){ // return orbits.getPartition(n); // } // // private boolean updateOrbits(HashMap<Node,Node> auto, Partition<Node> orbits){ // boolean add = false; // for(Map.Entry<Node, Node> e:auto.entrySet()){ // if(!e.getKey().equals(e.getValue())){ // add |= orbits.addPair(e.getKey(), e.getValue()); // } // } // return add; // } // // /** // * See if the given nodes form an orbit in the known automorphisms. // * // * @param nodes // * @return // */ // public boolean isOrbit(Collection<Node> nodes){ // if(nodes==null || nodes.isEmpty()){ // throw new IllegalArgumentException("Expecting non-null, non-empty input for orbit detection"); // } // Iterator<Node> i = nodes.iterator(); // // TreeSet<Node> o = orbits.get(i.next()); // if(o==null) // return false; // return o.containsAll(nodes); // } // // // public static HashMap<Node,Node> inverse(HashMap<Node,Node> auto){ // HashMap<Node,Node> inv = new HashMap<Node,Node>(auto.size()); // for(Map.Entry<Node, Node> e : auto.entrySet()){ // inv.put(e.getValue(), e.getKey()); // } // return inv; // } // // public static HashMap<Node,Node> comp(HashMap<Node,Node> a1, HashMap<Node,Node> a2){ // HashMap<Node,Node> comp = new HashMap<Node,Node>(a1.size()); // for(Map.Entry<Node, Node> e : a1.entrySet()){ // Node c = a2.get(e.getValue()); // if(c==null){ // throw new IllegalArgumentException("Not an automorphism"); // } // comp.put(e.getKey(), c); // } // return comp; // } // } // // Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // } // Path: src/main/java/cl/uchile/dcc/blabel/lean/DFSGraphLeaning.java import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.TreeSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.NodeComparator; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import org.semanticweb.yars.stats.Count; import cl.uchile.dcc.blabel.label.util.Orbits; import cl.uchile.dcc.blabel.lean.util.Bindings; Count<Node> timesBound = new Count<Node>(); if(initialMap!=null && !initialMap.isEmpty()){ startingSolution.putAll(initialMap); for(Map.Entry<BNode, Node> e: initialMap.entrySet()){ timesBound.add(e.getValue()); } } HashMap<BNode,Node> hom = join(queryCopy, startingSolution, timesBound); return hom; } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private HashMap<BNode,Node> join(ArrayList<Node[]> todo, HashMap<BNode,Node> partialSol, Count<Node> timesBound) throws InterruptedException{ if (Thread.interrupted()) { throw new InterruptedException(); } joins++; Node[] current = todo.remove(0);
Bindings bindings = getBindings(current,partialSol,timesBound);
aidhog/blabel
src/main/java/cl/uchile/dcc/blabel/lean/DFSGraphLeaning.java
// Path: src/main/java/cl/uchile/dcc/blabel/label/util/Orbits.java // public class Orbits { // // // only non-trivial ones // Partition<Node> orbits = new Partition<Node>(); // // public Orbits(){ // super(); // } // // public int countOrbits(){ // return orbits.partitions; // } // // public int maxOrbit(){ // int max = 0; // for(TreeSet<Node> o:orbits.values()){ // if(o.size()>max) // max = o.size(); // } // return max; // } // // public boolean addAndCompose(HashMap<Node,Node> auto){ // return updateOrbits(auto, this.orbits); // } // // public TreeSet<Node> getNonTrivialOrbit(Node n){ // return orbits.getPartition(n); // } // // private boolean updateOrbits(HashMap<Node,Node> auto, Partition<Node> orbits){ // boolean add = false; // for(Map.Entry<Node, Node> e:auto.entrySet()){ // if(!e.getKey().equals(e.getValue())){ // add |= orbits.addPair(e.getKey(), e.getValue()); // } // } // return add; // } // // /** // * See if the given nodes form an orbit in the known automorphisms. // * // * @param nodes // * @return // */ // public boolean isOrbit(Collection<Node> nodes){ // if(nodes==null || nodes.isEmpty()){ // throw new IllegalArgumentException("Expecting non-null, non-empty input for orbit detection"); // } // Iterator<Node> i = nodes.iterator(); // // TreeSet<Node> o = orbits.get(i.next()); // if(o==null) // return false; // return o.containsAll(nodes); // } // // // public static HashMap<Node,Node> inverse(HashMap<Node,Node> auto){ // HashMap<Node,Node> inv = new HashMap<Node,Node>(auto.size()); // for(Map.Entry<Node, Node> e : auto.entrySet()){ // inv.put(e.getValue(), e.getKey()); // } // return inv; // } // // public static HashMap<Node,Node> comp(HashMap<Node,Node> a1, HashMap<Node,Node> a2){ // HashMap<Node,Node> comp = new HashMap<Node,Node>(a1.size()); // for(Map.Entry<Node, Node> e : a1.entrySet()){ // Node c = a2.get(e.getValue()); // if(c==null){ // throw new IllegalArgumentException("Not an automorphism"); // } // comp.put(e.getKey(), c); // } // return comp; // } // } // // Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // }
import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.TreeSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.NodeComparator; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import org.semanticweb.yars.stats.Count; import cl.uchile.dcc.blabel.label.util.Orbits; import cl.uchile.dcc.blabel.lean.util.Bindings;
} HashMap<BNode,Node> hom = join(queryCopy, startingSolution, timesBound); return hom; } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private HashMap<BNode,Node> join(ArrayList<Node[]> todo, HashMap<BNode,Node> partialSol, Count<Node> timesBound) throws InterruptedException{ if (Thread.interrupted()) { throw new InterruptedException(); } joins++; Node[] current = todo.remove(0); Bindings bindings = getBindings(current,partialSol,timesBound); if(bindings.getBindings()==null){ return null; } // the following are all for pruning // by automorphism
// Path: src/main/java/cl/uchile/dcc/blabel/label/util/Orbits.java // public class Orbits { // // // only non-trivial ones // Partition<Node> orbits = new Partition<Node>(); // // public Orbits(){ // super(); // } // // public int countOrbits(){ // return orbits.partitions; // } // // public int maxOrbit(){ // int max = 0; // for(TreeSet<Node> o:orbits.values()){ // if(o.size()>max) // max = o.size(); // } // return max; // } // // public boolean addAndCompose(HashMap<Node,Node> auto){ // return updateOrbits(auto, this.orbits); // } // // public TreeSet<Node> getNonTrivialOrbit(Node n){ // return orbits.getPartition(n); // } // // private boolean updateOrbits(HashMap<Node,Node> auto, Partition<Node> orbits){ // boolean add = false; // for(Map.Entry<Node, Node> e:auto.entrySet()){ // if(!e.getKey().equals(e.getValue())){ // add |= orbits.addPair(e.getKey(), e.getValue()); // } // } // return add; // } // // /** // * See if the given nodes form an orbit in the known automorphisms. // * // * @param nodes // * @return // */ // public boolean isOrbit(Collection<Node> nodes){ // if(nodes==null || nodes.isEmpty()){ // throw new IllegalArgumentException("Expecting non-null, non-empty input for orbit detection"); // } // Iterator<Node> i = nodes.iterator(); // // TreeSet<Node> o = orbits.get(i.next()); // if(o==null) // return false; // return o.containsAll(nodes); // } // // // public static HashMap<Node,Node> inverse(HashMap<Node,Node> auto){ // HashMap<Node,Node> inv = new HashMap<Node,Node>(auto.size()); // for(Map.Entry<Node, Node> e : auto.entrySet()){ // inv.put(e.getValue(), e.getKey()); // } // return inv; // } // // public static HashMap<Node,Node> comp(HashMap<Node,Node> a1, HashMap<Node,Node> a2){ // HashMap<Node,Node> comp = new HashMap<Node,Node>(a1.size()); // for(Map.Entry<Node, Node> e : a1.entrySet()){ // Node c = a2.get(e.getValue()); // if(c==null){ // throw new IllegalArgumentException("Not an automorphism"); // } // comp.put(e.getKey(), c); // } // return comp; // } // } // // Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // } // Path: src/main/java/cl/uchile/dcc/blabel/lean/DFSGraphLeaning.java import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.TreeSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.NodeComparator; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import org.semanticweb.yars.stats.Count; import cl.uchile.dcc.blabel.label.util.Orbits; import cl.uchile.dcc.blabel.lean.util.Bindings; } HashMap<BNode,Node> hom = join(queryCopy, startingSolution, timesBound); return hom; } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private HashMap<BNode,Node> join(ArrayList<Node[]> todo, HashMap<BNode,Node> partialSol, Count<Node> timesBound) throws InterruptedException{ if (Thread.interrupted()) { throw new InterruptedException(); } joins++; Node[] current = todo.remove(0); Bindings bindings = getBindings(current,partialSol,timesBound); if(bindings.getBindings()==null){ return null; } // the following are all for pruning // by automorphism
Orbits o = null;
aidhog/blabel
src/main/java/cl/uchile/dcc/blabel/lean/BFSGraphLeaning.java
// Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // }
import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import cl.uchile.dcc.blabel.lean.util.Bindings;
} private ArrayList<HashMap<BNode,Node>> getSolutions(ArrayList<Node[]> todo, HashMap<BNode, Node> initialMap) throws InterruptedException{ ArrayList<HashMap<BNode,Node>> solutions = new ArrayList<HashMap<BNode,Node>>(); if(initialMap!=null) solutions.add(initialMap); else solutions.add(new HashMap<BNode,Node>()); ArrayList<Node[]> todoCopy = new ArrayList<Node[]>(todo); return join(todoCopy,solutions); } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private ArrayList<HashMap<BNode,Node>> join(ArrayList<Node[]> todo, ArrayList<HashMap<BNode,Node>> partialSols) throws InterruptedException{ ArrayList<HashMap<BNode,Node>> nextPartialSols = new ArrayList<HashMap<BNode,Node>>(); Node[] current = todo.remove(0); for(HashMap<BNode,Node> partialSol:partialSols){ if (Thread.interrupted()) { throw new InterruptedException(); } joins++;
// Path: src/main/java/cl/uchile/dcc/blabel/lean/util/Bindings.java // public class Bindings { // private final ArrayList<BNode> output; // private final ArrayList<Node[]> bindings; // // public Bindings(ArrayList<BNode> output, ArrayList<Node[]> bindings){ // this.output = output; // this.bindings = bindings; // } // // public ArrayList<BNode> getOutput() { // return output; // } // // public ArrayList<Node[]> getBindings() { // return bindings; // } // } // Path: src/main/java/cl/uchile/dcc/blabel/lean/BFSGraphLeaning.java import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.logging.Logger; import org.semanticweb.yars.nx.BNode; import org.semanticweb.yars.nx.Node; import org.semanticweb.yars.nx.Nodes; import org.semanticweb.yars.nx.parser.NxParser; import cl.uchile.dcc.blabel.lean.util.Bindings; } private ArrayList<HashMap<BNode,Node>> getSolutions(ArrayList<Node[]> todo, HashMap<BNode, Node> initialMap) throws InterruptedException{ ArrayList<HashMap<BNode,Node>> solutions = new ArrayList<HashMap<BNode,Node>>(); if(initialMap!=null) solutions.add(initialMap); else solutions.add(new HashMap<BNode,Node>()); ArrayList<Node[]> todoCopy = new ArrayList<Node[]>(todo); return join(todoCopy,solutions); } /** * * @param current Pattern with blank node subject and object * @param todo Patterns left to do * @param partialSol A partial solution * @param timesBound Number of times each term bound in current partial solution * @return null if no valid homomorphism found in depth first search, otherwise a single homomorphism * @throws InterruptedException */ private ArrayList<HashMap<BNode,Node>> join(ArrayList<Node[]> todo, ArrayList<HashMap<BNode,Node>> partialSols) throws InterruptedException{ ArrayList<HashMap<BNode,Node>> nextPartialSols = new ArrayList<HashMap<BNode,Node>>(); Node[] current = todo.remove(0); for(HashMap<BNode,Node> partialSol:partialSols){ if (Thread.interrupted()) { throw new InterruptedException(); } joins++;
Bindings bindings = getBindings(current,partialSol);
nka11/h3270
src/org/h3270/render/Engine.java
// Path: src/org/h3270/host/Screen.java // public interface Screen { // // /** // * Returns the width (number of columns) of this screen. // */ // public int getWidth(); // // /** // * Returns the height (number of rows) of this screen. // */ // public int getHeight(); // // /** // * Returns the character at the given position. x and y start // * in the upper left hand corner, which is position (0,0). // * Control characters are returned as blanks. // */ // public char charAt (int x, int y); // // /** // * Returns the contents of a region on this screen. // * // * @param startx x coordinate of the starting point (inclusive) // * @param starty y coordinate of the starting point // * @param endx x coordinate of the end point (inclusive) // * @param endy y coordinate of the end point // * @return the region as a String, with line breaks (newline characters) // * inserted // */ // public String substring (int startx, int starty, int endx, int endy); // // /** // * Returns a part of a row on this screen, as a string. // * @param startx x coordinate of the starting point (inclusive) // * @param endx x coordinate of the end point (inclusive) // * @param y number of the row // */ // public String substring (int startx, int endx, int y); // // /** // * Returns a single row of this screen. // * @param y the row number // * @return the row as a String, without a terminating newline // */ // public String substring (int y); // // /** // * Returns a list of all Fields on this screen. // * If there are no fields, this method returns an empty list. // */ // public List getFields(); // // /** // * Returns a Field object representing the input field at position (x,y). // * If there is no input field at this position, this method returns null. // * A field begins with the character <i>after</i> the first control // * character, and ends with the character <i>before</i> the terminating // * control character. Thus, for the positions of the control characters // * themselves, this method always returns null. // * // * x and y start in the upper left hand corner, which is position (0,0). // */ // public InputField getInputFieldAt (int x, int y); // // /** // * Returns true if there is an input field at position (x, y) on this screen. // * Fields do not include the control characters that delimit them, // * see {@link #getInputFieldAt getFieldAt()}. // */ // public boolean isInputField (int x, int y); // // /** // * Gets the InputField in which the cursor is currently, or null if // * the cursor is not in an InputField. // */ // public InputField getFocusedField(); // // /** // * Returns true if this Screen is formatted. // */ // public boolean isFormatted(); // // }
import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.h3270.host.Screen;
package org.h3270.render; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * An Engine is a collection of Renderers. * * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class Engine implements Renderer { private Renderer fallback = null; private List renderers = null; /** * Constructs an Engine based on all template files in the given basedir. */ public Engine (String basedir) { fallback = new HtmlRenderer(); renderers = new ArrayList(); File dir = new File (basedir); File[] templates = dir.listFiles (new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.endsWith(".html"); } }); if (templates != null) { for (int i=0; i<templates.length; i++) { renderers.add (new RegexRenderer(templates[i].toString())); } } }
// Path: src/org/h3270/host/Screen.java // public interface Screen { // // /** // * Returns the width (number of columns) of this screen. // */ // public int getWidth(); // // /** // * Returns the height (number of rows) of this screen. // */ // public int getHeight(); // // /** // * Returns the character at the given position. x and y start // * in the upper left hand corner, which is position (0,0). // * Control characters are returned as blanks. // */ // public char charAt (int x, int y); // // /** // * Returns the contents of a region on this screen. // * // * @param startx x coordinate of the starting point (inclusive) // * @param starty y coordinate of the starting point // * @param endx x coordinate of the end point (inclusive) // * @param endy y coordinate of the end point // * @return the region as a String, with line breaks (newline characters) // * inserted // */ // public String substring (int startx, int starty, int endx, int endy); // // /** // * Returns a part of a row on this screen, as a string. // * @param startx x coordinate of the starting point (inclusive) // * @param endx x coordinate of the end point (inclusive) // * @param y number of the row // */ // public String substring (int startx, int endx, int y); // // /** // * Returns a single row of this screen. // * @param y the row number // * @return the row as a String, without a terminating newline // */ // public String substring (int y); // // /** // * Returns a list of all Fields on this screen. // * If there are no fields, this method returns an empty list. // */ // public List getFields(); // // /** // * Returns a Field object representing the input field at position (x,y). // * If there is no input field at this position, this method returns null. // * A field begins with the character <i>after</i> the first control // * character, and ends with the character <i>before</i> the terminating // * control character. Thus, for the positions of the control characters // * themselves, this method always returns null. // * // * x and y start in the upper left hand corner, which is position (0,0). // */ // public InputField getInputFieldAt (int x, int y); // // /** // * Returns true if there is an input field at position (x, y) on this screen. // * Fields do not include the control characters that delimit them, // * see {@link #getInputFieldAt getFieldAt()}. // */ // public boolean isInputField (int x, int y); // // /** // * Gets the InputField in which the cursor is currently, or null if // * the cursor is not in an InputField. // */ // public InputField getFocusedField(); // // /** // * Returns true if this Screen is formatted. // */ // public boolean isFormatted(); // // } // Path: src/org/h3270/render/Engine.java import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.h3270.host.Screen; package org.h3270.render; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * An Engine is a collection of Renderers. * * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class Engine implements Renderer { private Renderer fallback = null; private List renderers = null; /** * Constructs an Engine based on all template files in the given basedir. */ public Engine (String basedir) { fallback = new HtmlRenderer(); renderers = new ArrayList(); File dir = new File (basedir); File[] templates = dir.listFiles (new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.endsWith(".html"); } }); if (templates != null) { for (int i=0; i<templates.length; i++) { renderers.add (new RegexRenderer(templates[i].toString())); } } }
public boolean canRender (Screen s) {
nka11/h3270
src/org/h3270/host/ScreenCharSequence.java
// Path: src/org/h3270/render/TextRenderer.java // public class TextRenderer implements Renderer { // // private boolean markIntensified = false; // private boolean markHidden = false; // // public TextRenderer() { // } // // public TextRenderer (boolean markIntensified, // boolean markHidden) { // this.markIntensified = markIntensified; // this.markHidden = markHidden; // } // // public boolean canRender (Screen s) { // return true; // } // // public boolean canRender (String screenText) { // return true; // } // // public String render (Screen s, String actionURL, String id) { // return this.render(s); // } // // public String render (Screen s, String actionURL) { // return this.render(s); // } // // public String render (Screen s) { // StringBuffer result = new StringBuffer(); // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // result.append (f.getText()); // } // // if (markIntensified) { // markFields (s, result, '[', ']', new FieldSelector() { // public boolean checkField (final Field f) { // return !(f instanceof InputField) && f.isIntensified(); // } // }); // } // // markFields (s, result, '{', '}', new FieldSelector() { // public boolean checkField (final Field f) { // return f instanceof InputField; // } // }); // // for (int i=0; i<result.length(); i++) { // if (result.charAt(i) == '\u0000') // result.setCharAt(i, ' '); // } // return result.toString(); // } // // /** // * This method marks some of the Fields in a textual screen representation // * by replacing the control characters with other characters. For example, // * InputFields can be surrounded by '{' and '}' to make them visible and // * detectable. // * @param s the Screen on which we operate // * @param buf a StringBuffer holding the textual representation of the screen, // * with individual lines separated by newline characters. // * @param openCh the character to be used for the initial control character // * of a field // * @param closeCh the character to be used for the terminating control // * character of the field // * @param fs a FieldSelector that decides which of the Fields should be marked // */ // private void markFields (Screen s, StringBuffer buf, // char openCh, char closeCh, // FieldSelector fs) { // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // if (!fs.checkField(f)) continue; // int startx = f.getStartX(); // int starty = f.getStartY(); // int endx = f.getEndX(); // int endy = f.getEndY(); // int width = s.getWidth(); // // if (startx == 0) // setChar (buf, width, width-1, starty-1, openCh); // else // setChar (buf, width, startx-1, starty, openCh); // // if (endx == width-1) // setChar (buf, width, 0, endy+1, closeCh); // else // setChar (buf, width, endx+1, endy, closeCh); // } // } // // /** // * Changes one character in the given StringBuffer. The character position // * is given in screen (x,y) coordinates. The buffer holds the entire screen // * contents, with lines separated by a single newline character each. If // * the x and y coordinates are out of range, this method silently ignores // * the request -- this makes the caller's code easier. // */ // private void setChar (StringBuffer buf, int width, int x, int y, char ch) { // int index = y * (width + 1) + x; // if (index >= 0 && index < buf.length()) // buf.setCharAt (index, ch); // } // // /** // * Interface for selecting Fields. // */ // private interface FieldSelector { // public boolean checkField (final Field f); // } // // }
import org.h3270.render.TextRenderer;
package org.h3270.host; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class ScreenCharSequence { private Screen screen = null; private String text = null; private int width = 0; private int height = 0;
// Path: src/org/h3270/render/TextRenderer.java // public class TextRenderer implements Renderer { // // private boolean markIntensified = false; // private boolean markHidden = false; // // public TextRenderer() { // } // // public TextRenderer (boolean markIntensified, // boolean markHidden) { // this.markIntensified = markIntensified; // this.markHidden = markHidden; // } // // public boolean canRender (Screen s) { // return true; // } // // public boolean canRender (String screenText) { // return true; // } // // public String render (Screen s, String actionURL, String id) { // return this.render(s); // } // // public String render (Screen s, String actionURL) { // return this.render(s); // } // // public String render (Screen s) { // StringBuffer result = new StringBuffer(); // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // result.append (f.getText()); // } // // if (markIntensified) { // markFields (s, result, '[', ']', new FieldSelector() { // public boolean checkField (final Field f) { // return !(f instanceof InputField) && f.isIntensified(); // } // }); // } // // markFields (s, result, '{', '}', new FieldSelector() { // public boolean checkField (final Field f) { // return f instanceof InputField; // } // }); // // for (int i=0; i<result.length(); i++) { // if (result.charAt(i) == '\u0000') // result.setCharAt(i, ' '); // } // return result.toString(); // } // // /** // * This method marks some of the Fields in a textual screen representation // * by replacing the control characters with other characters. For example, // * InputFields can be surrounded by '{' and '}' to make them visible and // * detectable. // * @param s the Screen on which we operate // * @param buf a StringBuffer holding the textual representation of the screen, // * with individual lines separated by newline characters. // * @param openCh the character to be used for the initial control character // * of a field // * @param closeCh the character to be used for the terminating control // * character of the field // * @param fs a FieldSelector that decides which of the Fields should be marked // */ // private void markFields (Screen s, StringBuffer buf, // char openCh, char closeCh, // FieldSelector fs) { // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // if (!fs.checkField(f)) continue; // int startx = f.getStartX(); // int starty = f.getStartY(); // int endx = f.getEndX(); // int endy = f.getEndY(); // int width = s.getWidth(); // // if (startx == 0) // setChar (buf, width, width-1, starty-1, openCh); // else // setChar (buf, width, startx-1, starty, openCh); // // if (endx == width-1) // setChar (buf, width, 0, endy+1, closeCh); // else // setChar (buf, width, endx+1, endy, closeCh); // } // } // // /** // * Changes one character in the given StringBuffer. The character position // * is given in screen (x,y) coordinates. The buffer holds the entire screen // * contents, with lines separated by a single newline character each. If // * the x and y coordinates are out of range, this method silently ignores // * the request -- this makes the caller's code easier. // */ // private void setChar (StringBuffer buf, int width, int x, int y, char ch) { // int index = y * (width + 1) + x; // if (index >= 0 && index < buf.length()) // buf.setCharAt (index, ch); // } // // /** // * Interface for selecting Fields. // */ // private interface FieldSelector { // public boolean checkField (final Field f); // } // // } // Path: src/org/h3270/host/ScreenCharSequence.java import org.h3270.render.TextRenderer; package org.h3270.host; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class ScreenCharSequence { private Screen screen = null; private String text = null; private int width = 0; private int height = 0;
private TextRenderer renderer = new TextRenderer();
nka11/h3270
src/org/h3270/logicalunit/LogicalUnitPoolFactory.java
// Path: src/org/h3270/render/H3270Configuration.java // public class H3270Configuration // extends org.apache.avalon.framework.configuration.DefaultConfiguration { // // private final List colorSchemes = new ArrayList(); // private final String colorSchemeDefault; // private final Map validFonts = new HashMap(); // private final String fontnameDefault; // private final String logicalUnitBuilderClass; // // private static final Pattern FILENAME_PATTERN = // Pattern.compile ("file:(.*?)/WEB-INF/h3270-config\\.xml.*"); // // private H3270Configuration (Configuration data) throws ConfigurationException { // super(data); // // final Configuration colorschemeConfig = data.getChild("colorschemes"); // createColorSchemes(colorschemeConfig); // colorSchemeDefault = createColorschemeDefault(colorschemeConfig, colorSchemes); // // final Configuration fontConfig = data.getChild("fonts"); // createValidFonts(fontConfig); // fontnameDefault = createFontnameDefault(fontConfig, validFonts); // // // If exec-path points into WEB-INF, convert it into an absolute path now. // DefaultConfiguration c = (DefaultConfiguration)data.getChild("exec-path"); // String execPath = c.getValue(""); // if (execPath.startsWith("WEB-INF")) { // Matcher m = FILENAME_PATTERN.matcher(getLocation()); // if (m.find()) { // execPath = m.group(1) + "/" + execPath; // c.setValue (execPath); // } // } // logicalUnitBuilderClass = createLogicalUnitBuilderClass(data.getChild("logical-units")); // } // // public List getColorSchemes() { // return colorSchemes; // } // // public String getColorSchemeDefault() // { // return colorSchemeDefault; // } // // public ColorScheme getColorScheme (String name) { // for (Iterator i = colorSchemes.iterator(); i.hasNext();) { // ColorScheme cs = (ColorScheme)i.next(); // if (cs.getName().equals(name)) // return cs; // } // return null; // } // // public Map getValidFonts() { // return validFonts; // } // // private void createColorSchemes(Configuration config) throws ConfigurationException { // Configuration[] cs = config.getChildren(); // for (int x = 0; x < cs.length; ++x) { // ColorScheme scheme = new ColorScheme ( // cs[x].getAttribute("name"), // cs[x].getAttribute("pnfg"), // cs[x].getAttribute("pnbg"), // cs[x].getAttribute("pifg"), // cs[x].getAttribute("pibg"), // cs[x].getAttribute("phfg"), // cs[x].getAttribute("phbg"), // cs[x].getAttribute("unfg"), // cs[x].getAttribute("unbg"), // cs[x].getAttribute("uifg"), // cs[x].getAttribute("uibg"), // cs[x].getAttribute("uhfg"), // cs[x].getAttribute("uhbg") // ); // colorSchemes.add(scheme); // } // } // // private String createColorschemeDefault(Configuration config, List colorSchemes) throws ConfigurationException { // String colorSchemeDefault = config.getAttribute("default", null); // if (colorSchemeDefault == null) { // if (colorSchemes.isEmpty()) { // throw new ConfigurationException("need to specify at least one colorscheme"); // } // // default to first colorscheme // colorSchemeDefault = ((ColorScheme) colorSchemes.get(0)).getName(); // } // return colorSchemeDefault; // } // // private void createValidFonts(Configuration config) // throws ConfigurationException { // Configuration[] fonts = config.getChildren(); // for (int x = 0; x < fonts.length; ++x) { // String fontName = fonts[x].getAttribute("name"); // String fontDescription = fonts[x].getAttribute("description", fontName); // validFonts.put(fontName, fontDescription); // } // } // // private String createFontnameDefault(Configuration config, Map validFonts) // throws ConfigurationException { // String fontnameDefault = config.getAttribute("default", null); // if (fontnameDefault == null) { // if (validFonts.isEmpty()) { // throw new ConfigurationException("need to specify at least one font"); // } // // default to random fontname // fontnameDefault = validFonts.keySet().iterator().next().toString(); // } // return fontnameDefault; // } // // public String getFontnameDefault() // { // return fontnameDefault; // } // // public String createLogicalUnitBuilderClass(Configuration config) throws ConfigurationException { // boolean usePool = config.getChild("use-pool").getValueAsBoolean(); // if (usePool) // return config.getChild("lu-builder").getValue(); // return null; // } // // public static H3270Configuration create (String filename) { // try { // return create(new FileInputStream(filename)); // } catch (FileNotFoundException e) { // throw new RuntimeException(e); // } // } // // public static H3270Configuration create (InputStream in) { // try { // DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); // Configuration data = builder.build(in); // return new H3270Configuration(data); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public String getLogicalUnitBuilderClass() { // return logicalUnitBuilderClass; // } // }
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.h3270.render.H3270Configuration;
package org.h3270.logicalunit; public class LogicalUnitPoolFactory { protected final static Log logger = LogFactory.getLog(LogicalUnitPoolFactory.class);
// Path: src/org/h3270/render/H3270Configuration.java // public class H3270Configuration // extends org.apache.avalon.framework.configuration.DefaultConfiguration { // // private final List colorSchemes = new ArrayList(); // private final String colorSchemeDefault; // private final Map validFonts = new HashMap(); // private final String fontnameDefault; // private final String logicalUnitBuilderClass; // // private static final Pattern FILENAME_PATTERN = // Pattern.compile ("file:(.*?)/WEB-INF/h3270-config\\.xml.*"); // // private H3270Configuration (Configuration data) throws ConfigurationException { // super(data); // // final Configuration colorschemeConfig = data.getChild("colorschemes"); // createColorSchemes(colorschemeConfig); // colorSchemeDefault = createColorschemeDefault(colorschemeConfig, colorSchemes); // // final Configuration fontConfig = data.getChild("fonts"); // createValidFonts(fontConfig); // fontnameDefault = createFontnameDefault(fontConfig, validFonts); // // // If exec-path points into WEB-INF, convert it into an absolute path now. // DefaultConfiguration c = (DefaultConfiguration)data.getChild("exec-path"); // String execPath = c.getValue(""); // if (execPath.startsWith("WEB-INF")) { // Matcher m = FILENAME_PATTERN.matcher(getLocation()); // if (m.find()) { // execPath = m.group(1) + "/" + execPath; // c.setValue (execPath); // } // } // logicalUnitBuilderClass = createLogicalUnitBuilderClass(data.getChild("logical-units")); // } // // public List getColorSchemes() { // return colorSchemes; // } // // public String getColorSchemeDefault() // { // return colorSchemeDefault; // } // // public ColorScheme getColorScheme (String name) { // for (Iterator i = colorSchemes.iterator(); i.hasNext();) { // ColorScheme cs = (ColorScheme)i.next(); // if (cs.getName().equals(name)) // return cs; // } // return null; // } // // public Map getValidFonts() { // return validFonts; // } // // private void createColorSchemes(Configuration config) throws ConfigurationException { // Configuration[] cs = config.getChildren(); // for (int x = 0; x < cs.length; ++x) { // ColorScheme scheme = new ColorScheme ( // cs[x].getAttribute("name"), // cs[x].getAttribute("pnfg"), // cs[x].getAttribute("pnbg"), // cs[x].getAttribute("pifg"), // cs[x].getAttribute("pibg"), // cs[x].getAttribute("phfg"), // cs[x].getAttribute("phbg"), // cs[x].getAttribute("unfg"), // cs[x].getAttribute("unbg"), // cs[x].getAttribute("uifg"), // cs[x].getAttribute("uibg"), // cs[x].getAttribute("uhfg"), // cs[x].getAttribute("uhbg") // ); // colorSchemes.add(scheme); // } // } // // private String createColorschemeDefault(Configuration config, List colorSchemes) throws ConfigurationException { // String colorSchemeDefault = config.getAttribute("default", null); // if (colorSchemeDefault == null) { // if (colorSchemes.isEmpty()) { // throw new ConfigurationException("need to specify at least one colorscheme"); // } // // default to first colorscheme // colorSchemeDefault = ((ColorScheme) colorSchemes.get(0)).getName(); // } // return colorSchemeDefault; // } // // private void createValidFonts(Configuration config) // throws ConfigurationException { // Configuration[] fonts = config.getChildren(); // for (int x = 0; x < fonts.length; ++x) { // String fontName = fonts[x].getAttribute("name"); // String fontDescription = fonts[x].getAttribute("description", fontName); // validFonts.put(fontName, fontDescription); // } // } // // private String createFontnameDefault(Configuration config, Map validFonts) // throws ConfigurationException { // String fontnameDefault = config.getAttribute("default", null); // if (fontnameDefault == null) { // if (validFonts.isEmpty()) { // throw new ConfigurationException("need to specify at least one font"); // } // // default to random fontname // fontnameDefault = validFonts.keySet().iterator().next().toString(); // } // return fontnameDefault; // } // // public String getFontnameDefault() // { // return fontnameDefault; // } // // public String createLogicalUnitBuilderClass(Configuration config) throws ConfigurationException { // boolean usePool = config.getChild("use-pool").getValueAsBoolean(); // if (usePool) // return config.getChild("lu-builder").getValue(); // return null; // } // // public static H3270Configuration create (String filename) { // try { // return create(new FileInputStream(filename)); // } catch (FileNotFoundException e) { // throw new RuntimeException(e); // } // } // // public static H3270Configuration create (InputStream in) { // try { // DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); // Configuration data = builder.build(in); // return new H3270Configuration(data); // } catch (Exception ex) { // throw new RuntimeException(ex); // } // } // // public String getLogicalUnitBuilderClass() { // return logicalUnitBuilderClass; // } // } // Path: src/org/h3270/logicalunit/LogicalUnitPoolFactory.java import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.h3270.render.H3270Configuration; package org.h3270.logicalunit; public class LogicalUnitPoolFactory { protected final static Log logger = LogFactory.getLog(LogicalUnitPoolFactory.class);
public static LogicalUnitPool createLogicalUnitPool(H3270Configuration configuration) {
nka11/h3270
src/org/h3270/web/SessionState.java
// Path: src/org/h3270/logicalunit/LogicalUnitPool.java // public class LogicalUnitPool implements Serializable { // // public final static String SERVLET_CONTEXT_KEY = "org.h3270.LogicalUnitPool"; // // private final static Log logger = LogFactory.getLog(LogicalUnitPool.class); // // private Map luPool; // // public LogicalUnitPool(LogicalUnitBuilder builder) { // Collection logicalUnits = builder.getLogicalUnits(); // // luPool = Collections.synchronizedMap(new HashMap(logicalUnits.size())); // // for (Iterator iter = logicalUnits.iterator(); iter.hasNext();) { // String name = (String) iter.next(); // luPool.put(name, new Boolean(false)); // } // } // // public String leaseLogicalUnit() throws LogicalUnitException { // Set names = luPool.keySet(); // synchronized (luPool) { // for (Iterator iter = names.iterator(); iter.hasNext();) { // String name = (String) iter.next(); // boolean isInUse = ((Boolean) luPool.get(name)).booleanValue(); // if (!isInUse) { // luPool.put(name, new Boolean(true)); // logger.debug("LU akquired = " + name); // return name; // new LogicalUnit(name); // } // } // } // throw new LogicalUnitException("All logical units are in use"); // } // // public void releaseLogicalUnit(String logicalUnit) { // if (luPool.get(logicalUnit) == null) // logger.error("Trying to release non-existent logical unit!"); // else { // synchronized (luPool) { // luPool.put(logicalUnit, new Boolean(false)); // logger.debug("LU released = " + logicalUnit); // } // } // } // }
import org.apache.commons.logging.LogFactory; import org.h3270.host.*; import org.h3270.logicalunit.LogicalUnitPool; import org.h3270.render.*; import java.io.*; import java.util.*; import javax.servlet.ServletContext; import javax.servlet.http.*; import org.apache.commons.codec.*; import org.apache.commons.codec.net.URLCodec; import org.apache.commons.logging.Log;
return getBooleanProperty(RENDERER, true); } public void setException (HttpServletRequest request, Throwable exception) { getTerminalState(request).setException(exception); } public Throwable getException (HttpServletRequest request) { return getTerminalState(request).getException(); } public void valueBound(HttpSessionBindingEvent arg0) { // nothing } public void valueUnbound(HttpSessionBindingEvent event) { // disconnect all s3270 sessions when the HttpSession times out and release // associated logical units in the pool for (Iterator i = terminalStates.iterator(); i.hasNext();) { TerminalState ts = (TerminalState) i.next(); if (ts.getTerminal() != null && ts.getTerminal().isConnected()) { if (logger.isInfoEnabled()) logger.info("Session unbound, disconnecting terminal " + ts.getTerminal()); ts.getTerminal().disconnect(); String logicalUnit = ts.getTerminal().getLogicalUnit(); if (logicalUnit != null) { ServletContext servletContext = event.getSession() .getServletContext();
// Path: src/org/h3270/logicalunit/LogicalUnitPool.java // public class LogicalUnitPool implements Serializable { // // public final static String SERVLET_CONTEXT_KEY = "org.h3270.LogicalUnitPool"; // // private final static Log logger = LogFactory.getLog(LogicalUnitPool.class); // // private Map luPool; // // public LogicalUnitPool(LogicalUnitBuilder builder) { // Collection logicalUnits = builder.getLogicalUnits(); // // luPool = Collections.synchronizedMap(new HashMap(logicalUnits.size())); // // for (Iterator iter = logicalUnits.iterator(); iter.hasNext();) { // String name = (String) iter.next(); // luPool.put(name, new Boolean(false)); // } // } // // public String leaseLogicalUnit() throws LogicalUnitException { // Set names = luPool.keySet(); // synchronized (luPool) { // for (Iterator iter = names.iterator(); iter.hasNext();) { // String name = (String) iter.next(); // boolean isInUse = ((Boolean) luPool.get(name)).booleanValue(); // if (!isInUse) { // luPool.put(name, new Boolean(true)); // logger.debug("LU akquired = " + name); // return name; // new LogicalUnit(name); // } // } // } // throw new LogicalUnitException("All logical units are in use"); // } // // public void releaseLogicalUnit(String logicalUnit) { // if (luPool.get(logicalUnit) == null) // logger.error("Trying to release non-existent logical unit!"); // else { // synchronized (luPool) { // luPool.put(logicalUnit, new Boolean(false)); // logger.debug("LU released = " + logicalUnit); // } // } // } // } // Path: src/org/h3270/web/SessionState.java import org.apache.commons.logging.LogFactory; import org.h3270.host.*; import org.h3270.logicalunit.LogicalUnitPool; import org.h3270.render.*; import java.io.*; import java.util.*; import javax.servlet.ServletContext; import javax.servlet.http.*; import org.apache.commons.codec.*; import org.apache.commons.codec.net.URLCodec; import org.apache.commons.logging.Log; return getBooleanProperty(RENDERER, true); } public void setException (HttpServletRequest request, Throwable exception) { getTerminalState(request).setException(exception); } public Throwable getException (HttpServletRequest request) { return getTerminalState(request).getException(); } public void valueBound(HttpSessionBindingEvent arg0) { // nothing } public void valueUnbound(HttpSessionBindingEvent event) { // disconnect all s3270 sessions when the HttpSession times out and release // associated logical units in the pool for (Iterator i = terminalStates.iterator(); i.hasNext();) { TerminalState ts = (TerminalState) i.next(); if (ts.getTerminal() != null && ts.getTerminal().isConnected()) { if (logger.isInfoEnabled()) logger.info("Session unbound, disconnecting terminal " + ts.getTerminal()); ts.getTerminal().disconnect(); String logicalUnit = ts.getTerminal().getLogicalUnit(); if (logicalUnit != null) { ServletContext servletContext = event.getSession() .getServletContext();
LogicalUnitPool pool = (LogicalUnitPool) servletContext
nka11/h3270
src/org/h3270/host/S3270Screen.java
// Path: src/org/h3270/render/TextRenderer.java // public class TextRenderer implements Renderer { // // private boolean markIntensified = false; // private boolean markHidden = false; // // public TextRenderer() { // } // // public TextRenderer (boolean markIntensified, // boolean markHidden) { // this.markIntensified = markIntensified; // this.markHidden = markHidden; // } // // public boolean canRender (Screen s) { // return true; // } // // public boolean canRender (String screenText) { // return true; // } // // public String render (Screen s, String actionURL, String id) { // return this.render(s); // } // // public String render (Screen s, String actionURL) { // return this.render(s); // } // // public String render (Screen s) { // StringBuffer result = new StringBuffer(); // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // result.append (f.getText()); // } // // if (markIntensified) { // markFields (s, result, '[', ']', new FieldSelector() { // public boolean checkField (final Field f) { // return !(f instanceof InputField) && f.isIntensified(); // } // }); // } // // markFields (s, result, '{', '}', new FieldSelector() { // public boolean checkField (final Field f) { // return f instanceof InputField; // } // }); // // for (int i=0; i<result.length(); i++) { // if (result.charAt(i) == '\u0000') // result.setCharAt(i, ' '); // } // return result.toString(); // } // // /** // * This method marks some of the Fields in a textual screen representation // * by replacing the control characters with other characters. For example, // * InputFields can be surrounded by '{' and '}' to make them visible and // * detectable. // * @param s the Screen on which we operate // * @param buf a StringBuffer holding the textual representation of the screen, // * with individual lines separated by newline characters. // * @param openCh the character to be used for the initial control character // * of a field // * @param closeCh the character to be used for the terminating control // * character of the field // * @param fs a FieldSelector that decides which of the Fields should be marked // */ // private void markFields (Screen s, StringBuffer buf, // char openCh, char closeCh, // FieldSelector fs) { // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // if (!fs.checkField(f)) continue; // int startx = f.getStartX(); // int starty = f.getStartY(); // int endx = f.getEndX(); // int endy = f.getEndY(); // int width = s.getWidth(); // // if (startx == 0) // setChar (buf, width, width-1, starty-1, openCh); // else // setChar (buf, width, startx-1, starty, openCh); // // if (endx == width-1) // setChar (buf, width, 0, endy+1, closeCh); // else // setChar (buf, width, endx+1, endy, closeCh); // } // } // // /** // * Changes one character in the given StringBuffer. The character position // * is given in screen (x,y) coordinates. The buffer holds the entire screen // * contents, with lines separated by a single newline character each. If // * the x and y coordinates are out of range, this method silently ignores // * the request -- this makes the caller's code easier. // */ // private void setChar (StringBuffer buf, int width, int x, int y, char ch) { // int index = y * (width + 1) + x; // if (index >= 0 && index < buf.length()) // buf.setCharAt (index, ch); // } // // /** // * Interface for selecting Fields. // */ // private interface FieldSelector { // public boolean checkField (final Field f); // } // // }
import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.h3270.render.TextRenderer; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections;
} // a field that begins in the last column if (fieldStartX == index && fieldStartY == y) { fieldStartX = 0; fieldStartY++; } return result.toString().toCharArray(); } private Field createField(byte startCode, int startx, int starty, int endx, int endy, int color, int ext_highlight) { if ((startCode & Field.ATTR_PROTECTED) == 0) return new InputField (this, startCode, startx, starty, endx, endy, color, ext_highlight); else return new Field (this, startCode, startx, starty, endx, endy, color, ext_highlight); } public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader (new FileReader ("src/org/h3270/test/screen8.dump")); List lines = new ArrayList(); while (true) { String line = in.readLine(); if (line == null || !line.startsWith ("data: ")) break; lines.add (line.substring(6)); } S3270Screen s = new S3270Screen(); s.update ("U F U", lines);
// Path: src/org/h3270/render/TextRenderer.java // public class TextRenderer implements Renderer { // // private boolean markIntensified = false; // private boolean markHidden = false; // // public TextRenderer() { // } // // public TextRenderer (boolean markIntensified, // boolean markHidden) { // this.markIntensified = markIntensified; // this.markHidden = markHidden; // } // // public boolean canRender (Screen s) { // return true; // } // // public boolean canRender (String screenText) { // return true; // } // // public String render (Screen s, String actionURL, String id) { // return this.render(s); // } // // public String render (Screen s, String actionURL) { // return this.render(s); // } // // public String render (Screen s) { // StringBuffer result = new StringBuffer(); // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // result.append (f.getText()); // } // // if (markIntensified) { // markFields (s, result, '[', ']', new FieldSelector() { // public boolean checkField (final Field f) { // return !(f instanceof InputField) && f.isIntensified(); // } // }); // } // // markFields (s, result, '{', '}', new FieldSelector() { // public boolean checkField (final Field f) { // return f instanceof InputField; // } // }); // // for (int i=0; i<result.length(); i++) { // if (result.charAt(i) == '\u0000') // result.setCharAt(i, ' '); // } // return result.toString(); // } // // /** // * This method marks some of the Fields in a textual screen representation // * by replacing the control characters with other characters. For example, // * InputFields can be surrounded by '{' and '}' to make them visible and // * detectable. // * @param s the Screen on which we operate // * @param buf a StringBuffer holding the textual representation of the screen, // * with individual lines separated by newline characters. // * @param openCh the character to be used for the initial control character // * of a field // * @param closeCh the character to be used for the terminating control // * character of the field // * @param fs a FieldSelector that decides which of the Fields should be marked // */ // private void markFields (Screen s, StringBuffer buf, // char openCh, char closeCh, // FieldSelector fs) { // for (Iterator i = s.getFields().iterator(); i.hasNext();) { // Field f = (Field)i.next(); // if (!fs.checkField(f)) continue; // int startx = f.getStartX(); // int starty = f.getStartY(); // int endx = f.getEndX(); // int endy = f.getEndY(); // int width = s.getWidth(); // // if (startx == 0) // setChar (buf, width, width-1, starty-1, openCh); // else // setChar (buf, width, startx-1, starty, openCh); // // if (endx == width-1) // setChar (buf, width, 0, endy+1, closeCh); // else // setChar (buf, width, endx+1, endy, closeCh); // } // } // // /** // * Changes one character in the given StringBuffer. The character position // * is given in screen (x,y) coordinates. The buffer holds the entire screen // * contents, with lines separated by a single newline character each. If // * the x and y coordinates are out of range, this method silently ignores // * the request -- this makes the caller's code easier. // */ // private void setChar (StringBuffer buf, int width, int x, int y, char ch) { // int index = y * (width + 1) + x; // if (index >= 0 && index < buf.length()) // buf.setCharAt (index, ch); // } // // /** // * Interface for selecting Fields. // */ // private interface FieldSelector { // public boolean checkField (final Field f); // } // // } // Path: src/org/h3270/host/S3270Screen.java import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.h3270.render.TextRenderer; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; } // a field that begins in the last column if (fieldStartX == index && fieldStartY == y) { fieldStartX = 0; fieldStartY++; } return result.toString().toCharArray(); } private Field createField(byte startCode, int startx, int starty, int endx, int endy, int color, int ext_highlight) { if ((startCode & Field.ATTR_PROTECTED) == 0) return new InputField (this, startCode, startx, starty, endx, endy, color, ext_highlight); else return new Field (this, startCode, startx, starty, endx, endy, color, ext_highlight); } public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader (new FileReader ("src/org/h3270/test/screen8.dump")); List lines = new ArrayList(); while (true) { String line = in.readLine(); if (line == null || !line.startsWith ("data: ")) break; lines.add (line.substring(6)); } S3270Screen s = new S3270Screen(); s.update ("U F U", lines);
System.out.println (new TextRenderer().render(s));
nka11/h3270
test/src/org/h3270/test/AllTest.java
// Path: test/src/org/h3270/test/render/H3270ConfigurationTest.java // public class H3270ConfigurationTest extends TestCase { // // public void testCreateEmptyConfig() // { // try // { // createConfig(""); // fail(); // } catch (RuntimeException e) // { // // expected // } // } // // public void testColorschemeWithoutDefault() throws Exception { // final String colorscheme = "Dark Background"; // final String content = "<colorschemes>" // + getScheme(colorscheme) // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // // assertEquals(colorscheme, config.getColorSchemeDefault()); // } // // public void testColorschemeWithDefault() throws Exception // { // final String colorscheme = "Second Color"; // final String content = "<colorschemes default=\"" + colorscheme + "\">" // + getScheme("First Color") // + getScheme(colorscheme) // + getScheme("Third Color") // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // // assertEquals(colorscheme, config.getColorSchemeDefault()); // } // // public void testFontWithoutDefault() throws Exception // { // final String fontname = "terminal"; // final String content = "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts>" // + getFont(fontname) // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // assertEquals(fontname, config.getFontnameDefault()); // } // // public void testFontWithDefault() throws Exception // { // final String fontname = "terminal"; // final String content = "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts default=\"" + fontname + "\">" // + getFont("first font") // + getFont(fontname) // + getFont("third font") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // assertEquals(fontname, config.getFontnameDefault()); // } // // public void testLogicalUnits() throws Exception // { // final boolean usePool = true; // final String luBuilder = "builder"; // final String content = getLogicalUnitConfig(usePool, luBuilder) // + "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>"; // // final H3270Configuration config = createConfig(content); // assertEquals(usePool, config.getChild("logical-units").getChild("use-pool").getValueAsBoolean()); // assertEquals(luBuilder, config.getChild("logical-units").getChild("lu-builder").getValue()); // } // // private String getLogicalUnitConfig(final boolean usePool, // final String luBuilder) { // String logicalUnits = "<logical-units>" // + "<use-pool>" // + usePool // + "</use-pool>" // + "<lu-builder>" // + luBuilder // + "</lu-builder>" // + "</logical-units>"; // return logicalUnits; // } // // private H3270Configuration createConfig(String content) { // String data = "<h3270>" + content + "</h3270>"; // // ByteArrayInputStream stream = new ByteArrayInputStream(data.getBytes()); // DataInputStream in = new DataInputStream(stream); // return H3270Configuration.create(in); // } // // private String getScheme(String name) // { // return "<scheme name=\"" + name + "\" pnfg=\"cyan\" pnbg=\"black\" " // + "pifg=\"white\" pibg=\"black\" phfg=\"black\" phbg=\"black\" unfg=\"lime\" " // + "unbg=\"#282828\" uifg=\"red\" uibg=\"#282828\" uhfg=\"red\" " // + "uhbg=\"#282828\" />"; // } // // private String getFont(String name) // { // return "<font name=\"" + name + "\" description=\"Terminal\" />"; // } // }
import junit.framework.*; import org.h3270.test.render.H3270ConfigurationTest;
package org.h3270.test; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class AllTest extends TestCase { public AllTest(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite ("All h3270 tests"); suite.addTestSuite (S3270Test.class); suite.addTestSuite (S3270ScreenTest.class); suite.addTestSuite (SessionStateTest.class); suite.addTestSuite (Bug1063147Test.class); suite.addTestSuite (BugRenderTest.class);
// Path: test/src/org/h3270/test/render/H3270ConfigurationTest.java // public class H3270ConfigurationTest extends TestCase { // // public void testCreateEmptyConfig() // { // try // { // createConfig(""); // fail(); // } catch (RuntimeException e) // { // // expected // } // } // // public void testColorschemeWithoutDefault() throws Exception { // final String colorscheme = "Dark Background"; // final String content = "<colorschemes>" // + getScheme(colorscheme) // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // // assertEquals(colorscheme, config.getColorSchemeDefault()); // } // // public void testColorschemeWithDefault() throws Exception // { // final String colorscheme = "Second Color"; // final String content = "<colorschemes default=\"" + colorscheme + "\">" // + getScheme("First Color") // + getScheme(colorscheme) // + getScheme("Third Color") // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // // assertEquals(colorscheme, config.getColorSchemeDefault()); // } // // public void testFontWithoutDefault() throws Exception // { // final String fontname = "terminal"; // final String content = "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts>" // + getFont(fontname) // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // assertEquals(fontname, config.getFontnameDefault()); // } // // public void testFontWithDefault() throws Exception // { // final String fontname = "terminal"; // final String content = "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts default=\"" + fontname + "\">" // + getFont("first font") // + getFont(fontname) // + getFont("third font") // + "</fonts>" // + getLogicalUnitConfig(false, ""); // // final H3270Configuration config = createConfig(content); // assertEquals(fontname, config.getFontnameDefault()); // } // // public void testLogicalUnits() throws Exception // { // final boolean usePool = true; // final String luBuilder = "builder"; // final String content = getLogicalUnitConfig(usePool, luBuilder) // + "<colorschemes>" // + getScheme("Dark Background") // + "</colorschemes>" // + "<fonts>" // + getFont("terminal") // + "</fonts>"; // // final H3270Configuration config = createConfig(content); // assertEquals(usePool, config.getChild("logical-units").getChild("use-pool").getValueAsBoolean()); // assertEquals(luBuilder, config.getChild("logical-units").getChild("lu-builder").getValue()); // } // // private String getLogicalUnitConfig(final boolean usePool, // final String luBuilder) { // String logicalUnits = "<logical-units>" // + "<use-pool>" // + usePool // + "</use-pool>" // + "<lu-builder>" // + luBuilder // + "</lu-builder>" // + "</logical-units>"; // return logicalUnits; // } // // private H3270Configuration createConfig(String content) { // String data = "<h3270>" + content + "</h3270>"; // // ByteArrayInputStream stream = new ByteArrayInputStream(data.getBytes()); // DataInputStream in = new DataInputStream(stream); // return H3270Configuration.create(in); // } // // private String getScheme(String name) // { // return "<scheme name=\"" + name + "\" pnfg=\"cyan\" pnbg=\"black\" " // + "pifg=\"white\" pibg=\"black\" phfg=\"black\" phbg=\"black\" unfg=\"lime\" " // + "unbg=\"#282828\" uifg=\"red\" uibg=\"#282828\" uhfg=\"red\" " // + "uhbg=\"#282828\" />"; // } // // private String getFont(String name) // { // return "<font name=\"" + name + "\" description=\"Terminal\" />"; // } // } // Path: test/src/org/h3270/test/AllTest.java import junit.framework.*; import org.h3270.test.render.H3270ConfigurationTest; package org.h3270.test; /* * Copyright (C) 2003-2008 akquinet tech@spree * * This file is part of h3270. * * h3270 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. * * h3270 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 h3270; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ /** * @author Andre Spiegel spiegel@gnu.org * @version $Id$ */ public class AllTest extends TestCase { public AllTest(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite ("All h3270 tests"); suite.addTestSuite (S3270Test.class); suite.addTestSuite (S3270ScreenTest.class); suite.addTestSuite (SessionStateTest.class); suite.addTestSuite (Bug1063147Test.class); suite.addTestSuite (BugRenderTest.class);
suite.addTestSuite (H3270ConfigurationTest.class);