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
ltettoni/logic2j
src/main/java/org/logic2j/core/api/model/Clause.java
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // }
import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // } // Path: src/main/java/org/logic2j/core/api/model/Clause.java import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */
public Clause(PrologImplementation theProlog, Object theClauseTerm) {
ltettoni/logic2j
src/main/java/org/logic2j/core/api/model/Clause.java
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // }
import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */ public Clause(PrologImplementation theProlog, Object theClauseTerm) { // if (!(theClauseTerm instanceof Struct)) { // throw new InvalidTermException("Need a Struct to build a clause, not " + theClauseTerm); // } // Any Clause must be normalized otherwise we won't be able to infer on it!
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // } // Path: src/main/java/org/logic2j/core/api/model/Clause.java import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */ public Clause(PrologImplementation theProlog, Object theClauseTerm) { // if (!(theClauseTerm instanceof Struct)) { // throw new InvalidTermException("Need a Struct to build a clause, not " + theClauseTerm); // } // Any Clause must be normalized otherwise we won't be able to infer on it!
this.content = termApiExt().normalize(theClauseTerm, theProlog.getLibraryManager().wholeContent());
ltettoni/logic2j
src/main/java/org/logic2j/core/api/model/Clause.java
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // }
import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */ public Clause(PrologImplementation theProlog, Object theClauseTerm) { // if (!(theClauseTerm instanceof Struct)) { // throw new InvalidTermException("Need a Struct to build a clause, not " + theClauseTerm); // } // Any Clause must be normalized otherwise we won't be able to infer on it! this.content = termApiExt().normalize(theClauseTerm, theProlog.getLibraryManager().wholeContent()); // Store indexedVars into an array, indexed by the var's index
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // } // Path: src/main/java/org/logic2j/core/api/model/Clause.java import static org.logic2j.engine.model.TermApiLocator.termApi; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import java.util.Map; import java.util.TreeMap; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Struct; import org.logic2j.engine.model.Var; import org.logic2j.engine.unify.UnifyContext; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.core.api.model; /** * Represents a fact or a rule in a Theory; this is described by "content" Object. * This class provides extra features for efficient lookup * and matching by {@link org.logic2j.core.impl.theory.TheoryManager}s. * Simple facts may be represented in two manners: * <ol> * <li>An Object, or a Struct with any functor different from ':-' (this is recommended and more optimal)</li> * <li>A Struct with functor ':-' and "true" as body (this is less optimal because this is actually a rule)</li> * <li>A Struct with functor ':-' and a real body</li> * </ol> */ public class Clause { private final Object content; // Immutable, not null /** * All Vars in the clause in an array, indexed by each Var's index (ie Var with getIndex()=N will be located * in array element N). */ private final Var<?>[] indexedVars; private Object head; private Object body; /** * A number of clones of this Clause, to avoid many cloning during inference. */ private TreeMap<Integer, Clause> cache; /** * Make a Term (must be a Struct) read for inference, it will normalize it. * * @param theProlog Required to normalize theClauseTerm according to the current libraries. * @param theClauseTerm */ public Clause(PrologImplementation theProlog, Object theClauseTerm) { // if (!(theClauseTerm instanceof Struct)) { // throw new InvalidTermException("Need a Struct to build a clause, not " + theClauseTerm); // } // Any Clause must be normalized otherwise we won't be able to infer on it! this.content = termApiExt().normalize(theClauseTerm, theProlog.getLibraryManager().wholeContent()); // Store indexedVars into an array, indexed by the var's index
final Var<?>[] distinctVars = termApi().distinctVars(content);
ltettoni/logic2j
src/test/java/org/logic2j/engine/model/TermApiExtTest.java
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // }
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import org.junit.Test; import org.logic2j.engine.exception.InvalidTermException;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.engine.model; /** * Low-level tests of the {@link TermApi} facade. */ public class TermApiExtTest { @Test public void selectTerm() { final Object arg0 = Struct.valueOf("b", "c", "c2"); final Object term = Struct.valueOf("a", arg0, "b2"); // unmarshall("a(b(c,c2),b2)"); //
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApiExt termApiExt() { // return termApi; // } // Path: src/test/java/org/logic2j/engine/model/TermApiExtTest.java import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.logic2j.engine.model.TermApiLocator.termApiExt; import org.junit.Test; import org.logic2j.engine.exception.InvalidTermException; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.engine.model; /** * Low-level tests of the {@link TermApi} facade. */ public class TermApiExtTest { @Test public void selectTerm() { final Object arg0 = Struct.valueOf("b", "c", "c2"); final Object term = Struct.valueOf("a", arg0, "b2"); // unmarshall("a(b(c,c2),b2)"); //
assertThat(termApiExt().selectTerm(term, "", Struct.class)).isEqualTo(term);
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/OperatorManagerBase.java
// Path: src/main/java/org/logic2j/core/api/OperatorManager.java // public interface OperatorManager { // // void addOperator(String operatorText, String associativity, int precedence); // // // TODO Unclear how this is an operation of a "manager". Rename method? // int precedence(String operatorText, String associativity); // // } // // Path: src/main/java/org/logic2j/core/api/model/Operator.java // public final class Operator implements Serializable { // private static final long serialVersionUID = 1L; // // // TODO Probably this should become an enum // public static final String FX = "fx"; // prefix non-associative - (i.e. --5 not possible) // public static final String FY = "fy"; // prefix associative // public static final String XF = "xf"; // postfix non-associative // public static final String XFX = "xfx"; // infix non-associative =, is, < (i.e. no nesting) // public static final String XFY = "xfy"; // infix right-associative , (for subgoals) // public static final String YF = "yf"; // postfix associative // public static final String YFX = "yfx"; // infix left-associative +, -, * // public static final String YFY = "yfy"; // makes no sense, structuring would be impossible // // /** // * highest operator precedence // */ // public static final int OP_HIGHEST = 1200; // /** // * lowest operator precedence // */ // public static final int OP_LOWEST = 1; // // /** // * operator text representation // */ // private final String text; // // /** // * precedence // */ // private final int precedence; // // /** // * xf, yf, fx, fy, xfx, xfy, yfx, (yfy) // */ // private final String associativity; // // public Operator(String theText, String theAssociativity, int thePrecedence) { // this.text = theText; // this.associativity = theAssociativity; // this.precedence = thePrecedence; // } // // // --------------------------------------------------------------------------- // // Getters // // --------------------------------------------------------------------------- // // // public String getText() { // return text; // } // // public int getPrecedence() { // return precedence; // } // // public String getAssociativity() { // return associativity; // } // } // // Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // }
import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashSet; import org.logic2j.core.api.OperatorManager; import org.logic2j.core.api.model.Operator; import org.logic2j.engine.exception.PrologNonSpecificException;
/* * tuProlog - Copyright (C) 2001-2006 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl; /** * Base implementation for OperatorManager */ abstract class OperatorManagerBase implements OperatorManager, Serializable { private static final long serialVersionUID = 1L; /** * currently known operators */ private final OperatorRegister operatorList = new OperatorRegister(); /** * Creates and register a new operator. If the operator is already provided, it replaces it with the new one * * @throws PrologNonSpecificException */ @Override public void addOperator(String operatorText, String associativity, int precedence) {
// Path: src/main/java/org/logic2j/core/api/OperatorManager.java // public interface OperatorManager { // // void addOperator(String operatorText, String associativity, int precedence); // // // TODO Unclear how this is an operation of a "manager". Rename method? // int precedence(String operatorText, String associativity); // // } // // Path: src/main/java/org/logic2j/core/api/model/Operator.java // public final class Operator implements Serializable { // private static final long serialVersionUID = 1L; // // // TODO Probably this should become an enum // public static final String FX = "fx"; // prefix non-associative - (i.e. --5 not possible) // public static final String FY = "fy"; // prefix associative // public static final String XF = "xf"; // postfix non-associative // public static final String XFX = "xfx"; // infix non-associative =, is, < (i.e. no nesting) // public static final String XFY = "xfy"; // infix right-associative , (for subgoals) // public static final String YF = "yf"; // postfix associative // public static final String YFX = "yfx"; // infix left-associative +, -, * // public static final String YFY = "yfy"; // makes no sense, structuring would be impossible // // /** // * highest operator precedence // */ // public static final int OP_HIGHEST = 1200; // /** // * lowest operator precedence // */ // public static final int OP_LOWEST = 1; // // /** // * operator text representation // */ // private final String text; // // /** // * precedence // */ // private final int precedence; // // /** // * xf, yf, fx, fy, xfx, xfy, yfx, (yfy) // */ // private final String associativity; // // public Operator(String theText, String theAssociativity, int thePrecedence) { // this.text = theText; // this.associativity = theAssociativity; // this.precedence = thePrecedence; // } // // // --------------------------------------------------------------------------- // // Getters // // --------------------------------------------------------------------------- // // // public String getText() { // return text; // } // // public int getPrecedence() { // return precedence; // } // // public String getAssociativity() { // return associativity; // } // } // // Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // } // Path: src/main/java/org/logic2j/core/impl/OperatorManagerBase.java import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashSet; import org.logic2j.core.api.OperatorManager; import org.logic2j.core.api.model.Operator; import org.logic2j.engine.exception.PrologNonSpecificException; /* * tuProlog - Copyright (C) 2001-2006 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl; /** * Base implementation for OperatorManager */ abstract class OperatorManagerBase implements OperatorManager, Serializable { private static final long serialVersionUID = 1L; /** * currently known operators */ private final OperatorRegister operatorList = new OperatorRegister(); /** * Creates and register a new operator. If the operator is already provided, it replaces it with the new one * * @throws PrologNonSpecificException */ @Override public void addOperator(String operatorText, String associativity, int precedence) {
final Operator op = new Operator(operatorText, associativity, precedence);
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/OperatorManagerBase.java
// Path: src/main/java/org/logic2j/core/api/OperatorManager.java // public interface OperatorManager { // // void addOperator(String operatorText, String associativity, int precedence); // // // TODO Unclear how this is an operation of a "manager". Rename method? // int precedence(String operatorText, String associativity); // // } // // Path: src/main/java/org/logic2j/core/api/model/Operator.java // public final class Operator implements Serializable { // private static final long serialVersionUID = 1L; // // // TODO Probably this should become an enum // public static final String FX = "fx"; // prefix non-associative - (i.e. --5 not possible) // public static final String FY = "fy"; // prefix associative // public static final String XF = "xf"; // postfix non-associative // public static final String XFX = "xfx"; // infix non-associative =, is, < (i.e. no nesting) // public static final String XFY = "xfy"; // infix right-associative , (for subgoals) // public static final String YF = "yf"; // postfix associative // public static final String YFX = "yfx"; // infix left-associative +, -, * // public static final String YFY = "yfy"; // makes no sense, structuring would be impossible // // /** // * highest operator precedence // */ // public static final int OP_HIGHEST = 1200; // /** // * lowest operator precedence // */ // public static final int OP_LOWEST = 1; // // /** // * operator text representation // */ // private final String text; // // /** // * precedence // */ // private final int precedence; // // /** // * xf, yf, fx, fy, xfx, xfy, yfx, (yfy) // */ // private final String associativity; // // public Operator(String theText, String theAssociativity, int thePrecedence) { // this.text = theText; // this.associativity = theAssociativity; // this.precedence = thePrecedence; // } // // // --------------------------------------------------------------------------- // // Getters // // --------------------------------------------------------------------------- // // // public String getText() { // return text; // } // // public int getPrecedence() { // return precedence; // } // // public String getAssociativity() { // return associativity; // } // } // // Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // }
import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashSet; import org.logic2j.core.api.OperatorManager; import org.logic2j.core.api.model.Operator; import org.logic2j.engine.exception.PrologNonSpecificException;
/* * tuProlog - Copyright (C) 2001-2006 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl; /** * Base implementation for OperatorManager */ abstract class OperatorManagerBase implements OperatorManager, Serializable { private static final long serialVersionUID = 1L; /** * currently known operators */ private final OperatorRegister operatorList = new OperatorRegister(); /** * Creates and register a new operator. If the operator is already provided, it replaces it with the new one * * @throws PrologNonSpecificException */ @Override public void addOperator(String operatorText, String associativity, int precedence) { final Operator op = new Operator(operatorText, associativity, precedence); if (precedence >= Operator.OP_LOWEST && precedence <= Operator.OP_HIGHEST) { this.operatorList.addOperator(op); } else {
// Path: src/main/java/org/logic2j/core/api/OperatorManager.java // public interface OperatorManager { // // void addOperator(String operatorText, String associativity, int precedence); // // // TODO Unclear how this is an operation of a "manager". Rename method? // int precedence(String operatorText, String associativity); // // } // // Path: src/main/java/org/logic2j/core/api/model/Operator.java // public final class Operator implements Serializable { // private static final long serialVersionUID = 1L; // // // TODO Probably this should become an enum // public static final String FX = "fx"; // prefix non-associative - (i.e. --5 not possible) // public static final String FY = "fy"; // prefix associative // public static final String XF = "xf"; // postfix non-associative // public static final String XFX = "xfx"; // infix non-associative =, is, < (i.e. no nesting) // public static final String XFY = "xfy"; // infix right-associative , (for subgoals) // public static final String YF = "yf"; // postfix associative // public static final String YFX = "yfx"; // infix left-associative +, -, * // public static final String YFY = "yfy"; // makes no sense, structuring would be impossible // // /** // * highest operator precedence // */ // public static final int OP_HIGHEST = 1200; // /** // * lowest operator precedence // */ // public static final int OP_LOWEST = 1; // // /** // * operator text representation // */ // private final String text; // // /** // * precedence // */ // private final int precedence; // // /** // * xf, yf, fx, fy, xfx, xfy, yfx, (yfy) // */ // private final String associativity; // // public Operator(String theText, String theAssociativity, int thePrecedence) { // this.text = theText; // this.associativity = theAssociativity; // this.precedence = thePrecedence; // } // // // --------------------------------------------------------------------------- // // Getters // // --------------------------------------------------------------------------- // // // public String getText() { // return text; // } // // public int getPrecedence() { // return precedence; // } // // public String getAssociativity() { // return associativity; // } // } // // Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // } // Path: src/main/java/org/logic2j/core/impl/OperatorManagerBase.java import java.io.Serializable; import java.util.HashMap; import java.util.LinkedHashSet; import org.logic2j.core.api.OperatorManager; import org.logic2j.core.api.model.Operator; import org.logic2j.engine.exception.PrologNonSpecificException; /* * tuProlog - Copyright (C) 2001-2006 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl; /** * Base implementation for OperatorManager */ abstract class OperatorManagerBase implements OperatorManager, Serializable { private static final long serialVersionUID = 1L; /** * currently known operators */ private final OperatorRegister operatorList = new OperatorRegister(); /** * Creates and register a new operator. If the operator is already provided, it replaces it with the new one * * @throws PrologNonSpecificException */ @Override public void addOperator(String operatorText, String associativity, int precedence) { final Operator op = new Operator(operatorText, associativity, precedence); if (precedence >= Operator.OP_LOWEST && precedence <= Operator.OP_HIGHEST) { this.operatorList.addOperator(op); } else {
throw new PrologNonSpecificException("Operator priority not in valid range for " + op);
ltettoni/logic2j
src/test/java/org/logic2j/contrib/excel/TabularDataFactProviderTest.java
// Path: src/main/java/org/logic2j/core/api/TermAdapter.java // enum AssertionMode { // /** // * Data is asserted as "named triples". For a dataset called myData, assertions will be such as: // * myData(entityIdentifier, propertyName, propertyValue). // */ // EAV_NAMED, // /** // * Data is asserted as "quads". The predicate is always "eavt(entity, attribute, value, transaction)". // * The "transaction" identifier is the dataset name. For example: // * eavt(entityIdentifier, propertyName, propertyValue, myData). // */ // EAVT, // /** // * Data is asserted as full records with one argument per column, such as // * "myData(valueOfColumn1, valueOfColumn2, valueOfColumn3, ..., valueOfColumnN)." // * The order of columns obviously matters. // * If your data is already triples, use this mode. // * This is the least flexible form since changes to the tabularData (adding or removing or reordering columns) will change the assertions. // */ // RECORD // }
import org.junit.Test; import org.logic2j.core.api.TermAdapter.AssertionMode;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.contrib.excel; public class TabularDataFactProviderTest extends TabularDataTestBase { @Test public void test10000() {
// Path: src/main/java/org/logic2j/core/api/TermAdapter.java // enum AssertionMode { // /** // * Data is asserted as "named triples". For a dataset called myData, assertions will be such as: // * myData(entityIdentifier, propertyName, propertyValue). // */ // EAV_NAMED, // /** // * Data is asserted as "quads". The predicate is always "eavt(entity, attribute, value, transaction)". // * The "transaction" identifier is the dataset name. For example: // * eavt(entityIdentifier, propertyName, propertyValue, myData). // */ // EAVT, // /** // * Data is asserted as full records with one argument per column, such as // * "myData(valueOfColumn1, valueOfColumn2, valueOfColumn3, ..., valueOfColumnN)." // * The order of columns obviously matters. // * If your data is already triples, use this mode. // * This is the least flexible form since changes to the tabularData (adding or removing or reordering columns) will change the assertions. // */ // RECORD // } // Path: src/test/java/org/logic2j/contrib/excel/TabularDataFactProviderTest.java import org.junit.Test; import org.logic2j.core.api.TermAdapter.AssertionMode; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.contrib.excel; public class TabularDataFactProviderTest extends TabularDataTestBase { @Test public void test10000() {
getProlog().getTheoryManager().addDataFactProvider(new TabularDataFactProvider(largeData(), AssertionMode.RECORD));
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() {
return this.type & TYPEMASK;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() {
return this.type & ATTRMASK;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) {
return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() {
return getAttribute() == FUNCTOR;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() {
return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE;
ltettoni/logic2j
src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF;
import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable;
/* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() { return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE; } boolean isEOF() {
// Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int ATTRMASK = 0xFF00; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int DOUBLE = 0x0007; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int EOF = 0x1000; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FLOAT = 0x0017; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int FUNCTOR = 0x0100; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int INTEGER = 0x0006; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int LONG = 0x0016; // New in logic2j not original tuprolog // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int OPERATOR = 0x0200; // // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/MaskConstants.java // static final int TYPEMASK = 0x00FF; // Path: src/main/java/org/logic2j/core/impl/io/tuprolog/parse/Token.java import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.ATTRMASK; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.DOUBLE; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.EOF; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FLOAT; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.FUNCTOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.INTEGER; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.LONG; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.OPERATOR; import static org.logic2j.core.impl.io.tuprolog.parse.MaskConstants.TYPEMASK; import java.io.Serializable; /* * tuProlog - Copyright (C) 2001-2002 aliCE team at deis.unibo.it * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.logic2j.core.impl.io.tuprolog.parse; /** * This class represents a token read by the prolog term tokenizer */ class Token implements Serializable { private static final long serialVersionUID = 1L; // token textual representation final String text; // token type and attribute private final int type; public Token(String seq_, int type_) { this.text = seq_; this.type = type_; } /** * @return Type flag */ public int getType() { return this.type & TYPEMASK; } /** * @return Attribute flag could be FUNCTOR, OPERATOR or EOF */ private int getAttribute() { return this.type & ATTRMASK; } public boolean isOperator(boolean commaIsEndMarker) { return !(commaIsEndMarker && ",".equals(this.text)) && getAttribute() == OPERATOR; } public boolean isFunctor() { return getAttribute() == FUNCTOR; } public boolean isNumber() { return this.type == INTEGER || this.type == LONG || this.type == FLOAT || this.type == DOUBLE; } boolean isEOF() {
return getAttribute() == EOF;
ltettoni/logic2j
src/main/java/org/logic2j/engine/util/TypeUtils.java
// Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // }
import org.logic2j.engine.exception.PrologNonSpecificException;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.engine.util; /** * Provide minimal convenience functions to determine run-time accessibility of classes and methods. This class can be considered as a * micro-helper to java.lang.reflect. * * @version $Revision: 1.24 $ */ public abstract class TypeUtils { /** * Dynamic runtime checking of an instance against a class or interface; tolerates null values. * * @param context Contextual information to be reported, in case of an exception being thrown, to the beginning of the exception's * message. Typical use case would be safeCastOrNull("Downloading " + this, eventDate, Date.class). * @param instance The instance to check, can be null. * @param desiredClassOrInterface The class or interface that we want to make sure the instance is "instanceof". * @return The instance checked, or null. * @throws ClassCastException If the instance was not of the desiredClassOrInterface, i.e. if desiredClassOrInterface is not assignable * to instance. */ @SuppressWarnings("unchecked") public static <T> T safeCastOrNull(String context, Object instance, Class<? extends T> desiredClassOrInterface) throws ClassCastException { if (instance == null) { return null; } if (!(desiredClassOrInterface.isAssignableFrom(instance.getClass()))) { final String message = "Could not cast an instance of " + instance.getClass() + " to expected " + desiredClassOrInterface + " [formatted object was " + instance + "]";
// Path: src/main/java/org/logic2j/engine/exception/PrologNonSpecificException.java // @Deprecated // public class PrologNonSpecificException extends Logic2jException { // // private static final long serialVersionUID = 1; // // public PrologNonSpecificException(String theString) { // super(theString); // } // // public PrologNonSpecificException(String theString, Throwable theRootCause) { // super(theString, theRootCause); // } // // } // Path: src/main/java/org/logic2j/engine/util/TypeUtils.java import org.logic2j.engine.exception.PrologNonSpecificException; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.engine.util; /** * Provide minimal convenience functions to determine run-time accessibility of classes and methods. This class can be considered as a * micro-helper to java.lang.reflect. * * @version $Revision: 1.24 $ */ public abstract class TypeUtils { /** * Dynamic runtime checking of an instance against a class or interface; tolerates null values. * * @param context Contextual information to be reported, in case of an exception being thrown, to the beginning of the exception's * message. Typical use case would be safeCastOrNull("Downloading " + this, eventDate, Date.class). * @param instance The instance to check, can be null. * @param desiredClassOrInterface The class or interface that we want to make sure the instance is "instanceof". * @return The instance checked, or null. * @throws ClassCastException If the instance was not of the desiredClassOrInterface, i.e. if desiredClassOrInterface is not assignable * to instance. */ @SuppressWarnings("unchecked") public static <T> T safeCastOrNull(String context, Object instance, Class<? extends T> desiredClassOrInterface) throws ClassCastException { if (instance == null) { return null; } if (!(desiredClassOrInterface.isAssignableFrom(instance.getClass()))) { final String message = "Could not cast an instance of " + instance.getClass() + " to expected " + desiredClassOrInterface + " [formatted object was " + instance + "]";
throw new PrologNonSpecificException(message);
ltettoni/logic2j
src/main/java/org/logic2j/contrib/excel/TabularDataFactProvider.java
// Path: src/main/java/org/logic2j/core/api/DataFactProvider.java // public interface DataFactProvider { // // Iterable<DataFact> listMatchingDataFacts(Object theGoal, UnifyContext currentVars); // // } // // Path: src/main/java/org/logic2j/core/api/TermAdapter.java // enum AssertionMode { // /** // * Data is asserted as "named triples". For a dataset called myData, assertions will be such as: // * myData(entityIdentifier, propertyName, propertyValue). // */ // EAV_NAMED, // /** // * Data is asserted as "quads". The predicate is always "eavt(entity, attribute, value, transaction)". // * The "transaction" identifier is the dataset name. For example: // * eavt(entityIdentifier, propertyName, propertyValue, myData). // */ // EAVT, // /** // * Data is asserted as full records with one argument per column, such as // * "myData(valueOfColumn1, valueOfColumn2, valueOfColumn3, ..., valueOfColumnN)." // * The order of columns obviously matters. // * If your data is already triples, use this mode. // * This is the least flexible form since changes to the tabularData (adding or removing or reordering columns) will change the assertions. // */ // RECORD // }
import java.io.Serializable; import java.util.ArrayList; import org.logic2j.core.api.DataFactProvider; import org.logic2j.core.api.TermAdapter.AssertionMode; import org.logic2j.engine.exception.InvalidTermException; import org.logic2j.engine.model.DataFact; import org.logic2j.engine.unify.UnifyContext;
/* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.contrib.excel; /** * An implementation of DataFactProvider for TabularData. */ public class TabularDataFactProvider implements DataFactProvider { private final TabularData tabularData;
// Path: src/main/java/org/logic2j/core/api/DataFactProvider.java // public interface DataFactProvider { // // Iterable<DataFact> listMatchingDataFacts(Object theGoal, UnifyContext currentVars); // // } // // Path: src/main/java/org/logic2j/core/api/TermAdapter.java // enum AssertionMode { // /** // * Data is asserted as "named triples". For a dataset called myData, assertions will be such as: // * myData(entityIdentifier, propertyName, propertyValue). // */ // EAV_NAMED, // /** // * Data is asserted as "quads". The predicate is always "eavt(entity, attribute, value, transaction)". // * The "transaction" identifier is the dataset name. For example: // * eavt(entityIdentifier, propertyName, propertyValue, myData). // */ // EAVT, // /** // * Data is asserted as full records with one argument per column, such as // * "myData(valueOfColumn1, valueOfColumn2, valueOfColumn3, ..., valueOfColumnN)." // * The order of columns obviously matters. // * If your data is already triples, use this mode. // * This is the least flexible form since changes to the tabularData (adding or removing or reordering columns) will change the assertions. // */ // RECORD // } // Path: src/main/java/org/logic2j/contrib/excel/TabularDataFactProvider.java import java.io.Serializable; import java.util.ArrayList; import org.logic2j.core.api.DataFactProvider; import org.logic2j.core.api.TermAdapter.AssertionMode; import org.logic2j.engine.exception.InvalidTermException; import org.logic2j.engine.model.DataFact; import org.logic2j.engine.unify.UnifyContext; /* * logic2j - "Bring Logic to your Java" - Copyright (c) 2017 Laurent.Tettoni@gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Foobar 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 Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.logic2j.contrib.excel; /** * An implementation of DataFactProvider for TabularData. */ public class TabularDataFactProvider implements DataFactProvider { private final TabularData tabularData;
private final AssertionMode assertionMode;
ltettoni/logic2j
src/main/java/org/logic2j/contrib/tool/REPL.java
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/contrib/helper/FluentPrologBuilder.java // public class FluentPrologBuilder implements PrologBuilder { // // private boolean noLibraries = false; // // private boolean coreLibraries = false; // // private Collection<File> theoryFiles = new ArrayList<>(); // private Collection<String> theoryResources = new ArrayList<>(); // // @Override // public PrologImplementation build() { // final PrologReferenceImplementation.InitLevel initLevel; // if (isNoLibraries()) { // initLevel = PrologReferenceImplementation.InitLevel.L0_BARE; // } else if (isCoreLibraries()) { // initLevel = PrologReferenceImplementation.InitLevel.L1_CORE_LIBRARY; // } else { // initLevel = PrologReferenceImplementation.InitLevel.L2_BASE_LIBRARIES; // } // final PrologReferenceImplementation prolog = new PrologReferenceImplementation(initLevel); // // // Theories from files // final TheoryManager theoryManager = prolog.getTheoryManager(); // try { // for (File theory : theoryFiles) { // final TheoryContent content = theoryManager.load(theory); // theoryManager.addTheory(content); // } // } catch (IOException e) { // throw new PrologNonSpecificException("Builder could not load theory: " + e); // } // // Theories from resources // for (String resource : theoryResources) { // final TheoryContent content = theoryManager.load(resource); // theoryManager.addTheory(content); // } // // return prolog; // } // // // // --------------------------------------------------------------------------- // // Fluent API // // --------------------------------------------------------------------------- // // public FluentPrologBuilder withoutLibraries(boolean noLibraries) { // this.noLibraries = noLibraries; // return this; // } // // public FluentPrologBuilder withCoreLibraries(boolean coreLibraries) { // this.coreLibraries = coreLibraries; // return this; // } // // // public FluentPrologBuilder withTheory(File... files) { // for (File file : files) { // theoryFiles.add(file); // } // return this; // } // // public FluentPrologBuilder withTheory(String... resources) { // for (String resource : resources) { // theoryResources.add(resource); // } // return this; // } // // --------------------------------------------------------------------------- // // Accessors // // --------------------------------------------------------------------------- // // public boolean isNoLibraries() { // return noLibraries; // } // // public void setNoLibraries(boolean noLibraries) { // this.noLibraries = noLibraries; // } // // public boolean isCoreLibraries() { // return coreLibraries; // } // // public void setCoreLibraries(boolean coreLibraries) { // this.coreLibraries = coreLibraries; // } // // public Collection<File> getTheoryFiles() { // return theoryFiles; // } // // public void setTheoryFiles(Collection<File> theoryFiles) { // this.theoryFiles = theoryFiles; // } // // public Collection<String> getTheoryResources() { // return theoryResources; // } // // public void setTheoryResources(Collection<String> theoryResources) { // this.theoryResources = theoryResources; // } // } // // Path: src/main/java/org/logic2j/core/api/TermMarshaller.java // public interface TermMarshaller { // // /** // * Formats a {@link Term} to its character representation. // * // * @param theTerm // * @return The character representation of theTerm. // */ // CharSequence marshall(Object theTerm); // // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // }
import static org.logic2j.engine.model.TermApiLocator.termApi; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.logic2j.contrib.helper.FluentPrologBuilder; import org.logic2j.core.api.TermMarshaller; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Var; import org.logic2j.engine.solver.Continuation; import org.logic2j.engine.solver.listener.CountingSolutionListener; import org.logic2j.engine.solver.listener.SolutionListener; import org.logic2j.engine.unify.UnifyContext;
System.out.println("logic2j REPL"); final List<File> theories = new ArrayList<>(); for (String arg : args) { theories.add(new File(arg)); } prolog = new FluentPrologBuilder().withTheory(theories.toArray(new File[0])).build(); final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("?- "); String goal = br.readLine(); goal = goal.trim(); // Removing trailing period if (goal.lastIndexOf('.') >= 0) { goal = goal.substring(0, goal.lastIndexOf('.')); } if ("quit".equals(goal) || "exit".equals(goal) || "bye".equals(goal)) { System.out.println("Bye"); return; } runOne(goal); } } protected void runOne(String goalText) { try { // Parse and extract vars
// Path: src/main/java/org/logic2j/engine/model/TermApiLocator.java // public static TermApi termApi() { // return termApi; // } // // Path: src/main/java/org/logic2j/contrib/helper/FluentPrologBuilder.java // public class FluentPrologBuilder implements PrologBuilder { // // private boolean noLibraries = false; // // private boolean coreLibraries = false; // // private Collection<File> theoryFiles = new ArrayList<>(); // private Collection<String> theoryResources = new ArrayList<>(); // // @Override // public PrologImplementation build() { // final PrologReferenceImplementation.InitLevel initLevel; // if (isNoLibraries()) { // initLevel = PrologReferenceImplementation.InitLevel.L0_BARE; // } else if (isCoreLibraries()) { // initLevel = PrologReferenceImplementation.InitLevel.L1_CORE_LIBRARY; // } else { // initLevel = PrologReferenceImplementation.InitLevel.L2_BASE_LIBRARIES; // } // final PrologReferenceImplementation prolog = new PrologReferenceImplementation(initLevel); // // // Theories from files // final TheoryManager theoryManager = prolog.getTheoryManager(); // try { // for (File theory : theoryFiles) { // final TheoryContent content = theoryManager.load(theory); // theoryManager.addTheory(content); // } // } catch (IOException e) { // throw new PrologNonSpecificException("Builder could not load theory: " + e); // } // // Theories from resources // for (String resource : theoryResources) { // final TheoryContent content = theoryManager.load(resource); // theoryManager.addTheory(content); // } // // return prolog; // } // // // // --------------------------------------------------------------------------- // // Fluent API // // --------------------------------------------------------------------------- // // public FluentPrologBuilder withoutLibraries(boolean noLibraries) { // this.noLibraries = noLibraries; // return this; // } // // public FluentPrologBuilder withCoreLibraries(boolean coreLibraries) { // this.coreLibraries = coreLibraries; // return this; // } // // // public FluentPrologBuilder withTheory(File... files) { // for (File file : files) { // theoryFiles.add(file); // } // return this; // } // // public FluentPrologBuilder withTheory(String... resources) { // for (String resource : resources) { // theoryResources.add(resource); // } // return this; // } // // --------------------------------------------------------------------------- // // Accessors // // --------------------------------------------------------------------------- // // public boolean isNoLibraries() { // return noLibraries; // } // // public void setNoLibraries(boolean noLibraries) { // this.noLibraries = noLibraries; // } // // public boolean isCoreLibraries() { // return coreLibraries; // } // // public void setCoreLibraries(boolean coreLibraries) { // this.coreLibraries = coreLibraries; // } // // public Collection<File> getTheoryFiles() { // return theoryFiles; // } // // public void setTheoryFiles(Collection<File> theoryFiles) { // this.theoryFiles = theoryFiles; // } // // public Collection<String> getTheoryResources() { // return theoryResources; // } // // public void setTheoryResources(Collection<String> theoryResources) { // this.theoryResources = theoryResources; // } // } // // Path: src/main/java/org/logic2j/core/api/TermMarshaller.java // public interface TermMarshaller { // // /** // * Formats a {@link Term} to its character representation. // * // * @param theTerm // * @return The character representation of theTerm. // */ // CharSequence marshall(Object theTerm); // // } // // Path: src/main/java/org/logic2j/core/impl/PrologImplementation.java // public interface PrologImplementation extends Prolog { // // // --------------------------------------------------------------------------- // // Accessors to the sub-features of the Prolog engine // // --------------------------------------------------------------------------- // // /** // * @return The implementation for managing libraries. // */ // LibraryManager getLibraryManager(); // // /** // * @return The implementation of inference logic. // */ // Solver getSolver(); // // /** // * @return The implementation for managing operators. // */ // OperatorManager getOperatorManager(); // // /** // * @return Marshalling // */ // TermMarshaller getTermMarshaller(); // // TermUnmarshaller getTermUnmarshaller(); // // void setTermAdapter(TermAdapter termAdapter); // // } // Path: src/main/java/org/logic2j/contrib/tool/REPL.java import static org.logic2j.engine.model.TermApiLocator.termApi; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.logic2j.contrib.helper.FluentPrologBuilder; import org.logic2j.core.api.TermMarshaller; import org.logic2j.core.impl.PrologImplementation; import org.logic2j.engine.model.Var; import org.logic2j.engine.solver.Continuation; import org.logic2j.engine.solver.listener.CountingSolutionListener; import org.logic2j.engine.solver.listener.SolutionListener; import org.logic2j.engine.unify.UnifyContext; System.out.println("logic2j REPL"); final List<File> theories = new ArrayList<>(); for (String arg : args) { theories.add(new File(arg)); } prolog = new FluentPrologBuilder().withTheory(theories.toArray(new File[0])).build(); final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("?- "); String goal = br.readLine(); goal = goal.trim(); // Removing trailing period if (goal.lastIndexOf('.') >= 0) { goal = goal.substring(0, goal.lastIndexOf('.')); } if ("quit".equals(goal) || "exit".equals(goal) || "bye".equals(goal)) { System.out.println("Bye"); return; } runOne(goal); } } protected void runOne(String goalText) { try { // Parse and extract vars
final TermMarshaller termMarshaller = prolog.getTermMarshaller();
daltonj/CIIRShared
src/main/java/edu/umass/ciir/TabFileRecordReader.java
// Path: src/main/java/edu/umass/ciir/FileRecordReader.java // public abstract class FileRecordReader<T> { // // /** // * If true, all lines starting with # will be ignored. // */ // private boolean m_ignoreComments = true; // // /** // * Empty lines will be ignored. // */ // private boolean m_skipBlank = true; // // /** // * If true, individual errors parsing lines will be ignored. // */ // protected final boolean m_catchParseExceptions; // // /** // * The underlying buffered reader. // */ // protected BufferedReader m_bufReader; // // /** // * A simple prefix filter. Terms after this will be ignored. // */ // protected final PrefixFilter m_prefixFilter; // // /** // * Constructor, opens the file for reading. If this successfully completes the client must // * call close() to ensure the file is closed! // * // * @param fileToRead // */ // public FileRecordReader(Reader reader, boolean catchParseExceptions, PrefixFilter prefixFilter) throws Exception { // m_prefixFilter = prefixFilter; // m_bufReader = new BufferedReader(reader); // m_catchParseExceptions = catchParseExceptions; // } // // /** // * Constructor, opens the file for reading. If this successfully completes the client must // * call close() to ensure the file is closed! // * // * @param fileToRead // */ // protected FileRecordReader(boolean catchParseExceptions, PrefixFilter prefixFilter) throws Exception { // m_prefixFilter = prefixFilter; // m_catchParseExceptions = catchParseExceptions; // } // // /** // * Reads a file and parses it, line by line. // * // * @return T object parsed from the line, or null if there are no more entries // * @throws Exception // */ // public T read() // throws Exception { // T obj = null; // String input = null; // while ((obj == null) && (input = m_bufReader.readLine()) != null) { // if (m_ignoreComments && input.startsWith("#") || // (m_skipBlank && input.length() == 0) || // (m_prefixFilter != null && m_prefixFilter.filterOut(input))) { // // skip comments or blank lines when appropriate // } else { // try { // // if (input.length() > 500) { // // System.out.println("Error processing long line: " + input.length()); // // continue; // // } // obj = parseLine(input); // } catch (Exception e) { // System.out.println("Error parsing input:" + input); // if (!m_catchParseExceptions) { // throw e; // } // } // } // } // return obj; // } // // protected abstract T parseLine(String input) throws Exception ; // // /** // * This MUST be closed. // */ // public void close() throws IOException { // m_bufReader.close(); // } // // public void setIgnoreComments(boolean ignoreComments) { // m_ignoreComments = ignoreComments; // } // // public void setSkipBlank(boolean skipBlank) { // m_skipBlank = skipBlank; // } // // public boolean getIgnoreComments() { // return m_ignoreComments; // } // // public boolean getSkipBlank() { // return m_skipBlank; // } // } // // Path: src/main/java/edu/umass/ciir/PrefixFilter.java // public class PrefixFilter { // // private final Character m_start; // private final Character m_end; // // public PrefixFilter(Character start, Character end) { // m_start = start; // m_end = end; // // } // // public boolean filterOut(String stringToTest) { // char f = stringToTest.charAt(0); // // // if (m_start == null) { // // only based on end. // if (m_end.compareTo(f) < 0) { // return true; // } // } else { // if (m_start.compareTo(f) > 0 || m_end.compareTo(f) < 0) { // return true; // } // } // // return false; // } // // public static void main(String[] args) { // PrefixFilter filter = new PrefixFilter('a', 'a'); // System.out.println(filter.filterOut("abc")); // System.out.println(filter.filterOut("baby")); // System.out.println(filter.filterOut("c")); // System.out.println(filter.filterOut("dog")); // System.out.println(filter.filterOut("emo")); // System.out.println(filter.filterOut("faf")); // } // // }
import java.io.File; import java.io.FileReader; import edu.umass.ciir.FileRecordReader; import edu.umass.ciir.PrefixFilter;
package edu.umass.ciir; public class TabFileRecordReader extends FileRecordReader<String[]> { public TabFileRecordReader(File fileToRead,
// Path: src/main/java/edu/umass/ciir/FileRecordReader.java // public abstract class FileRecordReader<T> { // // /** // * If true, all lines starting with # will be ignored. // */ // private boolean m_ignoreComments = true; // // /** // * Empty lines will be ignored. // */ // private boolean m_skipBlank = true; // // /** // * If true, individual errors parsing lines will be ignored. // */ // protected final boolean m_catchParseExceptions; // // /** // * The underlying buffered reader. // */ // protected BufferedReader m_bufReader; // // /** // * A simple prefix filter. Terms after this will be ignored. // */ // protected final PrefixFilter m_prefixFilter; // // /** // * Constructor, opens the file for reading. If this successfully completes the client must // * call close() to ensure the file is closed! // * // * @param fileToRead // */ // public FileRecordReader(Reader reader, boolean catchParseExceptions, PrefixFilter prefixFilter) throws Exception { // m_prefixFilter = prefixFilter; // m_bufReader = new BufferedReader(reader); // m_catchParseExceptions = catchParseExceptions; // } // // /** // * Constructor, opens the file for reading. If this successfully completes the client must // * call close() to ensure the file is closed! // * // * @param fileToRead // */ // protected FileRecordReader(boolean catchParseExceptions, PrefixFilter prefixFilter) throws Exception { // m_prefixFilter = prefixFilter; // m_catchParseExceptions = catchParseExceptions; // } // // /** // * Reads a file and parses it, line by line. // * // * @return T object parsed from the line, or null if there are no more entries // * @throws Exception // */ // public T read() // throws Exception { // T obj = null; // String input = null; // while ((obj == null) && (input = m_bufReader.readLine()) != null) { // if (m_ignoreComments && input.startsWith("#") || // (m_skipBlank && input.length() == 0) || // (m_prefixFilter != null && m_prefixFilter.filterOut(input))) { // // skip comments or blank lines when appropriate // } else { // try { // // if (input.length() > 500) { // // System.out.println("Error processing long line: " + input.length()); // // continue; // // } // obj = parseLine(input); // } catch (Exception e) { // System.out.println("Error parsing input:" + input); // if (!m_catchParseExceptions) { // throw e; // } // } // } // } // return obj; // } // // protected abstract T parseLine(String input) throws Exception ; // // /** // * This MUST be closed. // */ // public void close() throws IOException { // m_bufReader.close(); // } // // public void setIgnoreComments(boolean ignoreComments) { // m_ignoreComments = ignoreComments; // } // // public void setSkipBlank(boolean skipBlank) { // m_skipBlank = skipBlank; // } // // public boolean getIgnoreComments() { // return m_ignoreComments; // } // // public boolean getSkipBlank() { // return m_skipBlank; // } // } // // Path: src/main/java/edu/umass/ciir/PrefixFilter.java // public class PrefixFilter { // // private final Character m_start; // private final Character m_end; // // public PrefixFilter(Character start, Character end) { // m_start = start; // m_end = end; // // } // // public boolean filterOut(String stringToTest) { // char f = stringToTest.charAt(0); // // // if (m_start == null) { // // only based on end. // if (m_end.compareTo(f) < 0) { // return true; // } // } else { // if (m_start.compareTo(f) > 0 || m_end.compareTo(f) < 0) { // return true; // } // } // // return false; // } // // public static void main(String[] args) { // PrefixFilter filter = new PrefixFilter('a', 'a'); // System.out.println(filter.filterOut("abc")); // System.out.println(filter.filterOut("baby")); // System.out.println(filter.filterOut("c")); // System.out.println(filter.filterOut("dog")); // System.out.println(filter.filterOut("emo")); // System.out.println(filter.filterOut("faf")); // } // // } // Path: src/main/java/edu/umass/ciir/TabFileRecordReader.java import java.io.File; import java.io.FileReader; import edu.umass.ciir.FileRecordReader; import edu.umass.ciir.PrefixFilter; package edu.umass.ciir; public class TabFileRecordReader extends FileRecordReader<String[]> { public TabFileRecordReader(File fileToRead,
boolean catchParseExceptions, PrefixFilter prefixFilter)
daltonj/CIIRShared
src/main/java/edu/umass/ciir/trec/parsers/TRECBlog08Parser.java
// Path: src/main/java/edu/umass/ciir/trec/types/TRECJudgment.java // public class TRECJudgment implements Comparable<TRECJudgment> { // private int m_topic; // private int m_run; // private String m_label; // private int m_judgment; // // public TRECJudgment(int t, int r, String l, int j) { // this.m_topic = t; // this.m_run = r; // this.m_label = l; // this.m_judgment = j; // } // // public int getTopic() { return m_topic; } // public int getRun() { return m_run; } // public String getLabel() { return m_label; } // public int getJudgment() { return m_judgment; } // // public int compareTo(TRECJudgment o) { // if (this.getTopic() < o.getTopic()) return -1; // if (this.getTopic() > o.getTopic()) return 1; // if (this.getRun() < o.getRun()) return -1; // if (this.getRun() > o.getRun()) return 1; // // int labelComp = this.getLabel().compareTo(o.getLabel()); // if (labelComp != 0) return labelComp; // // if (this.getJudgment() < o.getJudgment()) return -1; // if (this.getJudgment() > o.getJudgment()) return 1; // // return 0; // } // // } // // Path: src/main/java/edu/umass/ciir/trec/types/TRECTopic.java // public class TRECTopic implements Comparable<TRECTopic> { // // private int m_number; // private String m_title; // private String m_description; // private String m_narrative; // // public TRECTopic(int n, String t, String d, String na) { // this.m_number = n; // this.m_title = t; // this.m_description = d; // this.m_narrative = na; // } // // public int getNumber() { return m_number; } // public String getTitle() { return m_title; } // public String getDescription() { return m_description; } // public String getNarrative() { return m_narrative; } // // // /** // * Compares topic number, and if they are equals, returns lexographical comparison of the title fields. // */ // public int compareTo(TRECTopic o) { // if (this.getNumber() < o.getNumber()) return -1; // if (this.getNumber() > o.getNumber()) return 1; // return (this.getTitle().compareTo(o.getTitle())); // } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; import edu.umass.ciir.trec.types.TRECJudgment; import edu.umass.ciir.trec.types.TRECTopic;
package edu.umass.ciir.trec.parsers; public class TRECBlog08Parser { private static Pattern pJudgments = Pattern.compile("(\\d+) (\\d+) (\\S+) (\\d+)"); private static Pattern pTopics = Pattern.compile("<top>\\s*<num> Number: (\\d+) </num>\\s*<title>(.+?)</title>\\s*<desc> Description:(.+?)</desc>\\s*<narr> Narrative:(.+?)</narr>\\s*</top>", Pattern.DOTALL); public TRECBlog08Parser() {}
// Path: src/main/java/edu/umass/ciir/trec/types/TRECJudgment.java // public class TRECJudgment implements Comparable<TRECJudgment> { // private int m_topic; // private int m_run; // private String m_label; // private int m_judgment; // // public TRECJudgment(int t, int r, String l, int j) { // this.m_topic = t; // this.m_run = r; // this.m_label = l; // this.m_judgment = j; // } // // public int getTopic() { return m_topic; } // public int getRun() { return m_run; } // public String getLabel() { return m_label; } // public int getJudgment() { return m_judgment; } // // public int compareTo(TRECJudgment o) { // if (this.getTopic() < o.getTopic()) return -1; // if (this.getTopic() > o.getTopic()) return 1; // if (this.getRun() < o.getRun()) return -1; // if (this.getRun() > o.getRun()) return 1; // // int labelComp = this.getLabel().compareTo(o.getLabel()); // if (labelComp != 0) return labelComp; // // if (this.getJudgment() < o.getJudgment()) return -1; // if (this.getJudgment() > o.getJudgment()) return 1; // // return 0; // } // // } // // Path: src/main/java/edu/umass/ciir/trec/types/TRECTopic.java // public class TRECTopic implements Comparable<TRECTopic> { // // private int m_number; // private String m_title; // private String m_description; // private String m_narrative; // // public TRECTopic(int n, String t, String d, String na) { // this.m_number = n; // this.m_title = t; // this.m_description = d; // this.m_narrative = na; // } // // public int getNumber() { return m_number; } // public String getTitle() { return m_title; } // public String getDescription() { return m_description; } // public String getNarrative() { return m_narrative; } // // // /** // * Compares topic number, and if they are equals, returns lexographical comparison of the title fields. // */ // public int compareTo(TRECTopic o) { // if (this.getNumber() < o.getNumber()) return -1; // if (this.getNumber() > o.getNumber()) return 1; // return (this.getTitle().compareTo(o.getTitle())); // } // } // Path: src/main/java/edu/umass/ciir/trec/parsers/TRECBlog08Parser.java import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; import edu.umass.ciir.trec.types.TRECJudgment; import edu.umass.ciir.trec.types.TRECTopic; package edu.umass.ciir.trec.parsers; public class TRECBlog08Parser { private static Pattern pJudgments = Pattern.compile("(\\d+) (\\d+) (\\S+) (\\d+)"); private static Pattern pTopics = Pattern.compile("<top>\\s*<num> Number: (\\d+) </num>\\s*<title>(.+?)</title>\\s*<desc> Description:(.+?)</desc>\\s*<narr> Narrative:(.+?)</narr>\\s*</top>", Pattern.DOTALL); public TRECBlog08Parser() {}
private static TRECJudgment parseJudgmentLine(String line) {
daltonj/CIIRShared
src/main/java/edu/umass/ciir/trec/parsers/TRECBlog08Parser.java
// Path: src/main/java/edu/umass/ciir/trec/types/TRECJudgment.java // public class TRECJudgment implements Comparable<TRECJudgment> { // private int m_topic; // private int m_run; // private String m_label; // private int m_judgment; // // public TRECJudgment(int t, int r, String l, int j) { // this.m_topic = t; // this.m_run = r; // this.m_label = l; // this.m_judgment = j; // } // // public int getTopic() { return m_topic; } // public int getRun() { return m_run; } // public String getLabel() { return m_label; } // public int getJudgment() { return m_judgment; } // // public int compareTo(TRECJudgment o) { // if (this.getTopic() < o.getTopic()) return -1; // if (this.getTopic() > o.getTopic()) return 1; // if (this.getRun() < o.getRun()) return -1; // if (this.getRun() > o.getRun()) return 1; // // int labelComp = this.getLabel().compareTo(o.getLabel()); // if (labelComp != 0) return labelComp; // // if (this.getJudgment() < o.getJudgment()) return -1; // if (this.getJudgment() > o.getJudgment()) return 1; // // return 0; // } // // } // // Path: src/main/java/edu/umass/ciir/trec/types/TRECTopic.java // public class TRECTopic implements Comparable<TRECTopic> { // // private int m_number; // private String m_title; // private String m_description; // private String m_narrative; // // public TRECTopic(int n, String t, String d, String na) { // this.m_number = n; // this.m_title = t; // this.m_description = d; // this.m_narrative = na; // } // // public int getNumber() { return m_number; } // public String getTitle() { return m_title; } // public String getDescription() { return m_description; } // public String getNarrative() { return m_narrative; } // // // /** // * Compares topic number, and if they are equals, returns lexographical comparison of the title fields. // */ // public int compareTo(TRECTopic o) { // if (this.getNumber() < o.getNumber()) return -1; // if (this.getNumber() > o.getNumber()) return 1; // return (this.getTitle().compareTo(o.getTitle())); // } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; import edu.umass.ciir.trec.types.TRECJudgment; import edu.umass.ciir.trec.types.TRECTopic;
package edu.umass.ciir.trec.parsers; public class TRECBlog08Parser { private static Pattern pJudgments = Pattern.compile("(\\d+) (\\d+) (\\S+) (\\d+)"); private static Pattern pTopics = Pattern.compile("<top>\\s*<num> Number: (\\d+) </num>\\s*<title>(.+?)</title>\\s*<desc> Description:(.+?)</desc>\\s*<narr> Narrative:(.+?)</narr>\\s*</top>", Pattern.DOTALL); public TRECBlog08Parser() {} private static TRECJudgment parseJudgmentLine(String line) { Matcher m = pJudgments.matcher(line); if (m.matches()) { return (new TRECJudgment(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)), m.group(3), Integer.parseInt(m.group(4)))); } else { return null; } }
// Path: src/main/java/edu/umass/ciir/trec/types/TRECJudgment.java // public class TRECJudgment implements Comparable<TRECJudgment> { // private int m_topic; // private int m_run; // private String m_label; // private int m_judgment; // // public TRECJudgment(int t, int r, String l, int j) { // this.m_topic = t; // this.m_run = r; // this.m_label = l; // this.m_judgment = j; // } // // public int getTopic() { return m_topic; } // public int getRun() { return m_run; } // public String getLabel() { return m_label; } // public int getJudgment() { return m_judgment; } // // public int compareTo(TRECJudgment o) { // if (this.getTopic() < o.getTopic()) return -1; // if (this.getTopic() > o.getTopic()) return 1; // if (this.getRun() < o.getRun()) return -1; // if (this.getRun() > o.getRun()) return 1; // // int labelComp = this.getLabel().compareTo(o.getLabel()); // if (labelComp != 0) return labelComp; // // if (this.getJudgment() < o.getJudgment()) return -1; // if (this.getJudgment() > o.getJudgment()) return 1; // // return 0; // } // // } // // Path: src/main/java/edu/umass/ciir/trec/types/TRECTopic.java // public class TRECTopic implements Comparable<TRECTopic> { // // private int m_number; // private String m_title; // private String m_description; // private String m_narrative; // // public TRECTopic(int n, String t, String d, String na) { // this.m_number = n; // this.m_title = t; // this.m_description = d; // this.m_narrative = na; // } // // public int getNumber() { return m_number; } // public String getTitle() { return m_title; } // public String getDescription() { return m_description; } // public String getNarrative() { return m_narrative; } // // // /** // * Compares topic number, and if they are equals, returns lexographical comparison of the title fields. // */ // public int compareTo(TRECTopic o) { // if (this.getNumber() < o.getNumber()) return -1; // if (this.getNumber() > o.getNumber()) return 1; // return (this.getTitle().compareTo(o.getTitle())); // } // } // Path: src/main/java/edu/umass/ciir/trec/parsers/TRECBlog08Parser.java import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; import edu.umass.ciir.trec.types.TRECJudgment; import edu.umass.ciir.trec.types.TRECTopic; package edu.umass.ciir.trec.parsers; public class TRECBlog08Parser { private static Pattern pJudgments = Pattern.compile("(\\d+) (\\d+) (\\S+) (\\d+)"); private static Pattern pTopics = Pattern.compile("<top>\\s*<num> Number: (\\d+) </num>\\s*<title>(.+?)</title>\\s*<desc> Description:(.+?)</desc>\\s*<narr> Narrative:(.+?)</narr>\\s*</top>", Pattern.DOTALL); public TRECBlog08Parser() {} private static TRECJudgment parseJudgmentLine(String line) { Matcher m = pJudgments.matcher(line); if (m.matches()) { return (new TRECJudgment(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)), m.group(3), Integer.parseInt(m.group(4)))); } else { return null; } }
public Iterator<TRECTopic> topicIterator(File source) {
daltonj/CIIRShared
src/main/java/edu/umass/ciir/memindex/GalagoIndexSearcher.java
// Path: src/main/java/edu/umass/ciir/CiirProperties.java // public class CiirProperties { // // public static Properties properties = new Properties(); // // public static void load(String propertiesFile) throws IOException { // FileInputStream fileInputStream = new FileInputStream(propertiesFile); // properties.load(fileInputStream); // fileInputStream.close(); // } // // public static String getProperty(String propertyName) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // throw new IllegalStateException("Required property not specified, " + propertyName); // } // return propVal; // } // // public static String getProperty(String propertyName, String defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } // return propVal; // } // // public static double getPropertyAsDouble(String propertyName, double defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } // return Double.parseDouble(propVal); // } // // public static int getPropertyAsInt(String propertyName, int defaultVal) { // // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } else { // return Integer.parseInt(properties.getProperty(propertyName)); // } // // } // // public static boolean getPropertyAsBoolean(String propertyName) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // throw new IllegalStateException("Required property not specified:" + propertyName); // } // return Boolean.parseBoolean(propVal); // } // // public static boolean getPropertyAsBoolean(String propertyName, boolean defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } else { // return Boolean.parseBoolean(propVal); // } // // } // // public static void printProperties() { // String[] keySet = properties.keySet().toArray(new String[0]); // Arrays.sort(keySet); // for (String key : keySet) { // String val = properties.getProperty(key); // if (val.length() > 40) { // val = val.substring(0, 37) + "..."; // } // System.out.println(key + "=" + val); // } // } // // }
import java.util.ArrayList; import java.util.List; import org.lemurproject.galago.core.index.corpus.CorpusReader; import org.lemurproject.galago.core.index.mem.MemoryIndex; import org.lemurproject.galago.core.retrieval.LocalRetrieval; import org.lemurproject.galago.core.retrieval.Results; import org.lemurproject.galago.core.retrieval.Retrieval; import org.lemurproject.galago.core.retrieval.ScoredDocument; import org.lemurproject.galago.core.retrieval.query.Node; import org.lemurproject.galago.core.retrieval.query.StructuredQuery; import org.lemurproject.galago.utility.Parameters; import edu.umass.ciir.CiirProperties;
package edu.umass.ciir.memindex; public class GalagoIndexSearcher implements SearcherI { protected Parameters queryParams = Parameters.create(); Retrieval m_retrieval; private final Corpus m_corpus; public GalagoIndexSearcher(MemoryIndex index, Corpus corpus) throws Exception { m_corpus = corpus;
// Path: src/main/java/edu/umass/ciir/CiirProperties.java // public class CiirProperties { // // public static Properties properties = new Properties(); // // public static void load(String propertiesFile) throws IOException { // FileInputStream fileInputStream = new FileInputStream(propertiesFile); // properties.load(fileInputStream); // fileInputStream.close(); // } // // public static String getProperty(String propertyName) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // throw new IllegalStateException("Required property not specified, " + propertyName); // } // return propVal; // } // // public static String getProperty(String propertyName, String defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } // return propVal; // } // // public static double getPropertyAsDouble(String propertyName, double defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } // return Double.parseDouble(propVal); // } // // public static int getPropertyAsInt(String propertyName, int defaultVal) { // // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } else { // return Integer.parseInt(properties.getProperty(propertyName)); // } // // } // // public static boolean getPropertyAsBoolean(String propertyName) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // throw new IllegalStateException("Required property not specified:" + propertyName); // } // return Boolean.parseBoolean(propVal); // } // // public static boolean getPropertyAsBoolean(String propertyName, boolean defaultVal) { // String propVal = properties.getProperty(propertyName); // if (propVal == null) { // return defaultVal; // } else { // return Boolean.parseBoolean(propVal); // } // // } // // public static void printProperties() { // String[] keySet = properties.keySet().toArray(new String[0]); // Arrays.sort(keySet); // for (String key : keySet) { // String val = properties.getProperty(key); // if (val.length() > 40) { // val = val.substring(0, 37) + "..."; // } // System.out.println(key + "=" + val); // } // } // // } // Path: src/main/java/edu/umass/ciir/memindex/GalagoIndexSearcher.java import java.util.ArrayList; import java.util.List; import org.lemurproject.galago.core.index.corpus.CorpusReader; import org.lemurproject.galago.core.index.mem.MemoryIndex; import org.lemurproject.galago.core.retrieval.LocalRetrieval; import org.lemurproject.galago.core.retrieval.Results; import org.lemurproject.galago.core.retrieval.Retrieval; import org.lemurproject.galago.core.retrieval.ScoredDocument; import org.lemurproject.galago.core.retrieval.query.Node; import org.lemurproject.galago.core.retrieval.query.StructuredQuery; import org.lemurproject.galago.utility.Parameters; import edu.umass.ciir.CiirProperties; package edu.umass.ciir.memindex; public class GalagoIndexSearcher implements SearcherI { protected Parameters queryParams = Parameters.create(); Retrieval m_retrieval; private final Corpus m_corpus; public GalagoIndexSearcher(MemoryIndex index, Corpus corpus) throws Exception { m_corpus = corpus;
queryParams.set("mu", CiirProperties.getPropertyAsDouble("Searcher.mu", 2500d));
JANNLab/JANNLab
src/main/java/de/jannlab/core/Layer.java
// Path: src/main/java/de/jannlab/misc/IntTools.java // public final class IntTools { // // public static void shuffle( // final int[] data, // final Random rnd // ) { // // // final int size = data.length; // // // for (int i = size; i > 1; i--) { // final int ii = i - 1; // final int r = rnd.nextInt(i); // // // final int temp = data[ii]; // data[ii] = data[r]; // data[r] = temp; // } // } // // public static String asString(final int[] data) { // return asString(data, 0, data.length); // } // // public static String asString(final int[] data, final int offset, final int size) { // StringWriter out = new StringWriter(); // // int o = offset; // for (int i = 0; i < size; i++) { // if (i > 0) out.append(", "); // out.append(Integer.toString(data[o])); // o++; // } // return out.toString(); // } // // }
import java.io.Serializable; import de.jannlab.misc.IntTools;
/******************************************************************************* * JANNLab Neural Network Framework for Java * Copyright (C) 2012-2013 Sebastian Otte * * 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 de.jannlab.core; /** * An instance of this class defines a Layer in ANN. It contains some information * on the CellArray corresponding to this layer and some other computational * specification (e.g. the computational dependencies of the containing CellArrays). * <br></br> * @author Sebastian Otte */ public final class Layer implements Serializable{ private static final long serialVersionUID = 52359162370719687L; public static final int NO_LAYER = -1; //------------------------------------------------------------------------- /** * Gives the lower bound of the cells contained by this layer. */ public int cellslbd = 0; /** * Gives the upper bound of the cells contained by this layer. */ public int cellsubd = -1; /** * Gives the number of the cells contained by this layer. */ public int cellsnum = 0; /** * Gives the lower bound of the arrays contained by this layer. */ public int arrayslbd = 0; /** * Gives the upper bound of the arrays contained by this layer. */ public int arraysubd = -1; /** * Gives the number of the arrays contained by this layer. */ public int arraysnum = 0; /** * Gives the lower bounds of the packages of computational independent * arrays. Arrays with the same computation index are computed at the same * time. */ public int[] complbds = null; /** * Gives the uppder bounds of the packages of computational independent * arrays. Arrays with the same computation index are computed at the same * time. */ public int[] compubds = null; /** * Gives the number of the packages of computational independent * arrays. */ public int compwidth = 0; /** * Gives the degree of incoming connections to all cells contained by all * array in this layer. */ public int indeg = 0; /** * Gives the degree of outgoing connections of all cells contained by all * array in this layer. */ public int outdeg = 0; /** * Gives the tag of the layer, which contains information of its * computational behavior. */ public int tag = LayerTag.REGULAR; //------------------------------------------------------------------------- /** * {@inheritDoc} */ @Override public String toString() { StringBuilder w = new StringBuilder(); // w.append("cellslbd : " + this.cellslbd + "\n"); w.append("cellsubd : " + this.cellsubd + "\n"); w.append("cellsnum : " + this.cellsnum + "\n"); w.append("arrayslbd : " + this.arrayslbd + "\n"); w.append("arraysubd : " + this.arraysubd + "\n"); w.append("arraysnum : " + this.arraysnum + "\n"); w.append("compwidth : " + this.compwidth + "\n");
// Path: src/main/java/de/jannlab/misc/IntTools.java // public final class IntTools { // // public static void shuffle( // final int[] data, // final Random rnd // ) { // // // final int size = data.length; // // // for (int i = size; i > 1; i--) { // final int ii = i - 1; // final int r = rnd.nextInt(i); // // // final int temp = data[ii]; // data[ii] = data[r]; // data[r] = temp; // } // } // // public static String asString(final int[] data) { // return asString(data, 0, data.length); // } // // public static String asString(final int[] data, final int offset, final int size) { // StringWriter out = new StringWriter(); // // int o = offset; // for (int i = 0; i < size; i++) { // if (i > 0) out.append(", "); // out.append(Integer.toString(data[o])); // o++; // } // return out.toString(); // } // // } // Path: src/main/java/de/jannlab/core/Layer.java import java.io.Serializable; import de.jannlab.misc.IntTools; /******************************************************************************* * JANNLab Neural Network Framework for Java * Copyright (C) 2012-2013 Sebastian Otte * * 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 de.jannlab.core; /** * An instance of this class defines a Layer in ANN. It contains some information * on the CellArray corresponding to this layer and some other computational * specification (e.g. the computational dependencies of the containing CellArrays). * <br></br> * @author Sebastian Otte */ public final class Layer implements Serializable{ private static final long serialVersionUID = 52359162370719687L; public static final int NO_LAYER = -1; //------------------------------------------------------------------------- /** * Gives the lower bound of the cells contained by this layer. */ public int cellslbd = 0; /** * Gives the upper bound of the cells contained by this layer. */ public int cellsubd = -1; /** * Gives the number of the cells contained by this layer. */ public int cellsnum = 0; /** * Gives the lower bound of the arrays contained by this layer. */ public int arrayslbd = 0; /** * Gives the upper bound of the arrays contained by this layer. */ public int arraysubd = -1; /** * Gives the number of the arrays contained by this layer. */ public int arraysnum = 0; /** * Gives the lower bounds of the packages of computational independent * arrays. Arrays with the same computation index are computed at the same * time. */ public int[] complbds = null; /** * Gives the uppder bounds of the packages of computational independent * arrays. Arrays with the same computation index are computed at the same * time. */ public int[] compubds = null; /** * Gives the number of the packages of computational independent * arrays. */ public int compwidth = 0; /** * Gives the degree of incoming connections to all cells contained by all * array in this layer. */ public int indeg = 0; /** * Gives the degree of outgoing connections of all cells contained by all * array in this layer. */ public int outdeg = 0; /** * Gives the tag of the layer, which contains information of its * computational behavior. */ public int tag = LayerTag.REGULAR; //------------------------------------------------------------------------- /** * {@inheritDoc} */ @Override public String toString() { StringBuilder w = new StringBuilder(); // w.append("cellslbd : " + this.cellslbd + "\n"); w.append("cellsubd : " + this.cellsubd + "\n"); w.append("cellsnum : " + this.cellsnum + "\n"); w.append("arrayslbd : " + this.arrayslbd + "\n"); w.append("arraysubd : " + this.arraysubd + "\n"); w.append("arraysnum : " + this.arraysnum + "\n"); w.append("compwidth : " + this.compwidth + "\n");
w.append("complbds : " + "(" + IntTools.asString(this.complbds) + ")\n");
JANNLab/JANNLab
src/main/java/de/jannlab/core/NetData.java
// Path: src/main/java/de/jannlab/misc/ObjectCopy.java // public class ObjectCopy { // /** // * Returns a copy of the object, or null if the object cannot // * be serialized. // */ // public static <T extends Serializable> T copy(final T obj) { // try { // // // // serialize object. // // // ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // ObjectOutputStream out = new ObjectOutputStream(buffer); // out.writeObject(obj); // out.flush(); // out.close(); // // // // de-serialize object. // // // ObjectInputStream in = new ObjectInputStream( // new ByteArrayInputStream(buffer.toByteArray()) // ); // // // @SuppressWarnings("unchecked") // final T result = (T)in.readObject(); // in.close(); // return result; // } catch (Exception e) { // return null; // } // } // }
import java.io.Serializable; import de.jannlab.misc.ObjectCopy;
/******************************************************************************* * JANNLab Neural Network Framework for Java * Copyright (C) 2012-2013 Sebastian Otte * * 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 de.jannlab.core; /** * An instance of this class contains the entire data of an ANN. This are on one hand * the data buffers for forward and backward computation (input, ouput, gradinput, * gradoutput) for each time step (the timesteps are defined by the frame width). * @author Sebastian Otte */ public final class NetData implements Serializable { private static final long serialVersionUID = 9138637243730569419L; /** * provides the input buffer. the results of the forward * integrations are stored here. */ public double[][] input; /** * provides the output buffer. the results of the forward * activations and also the network input are stored here. */ public double[][] output; /** * provides the grad. input buffer. the results of the backward * integrations and also the network error are stored here. */ public double[][] gradinput; /** * provides the grad. output buffer. the results of the activation * deviations and also the "back-flowing" error are stored here. */ public double[][] gradoutput; /** * determines the frame width, which is the first dimension of the * data buffers. MLPs or trained RNNs only need a frame width of 1. * Online offline computing RNNs or online computing RNNs during * training need a frame width > 1. */ public int framewidth; /** * provides the vector of weigts. note that the first value of the vector * is generally 1.0. this is founded in some runtime peformance improvements * concerning non weighted links. */ public double[] weights; /** * Gives the number of weights exclusive the constant 1.0 weight. */ public int weightsnum; /** * Stores the indices to the cells used for constant value assignments. */ public int[] asgns; /** * Stores the constant values assignments corresponding to the indices * given in asgns. */ public double[] asgnsv; /** * This method returns a shared copy of the current data record. This means * that the entire data buffer is "really" duplicated while the weights and * the assignments are shared. A shared copy can be used for independent * computations on the same weights vector, which is an important requirement * for computing/training the same problem in parallel with multiple Net instances. * <br></br> * @return Copy of this data record with shared weights and assigments. */ public NetData sharedCopy() { NetData copy = new NetData(); // // copy. //
// Path: src/main/java/de/jannlab/misc/ObjectCopy.java // public class ObjectCopy { // /** // * Returns a copy of the object, or null if the object cannot // * be serialized. // */ // public static <T extends Serializable> T copy(final T obj) { // try { // // // // serialize object. // // // ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // ObjectOutputStream out = new ObjectOutputStream(buffer); // out.writeObject(obj); // out.flush(); // out.close(); // // // // de-serialize object. // // // ObjectInputStream in = new ObjectInputStream( // new ByteArrayInputStream(buffer.toByteArray()) // ); // // // @SuppressWarnings("unchecked") // final T result = (T)in.readObject(); // in.close(); // return result; // } catch (Exception e) { // return null; // } // } // } // Path: src/main/java/de/jannlab/core/NetData.java import java.io.Serializable; import de.jannlab.misc.ObjectCopy; /******************************************************************************* * JANNLab Neural Network Framework for Java * Copyright (C) 2012-2013 Sebastian Otte * * 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 de.jannlab.core; /** * An instance of this class contains the entire data of an ANN. This are on one hand * the data buffers for forward and backward computation (input, ouput, gradinput, * gradoutput) for each time step (the timesteps are defined by the frame width). * @author Sebastian Otte */ public final class NetData implements Serializable { private static final long serialVersionUID = 9138637243730569419L; /** * provides the input buffer. the results of the forward * integrations are stored here. */ public double[][] input; /** * provides the output buffer. the results of the forward * activations and also the network input are stored here. */ public double[][] output; /** * provides the grad. input buffer. the results of the backward * integrations and also the network error are stored here. */ public double[][] gradinput; /** * provides the grad. output buffer. the results of the activation * deviations and also the "back-flowing" error are stored here. */ public double[][] gradoutput; /** * determines the frame width, which is the first dimension of the * data buffers. MLPs or trained RNNs only need a frame width of 1. * Online offline computing RNNs or online computing RNNs during * training need a frame width > 1. */ public int framewidth; /** * provides the vector of weigts. note that the first value of the vector * is generally 1.0. this is founded in some runtime peformance improvements * concerning non weighted links. */ public double[] weights; /** * Gives the number of weights exclusive the constant 1.0 weight. */ public int weightsnum; /** * Stores the indices to the cells used for constant value assignments. */ public int[] asgns; /** * Stores the constant values assignments corresponding to the indices * given in asgns. */ public double[] asgnsv; /** * This method returns a shared copy of the current data record. This means * that the entire data buffer is "really" duplicated while the weights and * the assignments are shared. A shared copy can be used for independent * computations on the same weights vector, which is an important requirement * for computing/training the same problem in parallel with multiple Net instances. * <br></br> * @return Copy of this data record with shared weights and assigments. */ public NetData sharedCopy() { NetData copy = new NetData(); // // copy. //
copy.input = ObjectCopy.copy(this.input);
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/IterativeMethodBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // }
import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized;
@Override public void initialize() { this.iterativeMethodInitialize(); this.initialized = true; this.reset(); } private void finished() { // final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() {
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // } // Path: src/main/java/de/jannlab/optimization/IterativeMethodBase.java import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized; @Override public void initialize() { this.iterativeMethodInitialize(); this.initialized = true; this.reset(); } private void finished() { // final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() {
if (this.running) throw new NotAllowedWhileRunning();
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/IterativeMethodBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // }
import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized;
// final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() { if (this.running) throw new NotAllowedWhileRunning(); this.iteration = 0; this.abort = false; this.updateError(Double.POSITIVE_INFINITY); this.iterativeMethodReset(); }
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // } // Path: src/main/java/de/jannlab/optimization/IterativeMethodBase.java import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized; // final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() { if (this.running) throw new NotAllowedWhileRunning(); this.iteration = 0; this.abort = false; this.updateError(Double.POSITIVE_INFINITY); this.iterativeMethodReset(); }
protected void preIterationCheck() throws IterativeMethodException {
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/IterativeMethodBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // }
import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized;
final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() { if (this.running) throw new NotAllowedWhileRunning(); this.iteration = 0; this.abort = false; this.updateError(Double.POSITIVE_INFINITY); this.iterativeMethodReset(); } protected void preIterationCheck() throws IterativeMethodException {
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotAllowedWhileRunning.java // public class NotAllowedWhileRunning extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotAllowedWhileRunning() { // super("Action not allowed while running process."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/NotInitialized.java // public class NotInitialized extends IterativeMethodException { // private static final long serialVersionUID = 1194916015131585272L; // // public NotInitialized() { // super("optimizer not initialized."); // } // // } // Path: src/main/java/de/jannlab/optimization/IterativeMethodBase.java import java.util.LinkedList; import java.util.List; import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NotAllowedWhileRunning; import de.jannlab.optimization.exception.NotInitialized; final I me = this.iterativeMethodMe(); // for (IterationListener<I> l : this.listener) { l.finished(this.iteration, this.error, me); } } @Override public int getIteration() { return this.iteration; } protected abstract void iterativeMethodReset(); protected abstract double iterativeMethodPerformIteration(); protected void updateError(final double error) { this.error = error; } @Override public void reset() { if (this.running) throw new NotAllowedWhileRunning(); this.iteration = 0; this.abort = false; this.updateError(Double.POSITIVE_INFINITY); this.iterativeMethodReset(); } protected void preIterationCheck() throws IterativeMethodException {
if (!this.initialized) throw new NotInitialized();
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/OptimizerBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // }
import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective;
StringBuilder out = new StringBuilder(); // out.append(super.toString()); // out.append( KEY_PARAMS + ": " + this.getParameters() + "\n" ); // return out.toString(); } public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) {
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // } // Path: src/main/java/de/jannlab/optimization/OptimizerBase.java import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective; StringBuilder out = new StringBuilder(); // out.append(super.toString()); // out.append( KEY_PARAMS + ": " + this.getParameters() + "\n" ); // return out.toString(); } public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) {
throw new RequiresDifferentiableObjective();
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/OptimizerBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // }
import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective;
// return out.toString(); } public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) { throw new RequiresDifferentiableObjective(); } } this.objective = objective; } @Override
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // } // Path: src/main/java/de/jannlab/optimization/OptimizerBase.java import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective; // return out.toString(); } public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) { throw new RequiresDifferentiableObjective(); } } this.objective = objective; } @Override
protected void preIterationCheck() throws IterativeMethodException {
JANNLab/JANNLab
src/main/java/de/jannlab/optimization/OptimizerBase.java
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // }
import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective;
} public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) { throw new RequiresDifferentiableObjective(); } } this.objective = objective; } @Override protected void preIterationCheck() throws IterativeMethodException { super.preIterationCheck();
// Path: src/main/java/de/jannlab/optimization/exception/IterativeMethodException.java // public class IterativeMethodException extends JANNLabException { // private static final long serialVersionUID = -4578796617966258713L; // // // public IterativeMethodException( // final String msg // ) { // super(msg); // } // // public IterativeMethodException( // final String msg, // final Throwable cause // ) { // super(msg, cause); // } // // // public IterativeMethodException() {}; // // // } // // Path: src/main/java/de/jannlab/optimization/exception/NoObjective.java // public class NoObjective extends OptimizerException { // private static final long serialVersionUID = -3687981706725406116L; // // public NoObjective() { // super("no objective given."); // } // // } // // Path: src/main/java/de/jannlab/optimization/exception/RequiresDifferentiableObjective.java // public class RequiresDifferentiableObjective extends IterativeMethodException { // private static final long serialVersionUID = -4578796617966258713L; // // public RequiresDifferentiableObjective() { // super("differentiable objective required."); // } // // } // Path: src/main/java/de/jannlab/optimization/OptimizerBase.java import de.jannlab.optimization.exception.IterativeMethodException; import de.jannlab.optimization.exception.NoObjective; import de.jannlab.optimization.exception.RequiresDifferentiableObjective; } public OptimizerBase() { this.parameters = 0; } @Override public void reset() { super.reset(); } @Override public Objective getObjective() { return this.objective; } @Override public void updateObjective(final Objective objective) { if (this.requiresGradient()) { if (!(objective instanceof DifferentiableObjective)) { throw new RequiresDifferentiableObjective(); } } this.objective = objective; } @Override protected void preIterationCheck() throws IterativeMethodException { super.preIterationCheck();
if (this.objective == null) throw new NoObjective();
uber/rides-java-sdk
uber-rides/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java
// Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/Place.java // public enum Places { // HOME("home"), // WORK("work"); // // private String placeId; // // Places(String placeId) { // this.placeId = placeId; // } // // @Override // public String toString() { // return this.placeId; // } // }
import com.uber.sdk.rides.client.model.Place.Places; import javax.annotation.Nonnull; import javax.annotation.Nullable;
public Builder setPickupNickname(@Nullable String nickname) { this.startNickname = nickname; return this; } /** * Sets the pickup location's address. * * @param address the pickup location's nickname. */ public Builder setPickupAddress(@Nullable String address) { this.startAddress = address; return this; } /** * Sets the pickup location via place identifier. * * @param placeId the pickup location's nickname. */ public Builder setPickupPlaceId(@Nullable String placeId) { this.startPlaceId = placeId; return this; } /** * Sets the pickup location via place identifier. * * @param place the pickup location's nickname. */
// Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/Place.java // public enum Places { // HOME("home"), // WORK("work"); // // private String placeId; // // Places(String placeId) { // this.placeId = placeId; // } // // @Override // public String toString() { // return this.placeId; // } // } // Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/RideRequestParameters.java import com.uber.sdk.rides.client.model.Place.Places; import javax.annotation.Nonnull; import javax.annotation.Nullable; public Builder setPickupNickname(@Nullable String nickname) { this.startNickname = nickname; return this; } /** * Sets the pickup location's address. * * @param address the pickup location's nickname. */ public Builder setPickupAddress(@Nullable String address) { this.startAddress = address; return this; } /** * Sets the pickup location via place identifier. * * @param placeId the pickup location's nickname. */ public Builder setPickupPlaceId(@Nullable String placeId) { this.startPlaceId = placeId; return this; } /** * Sets the pickup location via place identifier. * * @param place the pickup location's nickname. */
public Builder setPickupPlace(@Nullable Places place) {
uber/rides-java-sdk
uber-core/src/main/java/com/uber/sdk/core/auth/internal/OAuth2Service.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/AccessToken.java // public class AccessToken { // private final long expires_in; // @OAuthScopes // private final Set<Scope> scope; // private final String access_token; // private final String refresh_token; // private final String token_type; // // /** // * @param expiresIn the time that the access token expires. // * @param scopes the {@link Scope}s this access token works for. // * @param token the Uber API access token. // * @param refreshToken the Uber API refresh token. // * @param tokenType the Uber API token type. // */ // public AccessToken( // long expiresIn, // Collection<Scope> scopes, // String token, // String refreshToken, // String tokenType) { // expires_in = expiresIn; // this.scope = new HashSet<>(scopes); // access_token = token; // refresh_token = refreshToken; // token_type = tokenType; // } // // /** // * @param expiresIn the time that the access token expires. // * @param scope space delimited list of {@link Scope}s. // * @param token the Uber API access token. // * @param refreshToken the Uber API refresh token. // * @param tokenType the Uber API token type. // */ // public AccessToken( // long expiresIn, // String scope, // String token, // String refreshToken, // String tokenType) { // expires_in = expiresIn; // this.scope = Scope.parseScopes(scope); // access_token = token; // refresh_token = refreshToken; // token_type = tokenType; // } // // /** // * Gets the time the {@link AccessToken} expires at. // * // * @return the expiration time. // */ // public long getExpiresIn() { // return expires_in; // } // // /** // * Gets the {@link Scope}s the access token works for. // * // * @return the scopes. // */ // public Collection<Scope> getScopes() { // return Collections.unmodifiableCollection(scope); // } // // /** // * Gets the raw token used to make API requests // * // * @return the raw token. // */ // public String getToken() { // return access_token; // } // // /** // * Gets the refresh token used to update the {@link AccessToken#access_token}. // * // * @return the raw refresh token. // */ // public String getRefreshToken() { // return refresh_token; // } // // /** // * Gets the type associated with {@link AccessToken#access_token}. // * // * @return the raw token type // */ // public String getTokenType() { // return token_type; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AccessToken that = (AccessToken) o; // // if (expires_in != that.expires_in) return false; // if (scope != null ? !scope.equals(that.scope) : that.scope != null) return false; // if (access_token != null ? !access_token.equals(that.access_token) : that.access_token != null) // return false; // if (refresh_token != null ? !refresh_token.equals(that.refresh_token) : that.refresh_token != null) // return false; // return token_type != null ? token_type.equals(that.token_type) : that.token_type == null; // // } // // @Override // public int hashCode() { // int result = (int) (expires_in ^ (expires_in >>> 32)); // result = 31 * result + (scope != null ? scope.hashCode() : 0); // result = 31 * result + (access_token != null ? access_token.hashCode() : 0); // result = 31 * result + (refresh_token != null ? refresh_token.hashCode() : 0); // result = 31 * result + (token_type != null ? token_type.hashCode() : 0); // return result; // } // }
import com.uber.sdk.core.auth.AccessToken; import retrofit2.Call; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST;
/* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.auth.internal; public interface OAuth2Service { @FormUrlEncoded @POST("token")
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/AccessToken.java // public class AccessToken { // private final long expires_in; // @OAuthScopes // private final Set<Scope> scope; // private final String access_token; // private final String refresh_token; // private final String token_type; // // /** // * @param expiresIn the time that the access token expires. // * @param scopes the {@link Scope}s this access token works for. // * @param token the Uber API access token. // * @param refreshToken the Uber API refresh token. // * @param tokenType the Uber API token type. // */ // public AccessToken( // long expiresIn, // Collection<Scope> scopes, // String token, // String refreshToken, // String tokenType) { // expires_in = expiresIn; // this.scope = new HashSet<>(scopes); // access_token = token; // refresh_token = refreshToken; // token_type = tokenType; // } // // /** // * @param expiresIn the time that the access token expires. // * @param scope space delimited list of {@link Scope}s. // * @param token the Uber API access token. // * @param refreshToken the Uber API refresh token. // * @param tokenType the Uber API token type. // */ // public AccessToken( // long expiresIn, // String scope, // String token, // String refreshToken, // String tokenType) { // expires_in = expiresIn; // this.scope = Scope.parseScopes(scope); // access_token = token; // refresh_token = refreshToken; // token_type = tokenType; // } // // /** // * Gets the time the {@link AccessToken} expires at. // * // * @return the expiration time. // */ // public long getExpiresIn() { // return expires_in; // } // // /** // * Gets the {@link Scope}s the access token works for. // * // * @return the scopes. // */ // public Collection<Scope> getScopes() { // return Collections.unmodifiableCollection(scope); // } // // /** // * Gets the raw token used to make API requests // * // * @return the raw token. // */ // public String getToken() { // return access_token; // } // // /** // * Gets the refresh token used to update the {@link AccessToken#access_token}. // * // * @return the raw refresh token. // */ // public String getRefreshToken() { // return refresh_token; // } // // /** // * Gets the type associated with {@link AccessToken#access_token}. // * // * @return the raw token type // */ // public String getTokenType() { // return token_type; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AccessToken that = (AccessToken) o; // // if (expires_in != that.expires_in) return false; // if (scope != null ? !scope.equals(that.scope) : that.scope != null) return false; // if (access_token != null ? !access_token.equals(that.access_token) : that.access_token != null) // return false; // if (refresh_token != null ? !refresh_token.equals(that.refresh_token) : that.refresh_token != null) // return false; // return token_type != null ? token_type.equals(that.token_type) : that.token_type == null; // // } // // @Override // public int hashCode() { // int result = (int) (expires_in ^ (expires_in >>> 32)); // result = 31 * result + (scope != null ? scope.hashCode() : 0); // result = 31 * result + (access_token != null ? access_token.hashCode() : 0); // result = 31 * result + (refresh_token != null ? refresh_token.hashCode() : 0); // result = 31 * result + (token_type != null ? token_type.hashCode() : 0); // return result; // } // } // Path: uber-core/src/main/java/com/uber/sdk/core/auth/internal/OAuth2Service.java import com.uber.sdk.core.auth.AccessToken; import retrofit2.Call; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; /* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.auth.internal; public interface OAuth2Service { @FormUrlEncoded @POST("token")
Call<AccessToken> refresh(@Field("refresh_token") String refreshToken,
uber/rides-java-sdk
uber-rides/src/main/java/com/uber/sdk/rides/client/model/RideUpdateParameters.java
// Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/Place.java // public enum Places { // HOME("home"), // WORK("work"); // // private String placeId; // // Places(String placeId) { // this.placeId = placeId; // } // // @Override // public String toString() { // return this.placeId; // } // }
import com.uber.sdk.rides.client.model.Place.Places; import javax.annotation.Nullable;
public Builder setDropoffNickname(@Nullable String nickname) { this.endNickname = nickname; return this; } /** * Sets the dropoff location's address. * * @param address the dropoff location's nickname. */ public Builder setDropoffAddress(@Nullable String address) { this.endAddress = address; return this; } /** * Sets the dropoff location via place identifier. * * @param placeId the dropoff location's nickname. */ public Builder setDropoffPlaceId(@Nullable String placeId) { this.endPlaceId = placeId; return this; } /** * Sets the dropoff location via place identifier. * * @param place the dropoff location's nickname. */
// Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/Place.java // public enum Places { // HOME("home"), // WORK("work"); // // private String placeId; // // Places(String placeId) { // this.placeId = placeId; // } // // @Override // public String toString() { // return this.placeId; // } // } // Path: uber-rides/src/main/java/com/uber/sdk/rides/client/model/RideUpdateParameters.java import com.uber.sdk.rides.client.model.Place.Places; import javax.annotation.Nullable; public Builder setDropoffNickname(@Nullable String nickname) { this.endNickname = nickname; return this; } /** * Sets the dropoff location's address. * * @param address the dropoff location's nickname. */ public Builder setDropoffAddress(@Nullable String address) { this.endAddress = address; return this; } /** * Sets the dropoff location via place identifier. * * @param placeId the dropoff location's nickname. */ public Builder setDropoffPlaceId(@Nullable String placeId) { this.endPlaceId = placeId; return this; } /** * Sets the dropoff location via place identifier. * * @param place the dropoff location's nickname. */
public Builder setDropoffPlace(@Nullable Places place) {
uber/rides-java-sdk
uber-core/src/test/java/com/uber/sdk/core/client/SessionTest.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // }
import com.uber.sdk.core.auth.Authenticator; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock;
/* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client; public class SessionTest { @Test public void buildSession_containsMembersFromConstructor() throws Exception {
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // } // Path: uber-core/src/test/java/com/uber/sdk/core/client/SessionTest.java import com.uber.sdk.core.auth.Authenticator; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; /* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client; public class SessionTest { @Test public void buildSession_containsMembersFromConstructor() throws Exception {
Authenticator authenticator = mock(Authenticator.class);
uber/rides-java-sdk
uber-core/src/main/java/com/uber/sdk/core/auth/internal/OAuthScopesAdapter.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // }
import com.squareup.moshi.FromJson; import com.squareup.moshi.ToJson; import com.uber.sdk.core.auth.Scope; import java.util.Set;
/* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.auth.internal; public class OAuthScopesAdapter { @FromJson @OAuthScopes
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // } // Path: uber-core/src/main/java/com/uber/sdk/core/auth/internal/OAuthScopesAdapter.java import com.squareup.moshi.FromJson; import com.squareup.moshi.ToJson; import com.uber.sdk.core.auth.Scope; import java.util.Set; /* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.auth.internal; public class OAuthScopesAdapter { @FromJson @OAuthScopes
Set<Scope> fromJson(String scopes) {
uber/rides-java-sdk
uber-core/src/main/java/com/uber/sdk/core/client/internal/ApiInterceptor.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // }
import com.uber.sdk.BuildConfig; import com.uber.sdk.core.auth.Authenticator; import java.io.IOException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response;
/* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client.internal; public class ApiInterceptor implements Interceptor { static final String HEADER_ACCESS_TOKEN = "Authorization"; static final String LIB_VERSION = BuildConfig.VERSION; static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; static final String HEADER_USER_AGENT = "X-Uber-User-Agent";
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // } // Path: uber-core/src/main/java/com/uber/sdk/core/client/internal/ApiInterceptor.java import com.uber.sdk.BuildConfig; import com.uber.sdk.core.auth.Authenticator; import java.io.IOException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; /* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client.internal; public class ApiInterceptor implements Interceptor { static final String HEADER_ACCESS_TOKEN = "Authorization"; static final String LIB_VERSION = BuildConfig.VERSION; static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; static final String HEADER_USER_AGENT = "X-Uber-User-Agent";
public final Authenticator authenticator;
uber/rides-java-sdk
uber-core/src/test/java/com/uber/sdk/core/client/internal/RefreshAuthenticatorTest.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // }
import com.uber.sdk.core.auth.Authenticator; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify;
package com.uber.sdk.core.client.internal; public class RefreshAuthenticatorTest { @Mock
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Authenticator.java // public interface Authenticator { // // /** // * Indicates whether this authenticator can be refreshed. // * // * @return // */ // boolean isRefreshable(); // // /** // * Add authentication header required to the request. // * // * @param builder // */ // void signRequest(Request.Builder builder); // // /** // * Refresh authentication token that is used to {@link #signRequest(Request.Builder)} // * // * @param response // * @throws IOException // */ // Request refresh(Response response) throws IOException; // // /** // * Get {@link SessionConfiguration} used for providing signining information for requests // */ // SessionConfiguration getSessionConfiguration(); // } // Path: uber-core/src/test/java/com/uber/sdk/core/client/internal/RefreshAuthenticatorTest.java import com.uber.sdk.core.auth.Authenticator; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; package com.uber.sdk.core.client.internal; public class RefreshAuthenticatorTest { @Mock
Authenticator authenticator;
uber/rides-java-sdk
uber-core/src/main/java/com/uber/sdk/core/client/SessionConfiguration.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // } // // Path: uber-core/src/main/java/com/uber/sdk/core/client/utils/Preconditions.java // @Nonnull // public static <T> T checkNotNull(T value, @Nonnull String errorMessage) { // if (value == null) { // throw new NullPointerException(errorMessage); // } // return value; // }
import static com.uber.sdk.core.client.SessionConfiguration.EndpointRegion.DEFAULT; import static com.uber.sdk.core.client.utils.Preconditions.checkNotNull; import com.uber.sdk.core.auth.Scope; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Locale; import javax.annotation.Nonnull;
this.scopes = scopes; return this; } /** * Sets a list of custom scopes that your application must be explicitly whitelisted * for. For any documented scopes, please use {@link #setScopes(Collection)} instead. */ public Builder setCustomScopes(@Nonnull Collection<String> scopes) { this.customScopes = scopes; return this; } /** * Sets the requested Locale through the Accept-Language HTTP header. See * <a href="https://developer.uber.com/docs/localization">Localization</a> * for possible locales. */ public Builder setLocale(@Nonnull Locale locale) { this.locale = locale; return this; } /** * Constructs {@link SessionConfiguration} from set Builder parameters. * * @return {@link SessionConfiguration} * @throws NullPointerException when clientId has not been set */ public SessionConfiguration build() {
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // } // // Path: uber-core/src/main/java/com/uber/sdk/core/client/utils/Preconditions.java // @Nonnull // public static <T> T checkNotNull(T value, @Nonnull String errorMessage) { // if (value == null) { // throw new NullPointerException(errorMessage); // } // return value; // } // Path: uber-core/src/main/java/com/uber/sdk/core/client/SessionConfiguration.java import static com.uber.sdk.core.client.SessionConfiguration.EndpointRegion.DEFAULT; import static com.uber.sdk.core.client.utils.Preconditions.checkNotNull; import com.uber.sdk.core.auth.Scope; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Locale; import javax.annotation.Nonnull; this.scopes = scopes; return this; } /** * Sets a list of custom scopes that your application must be explicitly whitelisted * for. For any documented scopes, please use {@link #setScopes(Collection)} instead. */ public Builder setCustomScopes(@Nonnull Collection<String> scopes) { this.customScopes = scopes; return this; } /** * Sets the requested Locale through the Accept-Language HTTP header. See * <a href="https://developer.uber.com/docs/localization">Localization</a> * for possible locales. */ public Builder setLocale(@Nonnull Locale locale) { this.locale = locale; return this; } /** * Constructs {@link SessionConfiguration} from set Builder parameters. * * @return {@link SessionConfiguration} * @throws NullPointerException when clientId has not been set */ public SessionConfiguration build() {
checkNotNull(clientId, "Client must be set");
uber/rides-java-sdk
uber-core/src/test/java/com/uber/sdk/core/client/SessionConfigurationTest.java
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // }
import static com.uber.sdk.core.client.SessionConfiguration.Environment.PRODUCTION; import static com.uber.sdk.core.client.SessionConfiguration.Environment.SANDBOX; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; import com.uber.sdk.core.auth.Scope; import org.junit.Test; import java.util.Arrays; import java.util.List; import java.util.Locale;
/* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client; public class SessionConfigurationTest { @Test public void getClientId_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .build(); assertEquals("clientId", config.getClientId()); } @Test public void getRedirectUri_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setRedirectUri("redirectUri") .build(); assertEquals("redirectUri", config.getRedirectUri()); } @Test public void getEnvironment_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setEnvironment(SANDBOX) .build(); assertEquals(SANDBOX, config.getEnvironment()); } @Test public void getScopes_whenSetOnBuilder_setsOnConfiguration() throws Exception {
// Path: uber-core/src/main/java/com/uber/sdk/core/auth/Scope.java // public enum Scope { // // /** // * Pull trip data of a user's historical pickups and drop-offs. // */ // HISTORY(GENERAL, 1), // // /** // * Same as History without city information. // */ // HISTORY_LITE(GENERAL, 2), // // /** // * Retrieve user's available registered payment methods. // */ // PAYMENT_METHODS(GENERAL, 4), // // /** // * Save and retrieve user's favorite places. // */ // PLACES(GENERAL, 8), // // /** // * Access basic profile information on a user's Uber account. // */ // PROFILE(GENERAL, 16), // // /** // * Access the Ride Request Widget. // */ // RIDE_WIDGETS(GENERAL, 32), // // /** // * Request ride on the behalf of an Uber account. // */ // REQUEST(PRIVILEGED, 64), // // /** // * Request ride for a ride on the behalf of an Uber account. // */ // REQUEST_RECEIPT(PRIVILEGED, 128), // // /** // * Request list of all trips belong to a user. // */ // ALL_TRIPS(PRIVILEGED, 256); // // // private ScopeType mScopeType; // // /** // * Use powers of two to allow bit masking operation. // */ // private int mBitValue; // // Scope(ScopeType scopeType, int bitValue) { // this.mScopeType = scopeType; // this.mBitValue = bitValue; // } // // /** // * Gets the {@link ScopeType} associated with this {@link Scope}. // * // * @return the type of scope. // */ // public ScopeType getScopeType() { // return mScopeType; // } // // /** // * Gets the bit value that represents this. // * // * @return the int value that represents this’. // */ // public int getBitValue() { // return mBitValue; // } // // /** // * Category of {@link Scope} that describes its level of access. // */ // public enum ScopeType { // // /** // * {@link Scope}s that can be used without review. // */ // GENERAL, // // /** // * {@link Scope}s that require approval before opened to your users in production. // */ // PRIVILEGED // } // // public static Set<Scope> parseScopes(String concatenatedScopes) { // Set<Scope> scopes = new LinkedHashSet<>(); // for (String scopeString : concatenatedScopes.split(" ")) { // try { // Scope scope = Scope.valueOf(scopeString.toUpperCase()); // scopes.add(scope); // } catch (IllegalArgumentException ex) { // } // } // return scopes; // } // // public static Set<Scope> parseScopes(int bitValues) { // Set<Scope> scopes = new LinkedHashSet<>(); // if (bitValues <= 0) { // return scopes; // } // // for (Scope scope : Scope.values()) { // if ((bitValues & scope.mBitValue) == scope.mBitValue) { // scopes.add(scope); // } // } // // return scopes; // } // // public static String toStandardString(@Nonnull Collection<Scope> scopes) { // StringBuilder stringBuilder = new StringBuilder(); // int i = 0; // for (Scope scope : scopes) { // stringBuilder.append(scope.toString().toLowerCase()); // if (i < scopes.size() - 1) { // stringBuilder.append(' '); // } // i++; // } // return stringBuilder.toString(); // } // } // Path: uber-core/src/test/java/com/uber/sdk/core/client/SessionConfigurationTest.java import static com.uber.sdk.core.client.SessionConfiguration.Environment.PRODUCTION; import static com.uber.sdk.core.client.SessionConfiguration.Environment.SANDBOX; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; import com.uber.sdk.core.auth.Scope; import org.junit.Test; import java.util.Arrays; import java.util.List; import java.util.Locale; /* * Copyright (c) 2016 Uber Technologies, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.uber.sdk.core.client; public class SessionConfigurationTest { @Test public void getClientId_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .build(); assertEquals("clientId", config.getClientId()); } @Test public void getRedirectUri_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setRedirectUri("redirectUri") .build(); assertEquals("redirectUri", config.getRedirectUri()); } @Test public void getEnvironment_whenSetOnBuilder_setsOnConfiguration() throws Exception { SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setEnvironment(SANDBOX) .build(); assertEquals(SANDBOX, config.getEnvironment()); } @Test public void getScopes_whenSetOnBuilder_setsOnConfiguration() throws Exception {
List<Scope> scopes = Arrays.asList(Scope.ALL_TRIPS, Scope.HISTORY);
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ProcessModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // };
import java.util.HashMap; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class ProcessModel extends DevOrProcModel{ // variable name -> type private HashMap<String, String> globals; // method name -> method model private HashMap<String, MethodModel> methods; public ProcessModel() { super(); methods = new HashMap<>(); globals = new HashMap<>(); } public HashMap<String, String> getGlobals() { return globals; } /** * This will return the type of a global variable * @param name The name of the global variable * @return The type of the global variable */ public String getGlobalType(String name){ return globals.get(name); } public void setDisplay(boolean display) { if(display){
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ProcessModel.java import java.util.HashMap; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class ProcessModel extends DevOrProcModel{ // variable name -> type private HashMap<String, String> globals; // method name -> method model private HashMap<String, MethodModel> methods; public ProcessModel() { super(); methods = new HashMap<>(); globals = new HashMap<>(); } public HashMap<String, String> getGlobals() { return globals; } /** * This will return the type of a global variable * @param name The name of the global variable * @return The type of the global variable */ public String getGlobalType(String name){ return globals.get(name); } public void setDisplay(boolean display) { if(display){
this.processType = ProcessType.DISPLAY;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ProcessModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // };
import java.util.HashMap; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType;
* @return The type of the global variable */ public String getGlobalType(String name){ return globals.get(name); } public void setDisplay(boolean display) { if(display){ this.processType = ProcessType.DISPLAY; } else { this.processType = ProcessType.LOGIC; } } public TaskModel getLastThread(){ return (TaskModel) children.get(children.size() - 1); } public void addGlobal(String name, String type) { globals.put(name, type); } public HashMap<String, MethodModel> getMethods() { return methods; } public void addMethod(String methodName, MethodModel method) { methods.put(methodName, method); }
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ProcessModel.java import java.util.HashMap; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType; * @return The type of the global variable */ public String getGlobalType(String name){ return globals.get(name); } public void setDisplay(boolean display) { if(display){ this.processType = ProcessType.DISPLAY; } else { this.processType = ProcessType.LOGIC; } } public TaskModel getLastThread(){ return (TaskModel) children.get(children.size() - 1); } public void addGlobal(String name, String type) { globals.put(name, type); } public HashMap<String, MethodModel> getMethods() { return methods; } public void addMethod(String methodName, MethodModel method) { methods.put(methodName, method); }
public void addParameterToMethod(String methodName, String parameterName, String parameterType) throws DuplicateElementException{
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/preference/PreferenceInitializer.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/AadlTranslatorPlugin.java // public class AadlTranslatorPlugin extends AbstractUIPlugin { // //The shared instance. // private static AadlTranslatorPlugin plugin; // //Resource bundle. // private ResourceBundle resourceBundle; // // /** // * The constructor. // */ // public AadlTranslatorPlugin() { // super(); // plugin = this; // try { // resourceBundle = ResourceBundle.getBundle("edu.ksu.cis.projects.mdcf.aadltranslator.PluginResources"); // } catch (MissingResourceException x) { // resourceBundle = null; // } // } // // /** // * This method is called upon plug-in activation // */ // public void start(BundleContext context) throws Exception { // super.start(context); // } // // /** // * This method is called when the plug-in is stopped // */ // public void stop(BundleContext context) throws Exception { // super.stop(context); // } // // /** // * Returns the shared instance. // */ // public static AadlTranslatorPlugin getDefault() { // return plugin; // } // // /** // * Returns the string from the plugin's resource bundle, or 'key' if not // * found. // */ // public static String getResourceString(String key) { // ResourceBundle bundle = AadlTranslatorPlugin.getDefault().getResourceBundle(); // try { // return (bundle != null) ? bundle.getString(key) : key; // } catch (MissingResourceException e) { // return key; // } // } // // /** // * Returns the plugin's resource bundle, // */ // public ResourceBundle getResourceBundle() { // return resourceBundle; // } // }
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import edu.ksu.cis.projects.mdcf.aadltranslator.AadlTranslatorPlugin;
package edu.ksu.cis.projects.mdcf.aadltranslator.preference; /** * Class used to initialize default preference values. */ public class PreferenceInitializer extends AbstractPreferenceInitializer { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() {
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/AadlTranslatorPlugin.java // public class AadlTranslatorPlugin extends AbstractUIPlugin { // //The shared instance. // private static AadlTranslatorPlugin plugin; // //Resource bundle. // private ResourceBundle resourceBundle; // // /** // * The constructor. // */ // public AadlTranslatorPlugin() { // super(); // plugin = this; // try { // resourceBundle = ResourceBundle.getBundle("edu.ksu.cis.projects.mdcf.aadltranslator.PluginResources"); // } catch (MissingResourceException x) { // resourceBundle = null; // } // } // // /** // * This method is called upon plug-in activation // */ // public void start(BundleContext context) throws Exception { // super.start(context); // } // // /** // * This method is called when the plug-in is stopped // */ // public void stop(BundleContext context) throws Exception { // super.stop(context); // } // // /** // * Returns the shared instance. // */ // public static AadlTranslatorPlugin getDefault() { // return plugin; // } // // /** // * Returns the string from the plugin's resource bundle, or 'key' if not // * found. // */ // public static String getResourceString(String key) { // ResourceBundle bundle = AadlTranslatorPlugin.getDefault().getResourceBundle(); // try { // return (bundle != null) ? bundle.getString(key) : key; // } catch (MissingResourceException e) { // return key; // } // } // // /** // * Returns the plugin's resource bundle, // */ // public ResourceBundle getResourceBundle() { // return resourceBundle; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/preference/PreferenceInitializer.java import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import edu.ksu.cis.projects.mdcf.aadltranslator.AadlTranslatorPlugin; package edu.ksu.cis.projects.mdcf.aadltranslator.preference; /** * Class used to initialize default preference values. */ public class PreferenceInitializer extends AbstractPreferenceInitializer { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() {
IPreferenceStore store = AadlTranslatorPlugin.getDefault().getPreferenceStore();
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/MethodModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // }
import java.util.HashMap; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class MethodModel extends ComponentModel{ /** * This stores a mapping from param name -> param type */ private HashMap<String, String> parameters; private String name; private String retType; // /** // * This is the name of the parameter at the task level, so the code // * generator knows what value to set. // */ // private String retName; public MethodModel(String methodName) { super(); this.name = methodName; parameters = new HashMap<>(); } public String getRetType() { return retType; } public void setRetType(String retType) { this.retType = retType; } // public String getRetName() { // return retName; // } // // public void setRetName(String retName) { // this.retName = retName; // } public HashMap<String, String> getParameters() { return parameters; } public void addParameter(String paramName, String type)
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/MethodModel.java import java.util.HashMap; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class MethodModel extends ComponentModel{ /** * This stores a mapping from param name -> param type */ private HashMap<String, String> parameters; private String name; private String retType; // /** // * This is the name of the parameter at the task level, so the code // * generator knows what value to set. // */ // private String retName; public MethodModel(String methodName) { super(); this.name = methodName; parameters = new HashMap<>(); } public String getRetType() { return retType; } public void setRetType(String retType) { this.retType = retType; } // public String getRetName() { // return retName; // } // // public void setRetName(String retName) { // this.retName = retName; // } public HashMap<String, String> getParameters() { return parameters; } public void addParameter(String paramName, String type)
throws DuplicateElementException {
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ManifestationType { // CONTENT, HIGH, LOW, TIMING, EARLY, LATE, HALTED, ERRATIC, VIOLATEDCONSTRAINT // };
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ManifestationType;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * This class models a single manifestation. * * @author Sam * */ public class ManifestationTypeModel { private String name;
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ManifestationType { // CONTENT, HIGH, LOW, TIMING, EARLY, LATE, HALTED, ERRATIC, VIOLATEDCONSTRAINT // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java import org.osate.xtext.aadl2.errormodel.errorModel.ErrorType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ManifestationType; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * This class models a single manifestation. * * @author Sam * */ public class ManifestationTypeModel { private String name;
private ManifestationType manifestation;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ExternallyCausedDangerModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/CoreException.java // public class CoreException extends Exception { // // private static final long serialVersionUID = 3625614495551540231L; // // public CoreException(String ex) { // super(ex); // } // }
import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.CoreException;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * An externally caused danger represents the path of a set of errors through a * component; it's essentially an incoming danger (manifestation), outgoing * danger (succDanger), and some metadata. * * @author sam * */ public class ExternallyCausedDangerModel extends CausedDangerModel { private PropagationModel danger; private ProcessVariableModel processVariableModel; private String processVariableModelConstraint; public ExternallyCausedDangerModel(PropagationModel inProp, PropagationModel outProp, String interp,
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/CoreException.java // public class CoreException extends Exception { // // private static final long serialVersionUID = 3625614495551540231L; // // public CoreException(String ex) { // super(ex); // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ExternallyCausedDangerModel.java import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.CoreException; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * An externally caused danger represents the path of a set of errors through a * component; it's essentially an incoming danger (manifestation), outgoing * danger (succDanger), and some metadata. * * @author sam * */ public class ExternallyCausedDangerModel extends CausedDangerModel { private PropagationModel danger; private ProcessVariableModel processVariableModel; private String processVariableModelConstraint; public ExternallyCausedDangerModel(PropagationModel inProp, PropagationModel outProp, String interp,
ProcessVariableModel processVariableModel, String constraint) throws CoreException {
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/RuntimeHandlingModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeErrorHandlingApproach implements HandlingApproach{ // NOTSPECIFIED, ROLLBACK, ROLLFORWARD, COMPENSATION, // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeFaultHandlingApproach implements HandlingApproach{ // NOTSPECIFIED, DIAGNOSIS, ISOLATION, RECONFIGURATION, REINITIALIZATION, // };
import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeErrorHandlingApproach; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeFaultHandlingApproach;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class RuntimeHandlingModel { private RuntimeErrorHandlingApproach errorHandlingApproach;
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeErrorHandlingApproach implements HandlingApproach{ // NOTSPECIFIED, ROLLBACK, ROLLFORWARD, COMPENSATION, // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeFaultHandlingApproach implements HandlingApproach{ // NOTSPECIFIED, DIAGNOSIS, ISOLATION, RECONFIGURATION, REINITIALIZATION, // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/RuntimeHandlingModel.java import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeErrorHandlingApproach; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeFaultHandlingApproach; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class RuntimeHandlingModel { private RuntimeErrorHandlingApproach errorHandlingApproach;
private RuntimeFaultHandlingApproach faultHandlingApproach;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/DesignTimeDetectionModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum DesignTimeFaultDetectionApproach implements DetectionApproach{ // NOTSPECIFIED, STATICANALYSIS, THEOREMPROVING, MODELCHECKING, SYMBOLICEXECUTION, TESTING, // };
import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.DesignTimeFaultDetectionApproach;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class DesignTimeDetectionModel extends DetectionModel { public DesignTimeDetectionModel(String explanation, String name, String approachStr) { super(explanation, name);
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum DesignTimeFaultDetectionApproach implements DetectionApproach{ // NOTSPECIFIED, STATICANALYSIS, THEOREMPROVING, MODELCHECKING, SYMBOLICEXECUTION, TESTING, // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/DesignTimeDetectionModel.java import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.DesignTimeFaultDetectionApproach; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class DesignTimeDetectionModel extends DetectionModel { public DesignTimeDetectionModel(String explanation, String name, String approachStr) { super(explanation, name);
this.approach = DesignTimeFaultDetectionApproach.valueOf(approachStr.toUpperCase());
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/TaskModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/NotImplementedException.java // public class NotImplementedException extends Exception { // private static final long serialVersionUID = 7862752843582919995L; // // public NotImplementedException(String ex){ // super(ex); // } // }
import java.util.ArrayList; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.NotImplementedException;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class TaskModel extends ComponentModel<MethodModel, ConnectionModel>{ private PortModel trigPort = null; /** * The name that the task uses to refer to the value that arrives via the * triggering port */ private String trigPortLocalName; /** * This is a list of globals read by this task. */ private ArrayList<VariableModel> incomingGlobals; /** * This is a list of globals written by this task. */ private ArrayList<VariableModel> outgoingGlobals; /** * This task's period in milliseconds */ private int period; /** * This task's deadline in milliseconds */ private int deadline; /** * The type of this task's trigger -- periodic, sporadic, etc. */ private boolean sporadic; /** * This task's worst case execution time */ private int wcet; public TaskModel(String name) { super(); incomingGlobals = new ArrayList<>(); outgoingGlobals = new ArrayList<>(); this.name = name; }
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/NotImplementedException.java // public class NotImplementedException extends Exception { // private static final long serialVersionUID = 7862752843582919995L; // // public NotImplementedException(String ex){ // super(ex); // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/TaskModel.java import java.util.ArrayList; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.NotImplementedException; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class TaskModel extends ComponentModel<MethodModel, ConnectionModel>{ private PortModel trigPort = null; /** * The name that the task uses to refer to the value that arrives via the * triggering port */ private String trigPortLocalName; /** * This is a list of globals read by this task. */ private ArrayList<VariableModel> incomingGlobals; /** * This is a list of globals written by this task. */ private ArrayList<VariableModel> outgoingGlobals; /** * This task's period in milliseconds */ private int period; /** * This task's deadline in milliseconds */ private int deadline; /** * The type of this task's trigger -- periodic, sporadic, etc. */ private boolean sporadic; /** * This task's worst case execution time */ private int wcet; public TaskModel(String name) { super(); incomingGlobals = new ArrayList<>(); outgoingGlobals = new ArrayList<>(); this.name = name; }
public void setTrigPort(PortModel port) throws NotImplementedException{
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/RuntimeDetectionModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeErrorDetectionApproach implements DetectionApproach{ // NOTSPECIFIED, CONCURRENT, PREEMPTIVE, // };
import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeErrorDetectionApproach;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class RuntimeDetectionModel extends DetectionModel { public RuntimeDetectionModel(String explanation, String name, String approachStr) { super(explanation, name);
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum RuntimeErrorDetectionApproach implements DetectionApproach{ // NOTSPECIFIED, CONCURRENT, PREEMPTIVE, // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/RuntimeDetectionModel.java import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.RuntimeErrorDetectionApproach; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class RuntimeDetectionModel extends DetectionModel { public RuntimeDetectionModel(String explanation, String name, String approachStr) { super(explanation, name);
this.approach = RuntimeErrorDetectionApproach.valueOf(approachStr.toUpperCase());
santoslab/aadl-translator
edu.ksu.cis.projects.mdcf.aadl-translator-test/src/test/java/edu/ksu/cis/projects/mdcf/aadltranslator/view/STRendererTests.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/util/MarkdownLinkRenderer.java // public class MarkdownLinkRenderer implements AttributeRenderer { // // // Disallow instantiation // private MarkdownLinkRenderer() { // } // // private static class MarkdownLinkRendererHolder { // private static final MarkdownLinkRenderer INSTANCE = new MarkdownLinkRenderer(); // } // // public static MarkdownLinkRenderer getInstance() { // return MarkdownLinkRendererHolder.INSTANCE; // } // // @Override // public String toString(Object o, String formatString, Locale locale) { // // o will be a String // String ret = (String) o; // // if(formatString == null) { // return ret; // } // // ret = ret.toLowerCase(); // ret = ret.replace(' ', '-'); // ret = ret.replace(":", ""); // // if (formatString.equals("MarkdownInterLink")) { // ret += ".html"; // } else if (formatString.equals("MarkdownIntraLink")) { // ret = "#" + ret; // } // // return ret; // } // }
import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; import org.junit.Test; import org.stringtemplate.v4.STGroup; import edu.ksu.cis.projects.mdcf.aadltranslator.util.MarkdownLinkRenderer;
package edu.ksu.cis.projects.mdcf.aadltranslator.view; public class STRendererTests { private static STGroup stg; @BeforeClass public static void initialize() { stg = new STGroup(); stg.defineTemplate("interlink", "linkText", "<linkText; format=\"MarkdownInterLink\">"); stg.defineTemplate("intralink", "linkText", "<linkText; format=\"MarkdownIntraLink\">");
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/util/MarkdownLinkRenderer.java // public class MarkdownLinkRenderer implements AttributeRenderer { // // // Disallow instantiation // private MarkdownLinkRenderer() { // } // // private static class MarkdownLinkRendererHolder { // private static final MarkdownLinkRenderer INSTANCE = new MarkdownLinkRenderer(); // } // // public static MarkdownLinkRenderer getInstance() { // return MarkdownLinkRendererHolder.INSTANCE; // } // // @Override // public String toString(Object o, String formatString, Locale locale) { // // o will be a String // String ret = (String) o; // // if(formatString == null) { // return ret; // } // // ret = ret.toLowerCase(); // ret = ret.replace(' ', '-'); // ret = ret.replace(":", ""); // // if (formatString.equals("MarkdownInterLink")) { // ret += ".html"; // } else if (formatString.equals("MarkdownIntraLink")) { // ret = "#" + ret; // } // // return ret; // } // } // Path: edu.ksu.cis.projects.mdcf.aadl-translator-test/src/test/java/edu/ksu/cis/projects/mdcf/aadltranslator/view/STRendererTests.java import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; import org.junit.Test; import org.stringtemplate.v4.STGroup; import edu.ksu.cis.projects.mdcf.aadltranslator.util.MarkdownLinkRenderer; package edu.ksu.cis.projects.mdcf.aadltranslator.view; public class STRendererTests { private static STGroup stg; @BeforeClass public static void initialize() { stg = new STGroup(); stg.defineTemplate("interlink", "linkText", "<linkText; format=\"MarkdownInterLink\">"); stg.defineTemplate("intralink", "linkText", "<linkText; format=\"MarkdownIntraLink\">");
stg.registerRenderer(String.class, MarkdownLinkRenderer.getInstance());
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/DeviceModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // };
import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class DeviceModel extends DevOrProcModel { private HashBiMap<String, String> inToOutPortNames = HashBiMap.create(); public DeviceModel(){ super();
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/DeviceModel.java import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class DeviceModel extends DevOrProcModel { private HashBiMap<String, String> inToOutPortNames = HashBiMap.create(); public DeviceModel(){ super();
processType = ProcessType.PSEUDODEVICE;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/DeviceModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // };
import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class DeviceModel extends DevOrProcModel { private HashBiMap<String, String> inToOutPortNames = HashBiMap.create(); public DeviceModel(){ super(); processType = ProcessType.PSEUDODEVICE; } public void setComponentType(String componentType){
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ComponentType { // SENSOR, ACTUATOR, CONTROLLER, CONTROLLEDPROCESS, AGGREGATION, TOP // }; // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/ModelUtil.java // public static enum ProcessType { // PSEUDODEVICE, DISPLAY, LOGIC // }; // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/DeviceModel.java import java.util.Map; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ComponentType; import edu.ksu.cis.projects.mdcf.aadltranslator.model.ModelUtil.ProcessType; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class DeviceModel extends DevOrProcModel { private HashBiMap<String, String> inToOutPortNames = HashBiMap.create(); public DeviceModel(){ super(); processType = ProcessType.PSEUDODEVICE; } public void setComponentType(String componentType){
this.componentType = ComponentType.valueOf(componentType.toUpperCase());
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/AccidentLevelModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java // public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // // // Type name -> Child name Model // private HashMap<String, DevOrProcModel> typeToComponent; // // private String timestamp; // // private List<String> haExplanations = new LinkedList<>(); // // // Fault name -> Fault model // // private HashMap<String, ErrorTypeModel> faultClasses; // // /** // * Error type name -> model // */ // private Map<String, ManifestationTypeModel> errorTypeModels; // // public SystemModel() { // super(); // typeToComponent = new HashMap<>(); // } // // public ProcessModel getProcessByType(String processTypeName) { // if (typeToComponent.get(processTypeName) instanceof ProcessModel) // return (ProcessModel) typeToComponent.get(processTypeName); // else // return null; // } // // public DeviceModel getDeviceByType(String deviceTypeName) { // if (typeToComponent.get(deviceTypeName) instanceof DeviceModel) // return (DeviceModel) typeToComponent.get(deviceTypeName); // else // return null; // } // // @Override // public void addChild(String childName, DevOrProcModel childModel) throws DuplicateElementException { // super.addChild(childName, childModel); // if(typeToComponent.containsKey(childName)) // throw new DuplicateElementException(childName + " already exists"); // typeToComponent.put(childModel.getName(), childModel); // } // // public String getTimestamp() { // return timestamp; // } // // public void setTimestamp(String timestamp) { // this.timestamp = timestamp; // } // // public HashMap<String, ProcessModel> getLogicComponents() { // Map<String, DevOrProcModel> preCast = children.entrySet() // .stream() // .filter(p -> p.getValue() instanceof ProcessModel) // .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue())); // // HashMap<String, ProcessModel> ret = new HashMap<>(); // for(String elemName : preCast.keySet()){ // ret.put(elemName, (ProcessModel) preCast.get(elemName)); // } // return ret; // } // // public HashMap<String, DevOrProcModel> getLogicAndDevices() { // return children; // } // // public boolean hasProcessType(String typeName) { // return (typeToComponent.containsKey(typeName) && (typeToComponent // .get(typeName) instanceof ProcessModel)); // } // // public boolean hasDeviceType(String typeName) { // return (typeToComponent.containsKey(typeName) && (typeToComponent // .get(typeName) instanceof DeviceModel)); // } // // public HashMap<String, ConnectionModel> getUniqueDevicePublishedChannels(){ // Set<SystemConnectionModel> chanSet = channels.values() // .stream() // .filter(cs -> cs.publisher instanceof DeviceModel) // .collect(Collectors.toSet()); // // // Get a set that's distinct based on publishing identity // // (publisher component name + publisher port name) // HashMap<String, ConnectionModel> chanMap = new HashMap<String, ConnectionModel>(); // for(ConnectionModel cm : chanSet) { // chanMap.put(cm.getPubName().concat(cm.getPubPortName()), cm); // } // return chanMap; // } // // public HashMap<String, ConnectionModel> getUniqueDeviceSubscribedChannels(){ // Set<SystemConnectionModel> chanSet = channels.values() // .stream() // .filter(cs -> cs.subscriber instanceof DeviceModel) // .collect(Collectors.toSet()); // // // Get a set that's distinct based on subscriber identity // // (subscriber component name + subscriber port name) // HashMap<String, ConnectionModel> chanMap = new HashMap<String, ConnectionModel>(); // for(ConnectionModel cm : chanSet) { // chanMap.put(cm.getSubName().concat(cm.getSubPortName()), cm); // } // return chanMap; // } // // public void setErrorTypes(Map<String, ManifestationTypeModel> errorTypeModels) { // this.errorTypeModels = errorTypeModels; // } // // public Set<String> getAllErrorTypes(){ // return errorTypeModels.values() // .stream() // .map(v -> v.getManifestationName()) // .collect(Collectors.toCollection(LinkedHashSet::new)); // } // // public ManifestationTypeModel getErrorTypeModelByName(String name){ // if(errorTypeModels == null){ // // This will happen if there is no error type information at all // // We don't want to require that, so we just return null // return null; // } // return errorTypeModels.get(name); // } // // public void addExplanation(String exp){ // haExplanations.add(exp); // } // // public List<String> getExplanations(){ // return haExplanations; // } // }
import edu.ksu.cis.projects.mdcf.aadltranslator.model.SystemModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class AccidentLevelModel extends StpaPreliminaryModel { protected int number;
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java // public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // // // Type name -> Child name Model // private HashMap<String, DevOrProcModel> typeToComponent; // // private String timestamp; // // private List<String> haExplanations = new LinkedList<>(); // // // Fault name -> Fault model // // private HashMap<String, ErrorTypeModel> faultClasses; // // /** // * Error type name -> model // */ // private Map<String, ManifestationTypeModel> errorTypeModels; // // public SystemModel() { // super(); // typeToComponent = new HashMap<>(); // } // // public ProcessModel getProcessByType(String processTypeName) { // if (typeToComponent.get(processTypeName) instanceof ProcessModel) // return (ProcessModel) typeToComponent.get(processTypeName); // else // return null; // } // // public DeviceModel getDeviceByType(String deviceTypeName) { // if (typeToComponent.get(deviceTypeName) instanceof DeviceModel) // return (DeviceModel) typeToComponent.get(deviceTypeName); // else // return null; // } // // @Override // public void addChild(String childName, DevOrProcModel childModel) throws DuplicateElementException { // super.addChild(childName, childModel); // if(typeToComponent.containsKey(childName)) // throw new DuplicateElementException(childName + " already exists"); // typeToComponent.put(childModel.getName(), childModel); // } // // public String getTimestamp() { // return timestamp; // } // // public void setTimestamp(String timestamp) { // this.timestamp = timestamp; // } // // public HashMap<String, ProcessModel> getLogicComponents() { // Map<String, DevOrProcModel> preCast = children.entrySet() // .stream() // .filter(p -> p.getValue() instanceof ProcessModel) // .collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue())); // // HashMap<String, ProcessModel> ret = new HashMap<>(); // for(String elemName : preCast.keySet()){ // ret.put(elemName, (ProcessModel) preCast.get(elemName)); // } // return ret; // } // // public HashMap<String, DevOrProcModel> getLogicAndDevices() { // return children; // } // // public boolean hasProcessType(String typeName) { // return (typeToComponent.containsKey(typeName) && (typeToComponent // .get(typeName) instanceof ProcessModel)); // } // // public boolean hasDeviceType(String typeName) { // return (typeToComponent.containsKey(typeName) && (typeToComponent // .get(typeName) instanceof DeviceModel)); // } // // public HashMap<String, ConnectionModel> getUniqueDevicePublishedChannels(){ // Set<SystemConnectionModel> chanSet = channels.values() // .stream() // .filter(cs -> cs.publisher instanceof DeviceModel) // .collect(Collectors.toSet()); // // // Get a set that's distinct based on publishing identity // // (publisher component name + publisher port name) // HashMap<String, ConnectionModel> chanMap = new HashMap<String, ConnectionModel>(); // for(ConnectionModel cm : chanSet) { // chanMap.put(cm.getPubName().concat(cm.getPubPortName()), cm); // } // return chanMap; // } // // public HashMap<String, ConnectionModel> getUniqueDeviceSubscribedChannels(){ // Set<SystemConnectionModel> chanSet = channels.values() // .stream() // .filter(cs -> cs.subscriber instanceof DeviceModel) // .collect(Collectors.toSet()); // // // Get a set that's distinct based on subscriber identity // // (subscriber component name + subscriber port name) // HashMap<String, ConnectionModel> chanMap = new HashMap<String, ConnectionModel>(); // for(ConnectionModel cm : chanSet) { // chanMap.put(cm.getSubName().concat(cm.getSubPortName()), cm); // } // return chanMap; // } // // public void setErrorTypes(Map<String, ManifestationTypeModel> errorTypeModels) { // this.errorTypeModels = errorTypeModels; // } // // public Set<String> getAllErrorTypes(){ // return errorTypeModels.values() // .stream() // .map(v -> v.getManifestationName()) // .collect(Collectors.toCollection(LinkedHashSet::new)); // } // // public ManifestationTypeModel getErrorTypeModelByName(String name){ // if(errorTypeModels == null){ // // This will happen if there is no error type information at all // // We don't want to require that, so we just return null // return null; // } // return errorTypeModels.get(name); // } // // public void addExplanation(String exp){ // haExplanations.add(exp); // } // // public List<String> getExplanations(){ // return haExplanations; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/AccidentLevelModel.java import edu.ksu.cis.projects.mdcf.aadltranslator.model.SystemModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; public class AccidentLevelModel extends StpaPreliminaryModel { protected int number;
private SystemModel system;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // }
import java.util.HashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // Type name -> Child name Model private HashMap<String, DevOrProcModel> typeToComponent; private String timestamp; private List<String> haExplanations = new LinkedList<>(); // Fault name -> Fault model // private HashMap<String, ErrorTypeModel> faultClasses; /** * Error type name -> model */
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java import java.util.HashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // Type name -> Child name Model private HashMap<String, DevOrProcModel> typeToComponent; private String timestamp; private List<String> haExplanations = new LinkedList<>(); // Fault name -> Fault model // private HashMap<String, ErrorTypeModel> faultClasses; /** * Error type name -> model */
private Map<String, ManifestationTypeModel> errorTypeModels;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // }
import java.util.HashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // Type name -> Child name Model private HashMap<String, DevOrProcModel> typeToComponent; private String timestamp; private List<String> haExplanations = new LinkedList<>(); // Fault name -> Fault model // private HashMap<String, ErrorTypeModel> faultClasses; /** * Error type name -> model */ private Map<String, ManifestationTypeModel> errorTypeModels; public SystemModel() { super(); typeToComponent = new HashMap<>(); } public ProcessModel getProcessByType(String processTypeName) { if (typeToComponent.get(processTypeName) instanceof ProcessModel) return (ProcessModel) typeToComponent.get(processTypeName); else return null; } public DeviceModel getDeviceByType(String deviceTypeName) { if (typeToComponent.get(deviceTypeName) instanceof DeviceModel) return (DeviceModel) typeToComponent.get(deviceTypeName); else return null; } @Override
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/exception/DuplicateElementException.java // public class DuplicateElementException extends Exception { // // private static final long serialVersionUID = 329902136160036432L; // // public DuplicateElementException(String ex) { // super(ex); // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/SystemModel.java import java.util.HashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import edu.ksu.cis.projects.mdcf.aadltranslator.exception.DuplicateElementException; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class SystemModel extends ComponentModel<DevOrProcModel, SystemConnectionModel>{ // Type name -> Child name Model private HashMap<String, DevOrProcModel> typeToComponent; private String timestamp; private List<String> haExplanations = new LinkedList<>(); // Fault name -> Fault model // private HashMap<String, ErrorTypeModel> faultClasses; /** * Error type name -> model */ private Map<String, ManifestationTypeModel> errorTypeModels; public SystemModel() { super(); typeToComponent = new HashMap<>(); } public ProcessModel getProcessByType(String processTypeName) { if (typeToComponent.get(processTypeName) instanceof ProcessModel) return (ProcessModel) typeToComponent.get(processTypeName); else return null; } public DeviceModel getDeviceByType(String deviceTypeName) { if (typeToComponent.get(deviceTypeName) instanceof DeviceModel) return (DeviceModel) typeToComponent.get(deviceTypeName); else return null; } @Override
public void addChild(String childName, DevOrProcModel childModel) throws DuplicateElementException {
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java // public class PropagationModel{ // private String name; // private Map<String, ManifestationTypeModel> errors; // private FeatureModel port; // // public PropagationModel(String name, Collection<ManifestationTypeModel> errors, FeatureModel portModel) { // this.name = name; // setError(errors); // this.port = portModel; // } // // public Set<ManifestationTypeModel> getErrors() { // return new LinkedHashSet<>(errors.values()); // } // // public void setError(Collection<ManifestationTypeModel> errors) { // this.errors = new LinkedHashMap<>(); // for(ManifestationTypeModel error : errors){ // this.errors.put(error.getName(), error); // } // } // // public ManifestationTypeModel getErrorByName(String name){ // return errors.get(name); // } // // public FeatureModel getPort() { // return port; // } // // public String getName() { // return name; // } // }
import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.PropagationModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class FeatureModel { private String name; protected boolean subscribe; /** * Error types entering or leaving this port */
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java // public class PropagationModel{ // private String name; // private Map<String, ManifestationTypeModel> errors; // private FeatureModel port; // // public PropagationModel(String name, Collection<ManifestationTypeModel> errors, FeatureModel portModel) { // this.name = name; // setError(errors); // this.port = portModel; // } // // public Set<ManifestationTypeModel> getErrors() { // return new LinkedHashSet<>(errors.values()); // } // // public void setError(Collection<ManifestationTypeModel> errors) { // this.errors = new LinkedHashMap<>(); // for(ManifestationTypeModel error : errors){ // this.errors.put(error.getName(), error); // } // } // // public ManifestationTypeModel getErrorByName(String name){ // return errors.get(name); // } // // public FeatureModel getPort() { // return port; // } // // public String getName() { // return name; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.PropagationModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class FeatureModel { private String name; protected boolean subscribe; /** * Error types entering or leaving this port */
private Map<String, ManifestationTypeModel> propagatableErrors = new LinkedHashMap<>();
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java // public class PropagationModel{ // private String name; // private Map<String, ManifestationTypeModel> errors; // private FeatureModel port; // // public PropagationModel(String name, Collection<ManifestationTypeModel> errors, FeatureModel portModel) { // this.name = name; // setError(errors); // this.port = portModel; // } // // public Set<ManifestationTypeModel> getErrors() { // return new LinkedHashSet<>(errors.values()); // } // // public void setError(Collection<ManifestationTypeModel> errors) { // this.errors = new LinkedHashMap<>(); // for(ManifestationTypeModel error : errors){ // this.errors.put(error.getName(), error); // } // } // // public ManifestationTypeModel getErrorByName(String name){ // return errors.get(name); // } // // public FeatureModel getPort() { // return port; // } // // public String getName() { // return name; // } // }
import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.PropagationModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class FeatureModel { private String name; protected boolean subscribe; /** * Error types entering or leaving this port */ private Map<String, ManifestationTypeModel> propagatableErrors = new LinkedHashMap<>(); /** * The actual propagations that describe how the incoming or outgoing errors * are grouped */
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/ManifestationTypeModel.java // public class ManifestationTypeModel { // private String name; // private ManifestationType manifestation; // private boolean sunk = false; // // public ManifestationTypeModel(String name, ErrorType parentType) { // this.name = name; // } // // public String getName(){ // return name; // } // // public void setManifestation(ManifestationType manifestation) { // this.manifestation = manifestation; // } // // public String getManifestationName() { // if(manifestation == null){ // return null; // } else { // return manifestation.toString(); // } // } // // public boolean isSunk() { // return sunk; // } // // public void setSunk() { // sunk = true; // } // } // // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java // public class PropagationModel{ // private String name; // private Map<String, ManifestationTypeModel> errors; // private FeatureModel port; // // public PropagationModel(String name, Collection<ManifestationTypeModel> errors, FeatureModel portModel) { // this.name = name; // setError(errors); // this.port = portModel; // } // // public Set<ManifestationTypeModel> getErrors() { // return new LinkedHashSet<>(errors.values()); // } // // public void setError(Collection<ManifestationTypeModel> errors) { // this.errors = new LinkedHashMap<>(); // for(ManifestationTypeModel error : errors){ // this.errors.put(error.getName(), error); // } // } // // public ManifestationTypeModel getErrorByName(String name){ // return errors.get(name); // } // // public FeatureModel getPort() { // return port; // } // // public String getName() { // return name; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.ManifestationTypeModel; import edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis.PropagationModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model; public class FeatureModel { private String name; protected boolean subscribe; /** * Error types entering or leaving this port */ private Map<String, ManifestationTypeModel> propagatableErrors = new LinkedHashMap<>(); /** * The actual propagations that describe how the incoming or outgoing errors * are grouped */
private Map<String, PropagationModel> propagations = new LinkedHashMap<>();
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/preference/TranslatorPreferencePage.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/AadlTranslatorPlugin.java // public class AadlTranslatorPlugin extends AbstractUIPlugin { // //The shared instance. // private static AadlTranslatorPlugin plugin; // //Resource bundle. // private ResourceBundle resourceBundle; // // /** // * The constructor. // */ // public AadlTranslatorPlugin() { // super(); // plugin = this; // try { // resourceBundle = ResourceBundle.getBundle("edu.ksu.cis.projects.mdcf.aadltranslator.PluginResources"); // } catch (MissingResourceException x) { // resourceBundle = null; // } // } // // /** // * This method is called upon plug-in activation // */ // public void start(BundleContext context) throws Exception { // super.start(context); // } // // /** // * This method is called when the plug-in is stopped // */ // public void stop(BundleContext context) throws Exception { // super.stop(context); // } // // /** // * Returns the shared instance. // */ // public static AadlTranslatorPlugin getDefault() { // return plugin; // } // // /** // * Returns the string from the plugin's resource bundle, or 'key' if not // * found. // */ // public static String getResourceString(String key) { // ResourceBundle bundle = AadlTranslatorPlugin.getDefault().getResourceBundle(); // try { // return (bundle != null) ? bundle.getString(key) : key; // } catch (MissingResourceException e) { // return key; // } // } // // /** // * Returns the plugin's resource bundle, // */ // public ResourceBundle getResourceBundle() { // return resourceBundle; // } // }
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import edu.ksu.cis.projects.mdcf.aadltranslator.AadlTranslatorPlugin;
package edu.ksu.cis.projects.mdcf.aadltranslator.preference; /** * This class represents a preference page that is contributed to the * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we * can use the field support built into JFace that allows us to create a page * that is small and knows how to save, restore and apply itself. * <p> * This page is used to modify preferences only. They are stored in the * preference store that belongs to the main plug-in class. That way, * preferences can be accessed directly via the preference store. */ public class TranslatorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public TranslatorPreferencePage() { super(GRID);
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/AadlTranslatorPlugin.java // public class AadlTranslatorPlugin extends AbstractUIPlugin { // //The shared instance. // private static AadlTranslatorPlugin plugin; // //Resource bundle. // private ResourceBundle resourceBundle; // // /** // * The constructor. // */ // public AadlTranslatorPlugin() { // super(); // plugin = this; // try { // resourceBundle = ResourceBundle.getBundle("edu.ksu.cis.projects.mdcf.aadltranslator.PluginResources"); // } catch (MissingResourceException x) { // resourceBundle = null; // } // } // // /** // * This method is called upon plug-in activation // */ // public void start(BundleContext context) throws Exception { // super.start(context); // } // // /** // * This method is called when the plug-in is stopped // */ // public void stop(BundleContext context) throws Exception { // super.stop(context); // } // // /** // * Returns the shared instance. // */ // public static AadlTranslatorPlugin getDefault() { // return plugin; // } // // /** // * Returns the string from the plugin's resource bundle, or 'key' if not // * found. // */ // public static String getResourceString(String key) { // ResourceBundle bundle = AadlTranslatorPlugin.getDefault().getResourceBundle(); // try { // return (bundle != null) ? bundle.getString(key) : key; // } catch (MissingResourceException e) { // return key; // } // } // // /** // * Returns the plugin's resource bundle, // */ // public ResourceBundle getResourceBundle() { // return resourceBundle; // } // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/preference/TranslatorPreferencePage.java import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import edu.ksu.cis.projects.mdcf.aadltranslator.AadlTranslatorPlugin; package edu.ksu.cis.projects.mdcf.aadltranslator.preference; /** * This class represents a preference page that is contributed to the * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we * can use the field support built into JFace that allows us to create a page * that is small and knows how to save, restore and apply itself. * <p> * This page is used to modify preferences only. They are stored in the * preference store that belongs to the main plug-in class. That way, * preferences can be accessed directly via the preference store. */ public class TranslatorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public TranslatorPreferencePage() { super(GRID);
setPreferenceStore(AadlTranslatorPlugin.getDefault()
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java // public class FeatureModel { // // private String name; // protected boolean subscribe; // // /** // * Error types entering or leaving this port // */ // private Map<String, ManifestationTypeModel> propagatableErrors = new LinkedHashMap<>(); // // /** // * The actual propagations that describe how the incoming or outgoing errors // * are grouped // */ // private Map<String, PropagationModel> propagations = new LinkedHashMap<>(); // // public FeatureModel() { // super(); // } // // public String getName() { // return name; // } // // public boolean isSubscribe() { // return subscribe; // } // // public void setSubscribe(boolean subscribe) { // this.subscribe = subscribe; // } // // public void setName(String portName) { // this.name = portName; // } // // public void addPropagatableErrors(Collection<ManifestationTypeModel> propagations) { // for (ManifestationTypeModel errType : propagations) { // propagatableErrors.put(errType.getName(), errType); // } // } // // public Map<String, ManifestationTypeModel> getPropagatableErrors() { // return propagatableErrors; // } // // public void addPropagation(PropagationModel propModel) { // propagations.put(propModel.getName(), propModel); // } // // public ManifestationTypeModel getPropagatableErrorByName(String name) { // return propagatableErrors.get(name); // } // // public PropagationModel getPropagationByName(String name){ // return propagations.get(name); // } // // }
import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.model.FeatureModel;
package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * This class models EMv2 propagations. * * @author Sam * */ public class PropagationModel{ private String name; private Map<String, ManifestationTypeModel> errors;
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/FeatureModel.java // public class FeatureModel { // // private String name; // protected boolean subscribe; // // /** // * Error types entering or leaving this port // */ // private Map<String, ManifestationTypeModel> propagatableErrors = new LinkedHashMap<>(); // // /** // * The actual propagations that describe how the incoming or outgoing errors // * are grouped // */ // private Map<String, PropagationModel> propagations = new LinkedHashMap<>(); // // public FeatureModel() { // super(); // } // // public String getName() { // return name; // } // // public boolean isSubscribe() { // return subscribe; // } // // public void setSubscribe(boolean subscribe) { // this.subscribe = subscribe; // } // // public void setName(String portName) { // this.name = portName; // } // // public void addPropagatableErrors(Collection<ManifestationTypeModel> propagations) { // for (ManifestationTypeModel errType : propagations) { // propagatableErrors.put(errType.getName(), errType); // } // } // // public Map<String, ManifestationTypeModel> getPropagatableErrors() { // return propagatableErrors; // } // // public void addPropagation(PropagationModel propModel) { // propagations.put(propModel.getName(), propModel); // } // // public ManifestationTypeModel getPropagatableErrorByName(String name) { // return propagatableErrors.get(name); // } // // public PropagationModel getPropagationByName(String name){ // return propagations.get(name); // } // // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model/hazardanalysis/PropagationModel.java import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import edu.ksu.cis.projects.mdcf.aadltranslator.model.FeatureModel; package edu.ksu.cis.projects.mdcf.aadltranslator.model.hazardanalysis; /** * This class models EMv2 propagations. * * @author Sam * */ public class PropagationModel{ private String name; private Map<String, ManifestationTypeModel> errors;
private FeatureModel port;
santoslab/aadl-translator
aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model_for_device/DeviceComponentModel.java
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model_for_device/ModelUtil.java // public class ModelUtil { // // // // public final static Predicate<ExchangeModel> getExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof GetExchangeModel); // } // }; // // public final static Function<ExchangeModel, GetExchangeModel> transformToGetExchangeModel = new Function<ExchangeModel, GetExchangeModel>(){ // public GetExchangeModel apply(ExchangeModel em){ // return ((GetExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> setExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof SetExchangeModel); // } // }; // // public final static Function<ExchangeModel, SetExchangeModel> transformToSetExchangeModel = new Function<ExchangeModel, SetExchangeModel>(){ // public SetExchangeModel apply(ExchangeModel em){ // return ((SetExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> actionExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof ActionExchangeModel); // } // }; // // public final static Function<ExchangeModel, ActionExchangeModel> transformToActionExchangeModel = new Function<ExchangeModel, ActionExchangeModel>(){ // public ActionExchangeModel apply(ExchangeModel em){ // return ((ActionExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> periodicExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof PeriodicExchangeModel); // } // }; // // public final static Function<ExchangeModel, PeriodicExchangeModel> transformToPeriodicExchangeModel = new Function<ExchangeModel, PeriodicExchangeModel>(){ // public PeriodicExchangeModel apply(ExchangeModel em){ // return ((PeriodicExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> sporadicExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof SporadicExchangeModel); // } // }; // // public final static Function<ExchangeModel, SporadicExchangeModel> transformToSporadicExchangeModel = new Function<ExchangeModel, SporadicExchangeModel>(){ // public SporadicExchangeModel apply(ExchangeModel em){ // return ((SporadicExchangeModel) em); // } // }; // }
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import com.google.common.collect.Maps; import edu.ksu.cis.projects.mdcf.aadltranslator.model_for_device.ModelUtil;
public String getManufacturerName() { return manufacturerName; } public void setManufacturerName(String manufacturerName) { this.manufacturerName = manufacturerName; } public String getModelNumber() { return modelNumber; } public void setModelNumber(String modelNumber) { this.modelNumber = modelNumber; } public ArrayList<String> getCredentials(){ if(this.credentials == null) this.credentials = new ArrayList<String>(); return this.credentials; } public void addCredential(String credential){ if(this.credentials == null) this.credentials = new ArrayList<String>(); this.credentials.add(credential); } public void distributeExchanges(){ getExchangeModels = (Map<String, GetExchangeModel>) Maps.transformValues(
// Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model_for_device/ModelUtil.java // public class ModelUtil { // // // // public final static Predicate<ExchangeModel> getExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof GetExchangeModel); // } // }; // // public final static Function<ExchangeModel, GetExchangeModel> transformToGetExchangeModel = new Function<ExchangeModel, GetExchangeModel>(){ // public GetExchangeModel apply(ExchangeModel em){ // return ((GetExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> setExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof SetExchangeModel); // } // }; // // public final static Function<ExchangeModel, SetExchangeModel> transformToSetExchangeModel = new Function<ExchangeModel, SetExchangeModel>(){ // public SetExchangeModel apply(ExchangeModel em){ // return ((SetExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> actionExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof ActionExchangeModel); // } // }; // // public final static Function<ExchangeModel, ActionExchangeModel> transformToActionExchangeModel = new Function<ExchangeModel, ActionExchangeModel>(){ // public ActionExchangeModel apply(ExchangeModel em){ // return ((ActionExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> periodicExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof PeriodicExchangeModel); // } // }; // // public final static Function<ExchangeModel, PeriodicExchangeModel> transformToPeriodicExchangeModel = new Function<ExchangeModel, PeriodicExchangeModel>(){ // public PeriodicExchangeModel apply(ExchangeModel em){ // return ((PeriodicExchangeModel) em); // } // }; // // public final static Predicate<ExchangeModel> sporadicExchangeFilter = new Predicate<ExchangeModel>() { // public boolean apply(ExchangeModel em) { // return (em instanceof SporadicExchangeModel); // } // }; // // public final static Function<ExchangeModel, SporadicExchangeModel> transformToSporadicExchangeModel = new Function<ExchangeModel, SporadicExchangeModel>(){ // public SporadicExchangeModel apply(ExchangeModel em){ // return ((SporadicExchangeModel) em); // } // }; // } // Path: aadl-translator/src/main/java/edu/ksu/cis/projects/mdcf/aadltranslator/model_for_device/DeviceComponentModel.java import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import com.google.common.collect.Maps; import edu.ksu.cis.projects.mdcf.aadltranslator.model_for_device.ModelUtil; public String getManufacturerName() { return manufacturerName; } public void setManufacturerName(String manufacturerName) { this.manufacturerName = manufacturerName; } public String getModelNumber() { return modelNumber; } public void setModelNumber(String modelNumber) { this.modelNumber = modelNumber; } public ArrayList<String> getCredentials(){ if(this.credentials == null) this.credentials = new ArrayList<String>(); return this.credentials; } public void addCredential(String credential){ if(this.credentials == null) this.credentials = new ArrayList<String>(); this.credentials.add(credential); } public void distributeExchanges(){ getExchangeModels = (Map<String, GetExchangeModel>) Maps.transformValues(
(Map<String, ExchangeModel>) Maps.filterValues(exchangeModels, ModelUtil.getExchangeFilter),
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // // Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // }
import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler; import com.github.plusvic.yara.YaraException;
package com.github.plusvic.yara.embedded; /** * Yara component * * @apiNote There should be only one component instance per process */ public class YaraImpl implements Yara { private static final YaraLibrary library; static { library = new YaraLibrary(); library.initialize(); } /** * Create compiler * * @return */
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // // Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler; import com.github.plusvic.yara.YaraException; package com.github.plusvic.yara.embedded; /** * Yara component * * @apiNote There should be only one component instance per process */ public class YaraImpl implements Yara { private static final YaraLibrary library; static { library = new YaraLibrary(); library.initialize(); } /** * Create compiler * * @return */
public YaraCompiler createCompiler() {
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // // Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // }
import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler; import com.github.plusvic.yara.YaraException;
package com.github.plusvic.yara.embedded; /** * Yara component * * @apiNote There should be only one component instance per process */ public class YaraImpl implements Yara { private static final YaraLibrary library; static { library = new YaraLibrary(); library.initialize(); } /** * Create compiler * * @return */ public YaraCompiler createCompiler() { long compiler[] = new long[1]; int ret = library.compilerCreate(compiler); if (ret != 0) {
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // // Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler; import com.github.plusvic.yara.YaraException; package com.github.plusvic.yara.embedded; /** * Yara component * * @apiNote There should be only one component instance per process */ public class YaraImpl implements Yara { private static final YaraLibrary library; static { library = new YaraLibrary(); library.initialize(); } /** * Create compiler * * @return */ public YaraCompiler createCompiler() { long compiler[] = new long[1]; int ret = library.compilerCreate(compiler); if (ret != 0) {
throw new YaraException(ret);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraMetaImpl.java
// Path: src/main/java/com/github/plusvic/yara/YaraMeta.java // public interface YaraMeta { // enum Type { // NULL(0), // INTEGER(1), // STRING(2), // BOOLEAN(3); // // private int value; // // Type(int value) { // this.value = value; // } // // public static Type from(int value) { // for (Type t : Type.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Get metadata type // * // * @return // */ // Type getType(); // // /** // * Get metadata identifier // * // * @return // */ // String getIndentifier(); // // /** // * Get metadata string value // * // * @return // */ // String getString(); // // /** // * Get metadata integer value // * // * @return // */ // int getInteger(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMeta; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.external; public class YaraMetaImpl implements YaraMeta { private String identifier; private Type type; private String string; private int integer; public YaraMetaImpl(String identifier, String value) {
// Path: src/main/java/com/github/plusvic/yara/YaraMeta.java // public interface YaraMeta { // enum Type { // NULL(0), // INTEGER(1), // STRING(2), // BOOLEAN(3); // // private int value; // // Type(int value) { // this.value = value; // } // // public static Type from(int value) { // for (Type t : Type.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Get metadata type // * // * @return // */ // Type getType(); // // /** // * Get metadata identifier // * // * @return // */ // String getIndentifier(); // // /** // * Get metadata string value // * // * @return // */ // String getString(); // // /** // * Get metadata integer value // * // * @return // */ // int getInteger(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraMetaImpl.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMeta; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.external; public class YaraMetaImpl implements YaraMeta { private String identifier; private Type type; private String string; private int integer; public YaraMetaImpl(String identifier, String value) {
checkArgument(!Utils.isNullOrEmpty(identifier));
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraScannerImpl.java
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.*; import org.fusesource.hawtjni.runtime.Callback; import java.io.File; import java.io.IOException; import java.text.MessageFormat; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
private static final long CALLBACK_MSG_IMPORT_MODULE = 4; private static final int SCAN_FLAGS_FAST_MODE = 0x00000001; private static final int SCAN_FLAGS_PROCESS_MEMORY = 0x00000002; private static final int SCAN_FLAGS_NO_TRYCATCH = 0x00000004; private class NativeScanCallback { private boolean negate = false; private int maxRules = 0; private int count = 0; private final YaraLibrary library; private final YaraScanCallback scanCallback; private final YaraModuleCallback moduleCallback; public NativeScanCallback(YaraLibrary library, YaraScanCallback callback) { this(library, callback, null); } public NativeScanCallback(YaraLibrary library, YaraScanCallback scanCallback, YaraModuleCallback moduleCallback) { this.library = library; this.scanCallback = scanCallback; this.moduleCallback = moduleCallback; } public void setNegate(boolean negate) { this.negate = negate; return; } public void setMaxRules(int count) {
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraScannerImpl.java import com.github.plusvic.yara.*; import org.fusesource.hawtjni.runtime.Callback; import java.io.File; import java.io.IOException; import java.text.MessageFormat; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; private static final long CALLBACK_MSG_IMPORT_MODULE = 4; private static final int SCAN_FLAGS_FAST_MODE = 0x00000001; private static final int SCAN_FLAGS_PROCESS_MEMORY = 0x00000002; private static final int SCAN_FLAGS_NO_TRYCATCH = 0x00000004; private class NativeScanCallback { private boolean negate = false; private int maxRules = 0; private int count = 0; private final YaraLibrary library; private final YaraScanCallback scanCallback; private final YaraModuleCallback moduleCallback; public NativeScanCallback(YaraLibrary library, YaraScanCallback callback) { this(library, callback, null); } public NativeScanCallback(YaraLibrary library, YaraScanCallback scanCallback, YaraModuleCallback moduleCallback) { this.library = library; this.scanCallback = scanCallback; this.moduleCallback = moduleCallback; } public void setNegate(boolean negate) { this.negate = negate; return; } public void setMaxRules(int count) {
checkArgument(count >= 0);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraCompilerImpl.java
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.*; import java.io.*; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.external; public class YaraCompilerImpl implements YaraCompiler { private static final Logger LOGGER = Logger.getLogger(YaraCompilerImpl.class.getName()); private YaraCompilationCallback callback; private List<Path> packages = new ArrayList<>(); private YaracExecutable yarac; private Path rules; public YaraCompilerImpl() { this.rules = null; this.yarac = new YaracExecutable(); } @Override public void setCallback(YaraCompilationCallback cbk) {
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraCompilerImpl.java import com.github.plusvic.yara.*; import java.io.*; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.external; public class YaraCompilerImpl implements YaraCompiler { private static final Logger LOGGER = Logger.getLogger(YaraCompilerImpl.class.getName()); private YaraCompilationCallback callback; private List<Path> packages = new ArrayList<>(); private YaracExecutable yarac; private Path rules; public YaraCompilerImpl() { this.rules = null; this.yarac = new YaracExecutable(); } @Override public void setCallback(YaraCompilationCallback cbk) {
checkArgument(cbk != null);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraStringImpl.java
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMatch; import com.github.plusvic.yara.YaraString; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.external; public class YaraStringImpl implements YaraString { private String identifier;
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraStringImpl.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMatch; import com.github.plusvic.yara.YaraString; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.external; public class YaraStringImpl implements YaraString { private String identifier;
private List<YaraMatch> matches = new ArrayList<>();
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraStringImpl.java
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMatch; import com.github.plusvic.yara.YaraString; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.external; public class YaraStringImpl implements YaraString { private String identifier; private List<YaraMatch> matches = new ArrayList<>(); public YaraStringImpl(String identifier) {
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraStringImpl.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraMatch; import com.github.plusvic.yara.YaraString; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.external; public class YaraStringImpl implements YaraString { private String identifier; private List<YaraMatch> matches = new ArrayList<>(); public YaraStringImpl(String identifier) {
checkArgument(!Utils.isNullOrEmpty(identifier));
p8a/yara-java
src/main/java/com/github/plusvic/yara/YaraFactory.java
// Path: src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java // public class YaraImpl implements Yara { // private static final YaraLibrary library; // // static { // library = new YaraLibrary(); // library.initialize(); // } // // /** // * Create compiler // * // * @return // */ // public YaraCompiler createCompiler() { // long compiler[] = new long[1]; // // int ret = library.compilerCreate(compiler); // if (ret != 0) { // throw new YaraException(ret); // } // // return new YaraCompilerImpl(this.library, compiler[0]); // } // // @Override // public void close() throws Exception { // } // }
import com.github.plusvic.yara.embedded.YaraImpl;
package com.github.plusvic.yara; /** * Yara factory */ public class YaraFactory { public enum Mode { EMBEDDED, EXTERNAL } public static Yara create(Mode mode) { switch (mode) { case EMBEDDED:
// Path: src/main/java/com/github/plusvic/yara/embedded/YaraImpl.java // public class YaraImpl implements Yara { // private static final YaraLibrary library; // // static { // library = new YaraLibrary(); // library.initialize(); // } // // /** // * Create compiler // * // * @return // */ // public YaraCompiler createCompiler() { // long compiler[] = new long[1]; // // int ret = library.compilerCreate(compiler); // if (ret != 0) { // throw new YaraException(ret); // } // // return new YaraCompilerImpl(this.library, compiler[0]); // } // // @Override // public void close() throws Exception { // } // } // Path: src/main/java/com/github/plusvic/yara/YaraFactory.java import com.github.plusvic.yara.embedded.YaraImpl; package com.github.plusvic.yara; /** * Yara factory */ public class YaraFactory { public enum Mode { EMBEDDED, EXTERNAL } public static Yara create(Mode mode) { switch (mode) { case EMBEDDED:
return new YaraImpl();
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraMetaImpl.java
// Path: src/main/java/com/github/plusvic/yara/YaraMeta.java // public interface YaraMeta { // enum Type { // NULL(0), // INTEGER(1), // STRING(2), // BOOLEAN(3); // // private int value; // // Type(int value) { // this.value = value; // } // // public static Type from(int value) { // for (Type t : Type.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Get metadata type // * // * @return // */ // Type getType(); // // /** // * Get metadata identifier // * // * @return // */ // String getIndentifier(); // // /** // * Get metadata string value // * // * @return // */ // String getString(); // // /** // * Get metadata integer value // * // * @return // */ // int getInteger(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.YaraMeta; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.embedded; /** * User: pba * Date: 6/9/15 * Time: 3:06 PM */ public class YaraMetaImpl implements YaraMeta { private final YaraLibrary library; private final long peer; YaraMetaImpl(YaraLibrary library, long peer) {
// Path: src/main/java/com/github/plusvic/yara/YaraMeta.java // public interface YaraMeta { // enum Type { // NULL(0), // INTEGER(1), // STRING(2), // BOOLEAN(3); // // private int value; // // Type(int value) { // this.value = value; // } // // public static Type from(int value) { // for (Type t : Type.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Get metadata type // * // * @return // */ // Type getType(); // // /** // * Get metadata identifier // * // * @return // */ // String getIndentifier(); // // /** // * Get metadata string value // * // * @return // */ // String getString(); // // /** // * Get metadata integer value // * // * @return // */ // int getInteger(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraMetaImpl.java import com.github.plusvic.yara.YaraMeta; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.embedded; /** * User: pba * Date: 6/9/15 * Time: 3:06 PM */ public class YaraMetaImpl implements YaraMeta { private final YaraLibrary library; private final long peer; YaraMetaImpl(YaraLibrary library, long peer) {
checkArgument(library != null);
p8a/yara-java
src/test/java/com/github/plusvic/yara/embedded/YaraImplTest.java
// Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // }
import org.junit.Test; import com.github.plusvic.yara.YaraCompiler; import static org.junit.Assert.assertNotNull;
package com.github.plusvic.yara.embedded; /** * User: pba * Date: 6/9/15 * Time: 6:51 PM */ public class YaraImplTest { @Test public void testCreateClose() throws Exception { try (YaraImpl yara = new YaraImpl()) { } } @Test public void testCreateCompiler() throws Exception { try (YaraImpl yara = new YaraImpl()) {
// Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // Path: src/test/java/com/github/plusvic/yara/embedded/YaraImplTest.java import org.junit.Test; import com.github.plusvic.yara.YaraCompiler; import static org.junit.Assert.assertNotNull; package com.github.plusvic.yara.embedded; /** * User: pba * Date: 6/9/15 * Time: 6:51 PM */ public class YaraImplTest { @Test public void testCreateClose() throws Exception { try (YaraImpl yara = new YaraImpl()) { } } @Test public void testCreateCompiler() throws Exception { try (YaraImpl yara = new YaraImpl()) {
try (YaraCompiler compiler = yara.createCompiler()) {
p8a/yara-java
src/test/java/com/github/plusvic/yara/external/YaracExecutableTest.java
// Path: src/test/java/com/github/plusvic/yara/TestUtils.java // public class TestUtils { // public static Path getResource(String path) { // try { // return Paths.get(TestUtils.class.getClassLoader().getResource(path).toURI()); // } // catch (Throwable t) { // throw new RuntimeException(t); // } // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // }
import com.github.plusvic.yara.TestUtils; import com.github.plusvic.yara.YaraCompilationCallback; import org.junit.Test; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import static org.easymock.EasyMock.*; import static org.junit.Assert.*;
} @Test public void testCreateNativeExec() { NativeExecutable exec = createNiceMock(NativeExecutable.class); expect(exec.load()).andReturn(true).once(); replay(exec); new YaracExecutable(exec); verify(exec); } @Test(expected = IllegalArgumentException.class) public void testRuleNullNamespace() { YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(null, Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testRule() { YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testExecuteNoArgs() throws Exception { final AtomicBoolean failure = new AtomicBoolean();
// Path: src/test/java/com/github/plusvic/yara/TestUtils.java // public class TestUtils { // public static Path getResource(String path) { // try { // return Paths.get(TestUtils.class.getClassLoader().getResource(path).toURI()); // } // catch (Throwable t) { // throw new RuntimeException(t); // } // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // Path: src/test/java/com/github/plusvic/yara/external/YaracExecutableTest.java import com.github.plusvic.yara.TestUtils; import com.github.plusvic.yara.YaraCompilationCallback; import org.junit.Test; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import static org.easymock.EasyMock.*; import static org.junit.Assert.*; } @Test public void testCreateNativeExec() { NativeExecutable exec = createNiceMock(NativeExecutable.class); expect(exec.load()).andReturn(true).once(); replay(exec); new YaracExecutable(exec); verify(exec); } @Test(expected = IllegalArgumentException.class) public void testRuleNullNamespace() { YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(null, Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testRule() { YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testExecuteNoArgs() throws Exception { final AtomicBoolean failure = new AtomicBoolean();
YaraCompilationCallback callback = new YaraCompilationCallback() {
p8a/yara-java
src/test/java/com/github/plusvic/yara/external/YaracExecutableTest.java
// Path: src/test/java/com/github/plusvic/yara/TestUtils.java // public class TestUtils { // public static Path getResource(String path) { // try { // return Paths.get(TestUtils.class.getClassLoader().getResource(path).toURI()); // } // catch (Throwable t) { // throw new RuntimeException(t); // } // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // }
import com.github.plusvic.yara.TestUtils; import com.github.plusvic.yara.YaraCompilationCallback; import org.junit.Test; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import static org.easymock.EasyMock.*; import static org.junit.Assert.*;
YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testExecuteNoArgs() throws Exception { final AtomicBoolean failure = new AtomicBoolean(); YaraCompilationCallback callback = new YaraCompilationCallback() { @Override public void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message) { failure.set(true); } }; Path output = new YaracExecutable().compile(callback); assertNotNull(output); assertTrue(failure.get()); } @Test public void testExecuteOK() throws Exception { YaraCompilationCallback callback = new YaraCompilationCallback() { @Override public void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message) { fail(); } }; Path output = new YaracExecutable()
// Path: src/test/java/com/github/plusvic/yara/TestUtils.java // public class TestUtils { // public static Path getResource(String path) { // try { // return Paths.get(TestUtils.class.getClassLoader().getResource(path).toURI()); // } // catch (Throwable t) { // throw new RuntimeException(t); // } // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // Path: src/test/java/com/github/plusvic/yara/external/YaracExecutableTest.java import com.github.plusvic.yara.TestUtils; import com.github.plusvic.yara.YaraCompilationCallback; import org.junit.Test; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import static org.easymock.EasyMock.*; import static org.junit.Assert.*; YaracExecutable exec = new YaracExecutable(); assertEquals(exec, exec.addRule(Paths.get(System.getProperty("java.io.tmpdir")))); } @Test public void testExecuteNoArgs() throws Exception { final AtomicBoolean failure = new AtomicBoolean(); YaraCompilationCallback callback = new YaraCompilationCallback() { @Override public void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message) { failure.set(true); } }; Path output = new YaracExecutable().compile(callback); assertNotNull(output); assertTrue(failure.get()); } @Test public void testExecuteOK() throws Exception { YaraCompilationCallback callback = new YaraCompilationCallback() { @Override public void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message) { fail(); } }; Path output = new YaracExecutable()
.addRule(TestUtils.getResource("rules/hello.yara"))
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaracExecutable.java
// Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraCompilationCallback; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
public YaracExecutable(NativeExecutable executable) { if (executable == null) { throw new IllegalArgumentException(); } this.executable = executable; this.executable.load(); } public YaracExecutable addRule(Path file) { return addRule(GLOBAL_NAMESPACE, file); } public YaracExecutable addRule(String namespace, Path file) { if (namespace == null || !Utils.exists(file)) { throw new IllegalArgumentException(); } Set<Path> paths = rules.get(namespace); if (paths == null) { paths = new HashSet<>(); rules.put(namespace, paths); } paths.add(file); return this; } public YaracExecutable setTimeout(int timeout) {
// Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaracExecutable.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraCompilationCallback; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; public YaracExecutable(NativeExecutable executable) { if (executable == null) { throw new IllegalArgumentException(); } this.executable = executable; this.executable.load(); } public YaracExecutable addRule(Path file) { return addRule(GLOBAL_NAMESPACE, file); } public YaracExecutable addRule(String namespace, Path file) { if (namespace == null || !Utils.exists(file)) { throw new IllegalArgumentException(); } Set<Path> paths = rules.get(namespace); if (paths == null) { paths = new HashSet<>(); rules.put(namespace, paths); } paths.add(file); return this; } public YaracExecutable setTimeout(int timeout) {
checkArgument(timeout > 0);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaracExecutable.java
// Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraCompilationCallback; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
} paths.add(file); return this; } public YaracExecutable setTimeout(int timeout) { checkArgument(timeout > 0); this.timeout = timeout; return this; } private String[] getCommandLine(Path output) { List<String> args = new ArrayList<>(); for (Map.Entry<String, Set<Path>> kv : rules.entrySet()) { for (Path path : kv.getValue()) { String prefix = Utils.isNullOrEmpty(kv.getKey()) ? "" : kv.getKey() + ":"; args.add(prefix + path.toAbsolutePath().toString()); } } args.add(output.toAbsolutePath().toString()); return args.toArray(new String[args.size()]); }
// Path: src/main/java/com/github/plusvic/yara/YaraCompilationCallback.java // public interface YaraCompilationCallback { // /** // * Compilation error level // */ // enum ErrorLevel { // ERROR(0), // WARNING(1); // // private int value; // // ErrorLevel(int value) { // this.value = value; // } // // public static ErrorLevel from(int value) { // for (ErrorLevel t : ErrorLevel.values()) { // if (t.value == value) { // return t; // } // } // // throw new IllegalArgumentException(); // } // } // // /** // * Compilation error occured // * @param errorLevel Error level // * @param fileName File name being compiled (empty if string) // * @param lineNumber Line number // * @param message Error message // */ // void onError(ErrorLevel errorLevel, String fileName, long lineNumber, String message); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaracExecutable.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraCompilationCallback; import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; } paths.add(file); return this; } public YaracExecutable setTimeout(int timeout) { checkArgument(timeout > 0); this.timeout = timeout; return this; } private String[] getCommandLine(Path output) { List<String> args = new ArrayList<>(); for (Map.Entry<String, Set<Path>> kv : rules.entrySet()) { for (Path path : kv.getValue()) { String prefix = Utils.isNullOrEmpty(kv.getKey()) ? "" : kv.getKey() + ":"; args.add(prefix + path.toAbsolutePath().toString()); } } args.add(output.toAbsolutePath().toString()); return args.toArray(new String[args.size()]); }
public Path compile(YaraCompilationCallback callback) throws Exception {
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraExecutable.java
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.external; public class YaraExecutable { private static final Logger LOGGER = Logger.getLogger(YaraExecutable.class.getName()); private int timeout = 60; private boolean negate = false; private int maxRules = 0; private NativeExecutable executable; private Set<Path> rules = new HashSet<>(); public YaraExecutable() { this.executable = YaraExecutableManager.getYara(); } public YaraExecutable(NativeExecutable executable) { if (executable == null) { throw new IllegalArgumentException(); } this.executable = executable; this.executable.load(); } public YaraExecutable addRule(Path file) { if (!Utils.exists(file)) { throw new IllegalArgumentException(); } rules.add(file); return this; } public YaraExecutable setTimeout(int timeout) {
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraExecutable.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.external; public class YaraExecutable { private static final Logger LOGGER = Logger.getLogger(YaraExecutable.class.getName()); private int timeout = 60; private boolean negate = false; private int maxRules = 0; private NativeExecutable executable; private Set<Path> rules = new HashSet<>(); public YaraExecutable() { this.executable = YaraExecutableManager.getYara(); } public YaraExecutable(NativeExecutable executable) { if (executable == null) { throw new IllegalArgumentException(); } this.executable = executable; this.executable.load(); } public YaraExecutable addRule(Path file) { if (!Utils.exists(file)) { throw new IllegalArgumentException(); } rules.add(file); return this; } public YaraExecutable setTimeout(int timeout) {
checkArgument(timeout > 0);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraExecutable.java
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
if (maxRules > 0) { args.add("-l"); args.add(Integer.toString(maxRules)); } // module initialization if (moduleArgs != null && moduleArgs.size() > 0) { moduleArgs.forEach( (k, v) -> { args.add("-x"); args.add(String.format("%s=%s", k, v)); }); } // rules if (rules.size() == 1 && rules.iterator().next().toAbsolutePath().toString().endsWith(Utils.compiledRuleIdentifier)) { // -C flag is required when scanning with a compiled rule args.add("-C"); } for (Path path : rules) { args.add(path.toAbsolutePath().toString()); } // sample args.add(target.toAbsolutePath().toString()); return args.toArray(new String[]{}); }
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraExecutable.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; if (maxRules > 0) { args.add("-l"); args.add(Integer.toString(maxRules)); } // module initialization if (moduleArgs != null && moduleArgs.size() > 0) { moduleArgs.forEach( (k, v) -> { args.add("-x"); args.add(String.format("%s=%s", k, v)); }); } // rules if (rules.size() == 1 && rules.iterator().next().toAbsolutePath().toString().endsWith(Utils.compiledRuleIdentifier)) { // -C flag is required when scanning with a compiled rule args.add("-C"); } for (Path path : rules) { args.add(path.toAbsolutePath().toString()); } // sample args.add(target.toAbsolutePath().toString()); return args.toArray(new String[]{}); }
public boolean match(Path target, Map<String, String> moduleArgs, YaraScanCallback callback) throws Exception {
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraExecutable.java
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument;
{ String line; while(null != (line = perr.readLine())) { processError(line); } YaraOutputProcessor outputProcessor = new YaraOutputProcessor(callback); outputProcessor.onStart(); while (null != (line = pout.readLine())) { outputProcessor.onLine(line); } outputProcessor.onComplete(); } return true; } catch (Throwable t) { LOGGER.log(Level.WARNING, "Failed to match rules: {0}", t.getMessage()); throw t; } finally { if (ftmp != null) { if (! ftmp.delete()) { LOGGER.log(Level.WARNING, "Failed to delete tmp file {0}", ftmp); } } } } private void processError(String line) {
// Path: src/main/java/com/github/plusvic/yara/YaraException.java // public class YaraException extends RuntimeException { // private int code; // // public YaraException(int code) { // super(String.format("Code: %d", code)); // this.code = code; // } // // public YaraException(String message) { // super(message); // this.code = ErrorCode.UNKNOWN.getValue(); // } // // public int getNativeCode() { // return this.code; // } // // public ErrorCode getCode() { // return ErrorCode.from(this.code); // } // } // // Path: src/main/java/com/github/plusvic/yara/YaraScanCallback.java // public interface YaraScanCallback { // /** // * Called when a rule matches // * // * @param rule Rule that matched // */ // void onMatch(YaraRule rule); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/external/YaraExecutable.java import com.github.plusvic.yara.Utils; import com.github.plusvic.yara.YaraException; import com.github.plusvic.yara.YaraScanCallback; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import static com.github.plusvic.yara.Preconditions.checkArgument; { String line; while(null != (line = perr.readLine())) { processError(line); } YaraOutputProcessor outputProcessor = new YaraOutputProcessor(callback); outputProcessor.onStart(); while (null != (line = pout.readLine())) { outputProcessor.onLine(line); } outputProcessor.onComplete(); } return true; } catch (Throwable t) { LOGGER.log(Level.WARNING, "Failed to match rules: {0}", t.getMessage()); throw t; } finally { if (ftmp != null) { if (! ftmp.delete()) { LOGGER.log(Level.WARNING, "Failed to delete tmp file {0}", ftmp); } } } } private void processError(String line) {
throw new YaraException(line);
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraMatchImpl.java
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import com.github.plusvic.yara.YaraMatch; import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.embedded; /** * Yara rule match */ public class YaraMatchImpl implements YaraMatch { private final YaraLibrary library; private final long peer; YaraMatchImpl(YaraLibrary library, long peer) {
// Path: src/main/java/com/github/plusvic/yara/YaraMatch.java // public interface YaraMatch { // /** // * Value that was matched // * // * @return // */ // String getValue(); // // /** // * Offset where match was found // * // * @return // */ // long getOffset(); // } // // Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraMatchImpl.java import com.github.plusvic.yara.YaraMatch; import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.embedded; /** * Yara rule match */ public class YaraMatchImpl implements YaraMatch { private final YaraLibrary library; private final long peer; YaraMatchImpl(YaraLibrary library, long peer) {
checkArgument(library != null);
p8a/yara-java
src/main/java/com/github/plusvic/yara/embedded/YaraModule.java
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // }
import static com.github.plusvic.yara.Preconditions.checkArgument;
package com.github.plusvic.yara.embedded; /** * Yara module */ public class YaraModule implements AutoCloseable { private final YaraLibrary library; private final long peer; private long dp; YaraModule(YaraLibrary library, long peer) {
// Path: src/main/java/com/github/plusvic/yara/Preconditions.java // public static void checkArgument(boolean value) { // if (!value) { // throw new IllegalArgumentException(); // } // } // Path: src/main/java/com/github/plusvic/yara/embedded/YaraModule.java import static com.github.plusvic.yara.Preconditions.checkArgument; package com.github.plusvic.yara.embedded; /** * Yara module */ public class YaraModule implements AutoCloseable { private final YaraLibrary library; private final long peer; private long dp; YaraModule(YaraLibrary library, long peer) {
checkArgument(library != null);
p8a/yara-java
src/main/java/com/github/plusvic/yara/external/YaraImpl.java
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // }
import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler;
package com.github.plusvic.yara.external; public class YaraImpl implements Yara { @Override
// Path: src/main/java/com/github/plusvic/yara/Yara.java // public interface Yara extends AutoCloseable { // YaraCompiler createCompiler(); // // } // // Path: src/main/java/com/github/plusvic/yara/YaraCompiler.java // public interface YaraCompiler extends AutoCloseable { // /** // * Set compilation callback // * // * @param cbk // */ // void setCallback(YaraCompilationCallback cbk); // // /** // * Add rules content // * // * @param content // * @param namespace // * @return // */ // void addRulesContent(String content, String namespace); // // /** // * Add rules file // * // * @param filePath // * @param fileName // * @param namespace // * @return // */ // void addRulesFile(String filePath, String fileName, String namespace); // // /** // * Add all rules from package (zip archive) // * // * @param packagePath // * @param namespace // * @return // */ // void addRulesPackage(String packagePath, String namespace); // // /** // * Create scanner // * // * @return // */ // YaraScanner createScanner(); // } // Path: src/main/java/com/github/plusvic/yara/external/YaraImpl.java import com.github.plusvic.yara.Yara; import com.github.plusvic.yara.YaraCompiler; package com.github.plusvic.yara.external; public class YaraImpl implements Yara { @Override
public YaraCompiler createCompiler() {
ErnestOrt/Trampoline
trampoline/src/test/java/org/ernest/VMParserTest.java
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/VMParser.java // public class VMParser { // // public static final String REGEX_VM_ARGUMENTS = "[-D](.*?)\\="; // // public static String toUnixEnviromentVariables(String vmArguments){ // Pattern pattern = Pattern.compile(REGEX_VM_ARGUMENTS); // Matcher matcher = pattern.matcher(vmArguments); // // StringBuffer upperCaseStringBuffer = new StringBuffer(); // while (matcher.find()) { // matcher.appendReplacement(upperCaseStringBuffer, matcher.group().toUpperCase()); // } // matcher.appendTail(upperCaseStringBuffer); // // String strResult = upperCaseStringBuffer.toString(); // strResult = strResult.replaceAll("-D", "; export "); // strResult = strResult.replaceAll("\\.", "_"); // return strResult; // } // // public static String toWindowsEnviromentVariables(String vmArguments){ // Pattern pattern = Pattern.compile(REGEX_VM_ARGUMENTS); // Matcher matcher = pattern.matcher(vmArguments); // // StringBuffer upperCaseStringBuffer = new StringBuffer(); // while (matcher.find()) { // matcher.appendReplacement(upperCaseStringBuffer, matcher.group().toUpperCase()); // } // matcher.appendTail(upperCaseStringBuffer); // // String strResult = upperCaseStringBuffer.toString(); // strResult = strResult.replaceAll("-D", "&& SET "); // strResult = strResult.replaceAll("\\.", "_"); // return strResult; // } // }
import org.ernest.applications.trampoline.utils.VMParser; import org.junit.Assert; import org.junit.Test;
package org.ernest; public class VMParserTest { @Test public void givenVMArgsWhenParsingToWindowsEnvVariableThemThenResultExpected(){
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/VMParser.java // public class VMParser { // // public static final String REGEX_VM_ARGUMENTS = "[-D](.*?)\\="; // // public static String toUnixEnviromentVariables(String vmArguments){ // Pattern pattern = Pattern.compile(REGEX_VM_ARGUMENTS); // Matcher matcher = pattern.matcher(vmArguments); // // StringBuffer upperCaseStringBuffer = new StringBuffer(); // while (matcher.find()) { // matcher.appendReplacement(upperCaseStringBuffer, matcher.group().toUpperCase()); // } // matcher.appendTail(upperCaseStringBuffer); // // String strResult = upperCaseStringBuffer.toString(); // strResult = strResult.replaceAll("-D", "; export "); // strResult = strResult.replaceAll("\\.", "_"); // return strResult; // } // // public static String toWindowsEnviromentVariables(String vmArguments){ // Pattern pattern = Pattern.compile(REGEX_VM_ARGUMENTS); // Matcher matcher = pattern.matcher(vmArguments); // // StringBuffer upperCaseStringBuffer = new StringBuffer(); // while (matcher.find()) { // matcher.appendReplacement(upperCaseStringBuffer, matcher.group().toUpperCase()); // } // matcher.appendTail(upperCaseStringBuffer); // // String strResult = upperCaseStringBuffer.toString(); // strResult = strResult.replaceAll("-D", "&& SET "); // strResult = strResult.replaceAll("\\.", "_"); // return strResult; // } // } // Path: trampoline/src/test/java/org/ernest/VMParserTest.java import org.ernest.applications.trampoline.utils.VMParser; import org.junit.Assert; import org.junit.Test; package org.ernest; public class VMParserTest { @Test public void givenVMArgsWhenParsingToWindowsEnvVariableThemThenResultExpected(){
Assert.assertEquals("&& SET SERVER_PORT=true", VMParser.toWindowsEnviromentVariables("-Dserver.port=true"));
ErnestOrt/Trampoline
trampoline/src/main/java/org/ernest/applications/trampoline/controller/TrampolineManagerController.java
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/services/TrampolineManager.java // @Service // public class TrampolineManager { // // private final Logger log = LoggerFactory.getLogger(TrampolineManager.class); // // @Autowired // private ApplicationContext appContext; // // public void shutdown(){ // log.info("Shutdowning Trampoline... #HappyCoding"); // try {Thread.sleep(2000);} catch (InterruptedException e) {throw new RuntimeException();} // // SpringApplication.exit(appContext, () -> 0); // } // // }
import org.ernest.applications.trampoline.services.TrampolineManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestMapping;
package org.ernest.applications.trampoline.controller; @Component @RequestMapping("/trampoline") public class TrampolineManagerController { @Autowired
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/services/TrampolineManager.java // @Service // public class TrampolineManager { // // private final Logger log = LoggerFactory.getLogger(TrampolineManager.class); // // @Autowired // private ApplicationContext appContext; // // public void shutdown(){ // log.info("Shutdowning Trampoline... #HappyCoding"); // try {Thread.sleep(2000);} catch (InterruptedException e) {throw new RuntimeException();} // // SpringApplication.exit(appContext, () -> 0); // } // // } // Path: trampoline/src/main/java/org/ernest/applications/trampoline/controller/TrampolineManagerController.java import org.ernest.applications.trampoline.services.TrampolineManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestMapping; package org.ernest.applications.trampoline.controller; @Component @RequestMapping("/trampoline") public class TrampolineManagerController { @Autowired
TrampolineManager trampolineManager;
ErnestOrt/Trampoline
trampoline/src/main/java/org/ernest/applications/trampoline/entities/Instance.java
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/SanitizeActuatorPrefix.java // public class SanitizeActuatorPrefix { // public static String clean(String actuatorPrefix){ // return actuatorPrefix.replaceFirst("^/",""); // } // }
import org.ernest.applications.trampoline.utils.SanitizeActuatorPrefix;
} public void setId(String id) { this.id = id; } public String getIp() { return ip; } public void setIp(String ip) { this.ip = ip; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPomLocation() { return pomLocation; } public void setPomLocation(String pomLocation) { this.pomLocation = pomLocation; } public String getPort() { return port; } public void setPort(String port) { this.port = port; } public String getActuatorPrefix() {
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/SanitizeActuatorPrefix.java // public class SanitizeActuatorPrefix { // public static String clean(String actuatorPrefix){ // return actuatorPrefix.replaceFirst("^/",""); // } // } // Path: trampoline/src/main/java/org/ernest/applications/trampoline/entities/Instance.java import org.ernest.applications.trampoline.utils.SanitizeActuatorPrefix; } public void setId(String id) { this.id = id; } public String getIp() { return ip; } public void setIp(String ip) { this.ip = ip; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPomLocation() { return pomLocation; } public void setPomLocation(String pomLocation) { this.pomLocation = pomLocation; } public String getPort() { return port; } public void setPort(String port) { this.port = port; } public String getActuatorPrefix() {
return SanitizeActuatorPrefix.clean(actuatorPrefix);
ErnestOrt/Trampoline
trampoline/src/test/java/org/ernest/EncryptServiceTest.java
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/services/EncryptService.java // @Service // public class EncryptService { // // private StandardPBEStringEncryptor standardPBEStringEncryptor; // // @PostConstruct // public void initializeEncrypt(){ // standardPBEStringEncryptor = new StandardPBEStringEncryptor(); // standardPBEStringEncryptor.setPassword("s32rwnj2341mWDaqw12"); // } // // // public String encrypt(String value){ // return standardPBEStringEncryptor.encrypt(value); // } // // public String decrypt(String value) { // return standardPBEStringEncryptor.decrypt(value); // } // }
import org.ernest.applications.trampoline.services.EncryptService; import org.junit.Assert; import org.junit.Test; import java.util.UUID;
package org.ernest; public class EncryptServiceTest { @Test public void givenValueWhenEncryptAndDecryptThenSameValueIsObtained() throws Exception { String value = UUID.randomUUID().toString();
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/services/EncryptService.java // @Service // public class EncryptService { // // private StandardPBEStringEncryptor standardPBEStringEncryptor; // // @PostConstruct // public void initializeEncrypt(){ // standardPBEStringEncryptor = new StandardPBEStringEncryptor(); // standardPBEStringEncryptor.setPassword("s32rwnj2341mWDaqw12"); // } // // // public String encrypt(String value){ // return standardPBEStringEncryptor.encrypt(value); // } // // public String decrypt(String value) { // return standardPBEStringEncryptor.decrypt(value); // } // } // Path: trampoline/src/test/java/org/ernest/EncryptServiceTest.java import org.ernest.applications.trampoline.services.EncryptService; import org.junit.Assert; import org.junit.Test; import java.util.UUID; package org.ernest; public class EncryptServiceTest { @Test public void givenValueWhenEncryptAndDecryptThenSameValueIsObtained() throws Exception { String value = UUID.randomUUID().toString();
EncryptService encryptService = new EncryptService();
ErnestOrt/Trampoline
trampoline/src/main/java/org/ernest/applications/trampoline/entities/Microservice.java
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/SanitizeActuatorPrefix.java // public class SanitizeActuatorPrefix { // public static String clean(String actuatorPrefix){ // return actuatorPrefix.replaceFirst("^/",""); // } // }
import org.ernest.applications.trampoline.utils.SanitizeActuatorPrefix;
private String actuatorPrefix; private String vmArguments; private BuildTools buildTool; private Float version; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPomLocation() { return pomLocation; } public void setPomLocation(String pomLocation) { this.pomLocation = pomLocation; } public String getDefaultPort() { return defaultPort; } public void setDefaultPort(String defaultPort) { this.defaultPort = defaultPort; } public String getActuatorPrefix() {
// Path: trampoline/src/main/java/org/ernest/applications/trampoline/utils/SanitizeActuatorPrefix.java // public class SanitizeActuatorPrefix { // public static String clean(String actuatorPrefix){ // return actuatorPrefix.replaceFirst("^/",""); // } // } // Path: trampoline/src/main/java/org/ernest/applications/trampoline/entities/Microservice.java import org.ernest.applications.trampoline.utils.SanitizeActuatorPrefix; private String actuatorPrefix; private String vmArguments; private BuildTools buildTool; private Float version; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPomLocation() { return pomLocation; } public void setPomLocation(String pomLocation) { this.pomLocation = pomLocation; } public String getDefaultPort() { return defaultPort; } public void setDefaultPort(String defaultPort) { this.defaultPort = defaultPort; } public String getActuatorPrefix() {
return SanitizeActuatorPrefix.clean(actuatorPrefix);
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/ConfigManager.java
// Path: core/src/main/java/net/licks92/wirelessredstone/storage/StorageType.java // public enum StorageType { // SQLITE, YAML // }
import net.licks92.wirelessredstone.storage.StorageType; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.util.FileUtil; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Objects;
while ((read = input.read(buffer)) != -1) { output.write(buffer, 0, read); } } /* Save the config. * Very imported if something has changed. */ public void save() { try { config.save(file); } catch (final Exception ex) { ex.printStackTrace(); } } public void copyDefaults(){ if (config == null) return; config.options().copyHeader(true); config.options().copyDefaults(true); } public void update(String channelFolder) { switch (getConfigVersion()) { case 1: { File channelFolderFile = new File(WirelessRedstone.getInstance().getDataFolder(), channelFolder); channelFolderFile.mkdir();
// Path: core/src/main/java/net/licks92/wirelessredstone/storage/StorageType.java // public enum StorageType { // SQLITE, YAML // } // Path: core/src/main/java/net/licks92/wirelessredstone/ConfigManager.java import net.licks92.wirelessredstone.storage.StorageType; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.util.FileUtil; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Objects; while ((read = input.read(buffer)) != -1) { output.write(buffer, 0, read); } } /* Save the config. * Very imported if something has changed. */ public void save() { try { config.save(file); } catch (final Exception ex) { ex.printStackTrace(); } } public void copyDefaults(){ if (config == null) return; config.options().copyHeader(true); config.options().copyDefaults(true); } public void update(String channelFolder) { switch (getConfigVersion()) { case 1: { File channelFolderFile = new File(WirelessRedstone.getInstance().getDataFolder(), channelFolder); channelFolderFile.mkdir();
if (getStorageType() == StorageType.SQLITE
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/MaterialLib.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java // public enum CrossMaterial { // // AIR( // sinceRelease("AIR") // ), // // COMPARATOR( // until("REDSTONE_COMPARATOR", ServerVersion.V1_12_2), // since("COMPARATOR", ServerVersion.V1_13) // ), // // COMPARATOR_OFF( // until("REDSTONE_COMPARATOR_OFF", ServerVersion.V1_12_2) // ), // // COMPARATOR_ON( // until("REDSTONE_COMPARATOR_ON", ServerVersion.V1_12_2) // ), // // REDSTONE_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_TORCH", ServerVersion.V1_13) // ), // // REDSTONE_WALL_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) // ), // // REPEATER( // until("DIODE", ServerVersion.V1_12_2), // since("REPEATER", ServerVersion.V1_13) // ), // // REPEATER_OFF( // until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) // ), // // REPEATER_ON( // until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) // ), // // SIGN( // until("SIGN_POST", ServerVersion.V1_12_2), // between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), // since("OAK_SIGN", ServerVersion.V1_14) // ), // // WALL_SIGN( // until("WALL_SIGN", ServerVersion.V1_13_2), // since("OAK_WALL_SIGN", ServerVersion.V1_14) // ); // // private static boolean initialized; // // private final List<CrossMaterialVersion> versions; // private MaterialHandler handle; // // CrossMaterial(CrossMaterialVersion... versions) { // if (versions.length == 0) { // throw new IllegalArgumentException("No versions for material " + name()); // } // this.versions = Arrays.asList(versions); // } // // public List<CrossMaterialVersion> getVersions() { // return Collections.unmodifiableList(versions); // } // // public Optional<CrossMaterialVersion> getMostSuitableVersion(ServerVersion version) { // for (CrossMaterialVersion candidate : Lists.reverse(versions)) { // if (candidate.getValidVersions().isBetweenBounds(version)) { // return Optional.of(candidate); // } // } // return Optional.empty(); // } // // public Optional<MaterialHandler> getHandle() { // return Optional.ofNullable(handle); // } // // public boolean equals(Material material) { // return getHandle().map(handle -> handle.getType() == material).orElse(false); // } // // public Block setMaterial(Block block) { // return getHandle().map(handle -> handle.setMaterial(block, true)).orElseThrow(IllegalStateException::new); // } // // public Block setMaterial(Block block, boolean applyPhysics) { // return getHandle().map(handle -> handle.setMaterial(block, applyPhysics)).orElseThrow(IllegalStateException::new); // } // // public static Collection<CrossMaterial> getMaterials() { // return Collections.unmodifiableList(Arrays.asList(values())); // } // // public static void initialize(ServerVersion serverVersion) { // if (initialized) { // throw new IllegalStateException("Already initialized!"); // } // initialized = true; // for (CrossMaterial material : values()) { // material.getMostSuitableVersion(serverVersion) // .ifPresent(version -> { // String[] query = version.getName().split(":", 2); // Material type = Material.getMaterial(query[0].toUpperCase()); // if (type == null) { // throw new IllegalStateException("Unable to find expected material " + material.name()); // } // Byte data = null; // if (query.length == 2) { // if (serverVersion.isNewerOrSame(ServerVersion.V1_13)) { // throw new IllegalStateException("Can't use material data in >= 1.13"); // } // data = (byte) Integer.parseInt(query[1]); // } // material.handle = new MaterialHandler(type, data); // }); // } // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java // public class ServerService { // private final Logger logger; // private final Server server; // private ServerVersion serverVersion; // // public ServerService(Logger logger, Server server) { // this.logger = logger; // this.server = server; // } // // public ServerVersion getVersion() { // if (serverVersion != null) { // return serverVersion; // } // String versionString = "V" + server.getBukkitVersion().split("-", 2)[0].replace(".", "_"); // try { // serverVersion = ServerVersion.valueOf(versionString); // } catch (IllegalArgumentException e) { // logger.warning("Unknown server version " + versionString + ", assuming newer than " + ServerVersion.getLastKnown()); // serverVersion = ServerVersion.NEWER; // } // return serverVersion; // } // }
import net.licks92.wirelessredstone.materiallib.data.CrossMaterial; import net.licks92.wirelessredstone.materiallib.services.ServerService; import org.bukkit.plugin.Plugin; import java.util.logging.Logger;
package net.licks92.wirelessredstone.materiallib; public class MaterialLib { private final Plugin plugin; private final Logger logger;
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java // public enum CrossMaterial { // // AIR( // sinceRelease("AIR") // ), // // COMPARATOR( // until("REDSTONE_COMPARATOR", ServerVersion.V1_12_2), // since("COMPARATOR", ServerVersion.V1_13) // ), // // COMPARATOR_OFF( // until("REDSTONE_COMPARATOR_OFF", ServerVersion.V1_12_2) // ), // // COMPARATOR_ON( // until("REDSTONE_COMPARATOR_ON", ServerVersion.V1_12_2) // ), // // REDSTONE_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_TORCH", ServerVersion.V1_13) // ), // // REDSTONE_WALL_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) // ), // // REPEATER( // until("DIODE", ServerVersion.V1_12_2), // since("REPEATER", ServerVersion.V1_13) // ), // // REPEATER_OFF( // until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) // ), // // REPEATER_ON( // until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) // ), // // SIGN( // until("SIGN_POST", ServerVersion.V1_12_2), // between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), // since("OAK_SIGN", ServerVersion.V1_14) // ), // // WALL_SIGN( // until("WALL_SIGN", ServerVersion.V1_13_2), // since("OAK_WALL_SIGN", ServerVersion.V1_14) // ); // // private static boolean initialized; // // private final List<CrossMaterialVersion> versions; // private MaterialHandler handle; // // CrossMaterial(CrossMaterialVersion... versions) { // if (versions.length == 0) { // throw new IllegalArgumentException("No versions for material " + name()); // } // this.versions = Arrays.asList(versions); // } // // public List<CrossMaterialVersion> getVersions() { // return Collections.unmodifiableList(versions); // } // // public Optional<CrossMaterialVersion> getMostSuitableVersion(ServerVersion version) { // for (CrossMaterialVersion candidate : Lists.reverse(versions)) { // if (candidate.getValidVersions().isBetweenBounds(version)) { // return Optional.of(candidate); // } // } // return Optional.empty(); // } // // public Optional<MaterialHandler> getHandle() { // return Optional.ofNullable(handle); // } // // public boolean equals(Material material) { // return getHandle().map(handle -> handle.getType() == material).orElse(false); // } // // public Block setMaterial(Block block) { // return getHandle().map(handle -> handle.setMaterial(block, true)).orElseThrow(IllegalStateException::new); // } // // public Block setMaterial(Block block, boolean applyPhysics) { // return getHandle().map(handle -> handle.setMaterial(block, applyPhysics)).orElseThrow(IllegalStateException::new); // } // // public static Collection<CrossMaterial> getMaterials() { // return Collections.unmodifiableList(Arrays.asList(values())); // } // // public static void initialize(ServerVersion serverVersion) { // if (initialized) { // throw new IllegalStateException("Already initialized!"); // } // initialized = true; // for (CrossMaterial material : values()) { // material.getMostSuitableVersion(serverVersion) // .ifPresent(version -> { // String[] query = version.getName().split(":", 2); // Material type = Material.getMaterial(query[0].toUpperCase()); // if (type == null) { // throw new IllegalStateException("Unable to find expected material " + material.name()); // } // Byte data = null; // if (query.length == 2) { // if (serverVersion.isNewerOrSame(ServerVersion.V1_13)) { // throw new IllegalStateException("Can't use material data in >= 1.13"); // } // data = (byte) Integer.parseInt(query[1]); // } // material.handle = new MaterialHandler(type, data); // }); // } // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java // public class ServerService { // private final Logger logger; // private final Server server; // private ServerVersion serverVersion; // // public ServerService(Logger logger, Server server) { // this.logger = logger; // this.server = server; // } // // public ServerVersion getVersion() { // if (serverVersion != null) { // return serverVersion; // } // String versionString = "V" + server.getBukkitVersion().split("-", 2)[0].replace(".", "_"); // try { // serverVersion = ServerVersion.valueOf(versionString); // } catch (IllegalArgumentException e) { // logger.warning("Unknown server version " + versionString + ", assuming newer than " + ServerVersion.getLastKnown()); // serverVersion = ServerVersion.NEWER; // } // return serverVersion; // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/MaterialLib.java import net.licks92.wirelessredstone.materiallib.data.CrossMaterial; import net.licks92.wirelessredstone.materiallib.services.ServerService; import org.bukkit.plugin.Plugin; import java.util.logging.Logger; package net.licks92.wirelessredstone.materiallib; public class MaterialLib { private final Plugin plugin; private final Logger logger;
private ServerService serverService;
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/MaterialLib.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java // public enum CrossMaterial { // // AIR( // sinceRelease("AIR") // ), // // COMPARATOR( // until("REDSTONE_COMPARATOR", ServerVersion.V1_12_2), // since("COMPARATOR", ServerVersion.V1_13) // ), // // COMPARATOR_OFF( // until("REDSTONE_COMPARATOR_OFF", ServerVersion.V1_12_2) // ), // // COMPARATOR_ON( // until("REDSTONE_COMPARATOR_ON", ServerVersion.V1_12_2) // ), // // REDSTONE_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_TORCH", ServerVersion.V1_13) // ), // // REDSTONE_WALL_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) // ), // // REPEATER( // until("DIODE", ServerVersion.V1_12_2), // since("REPEATER", ServerVersion.V1_13) // ), // // REPEATER_OFF( // until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) // ), // // REPEATER_ON( // until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) // ), // // SIGN( // until("SIGN_POST", ServerVersion.V1_12_2), // between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), // since("OAK_SIGN", ServerVersion.V1_14) // ), // // WALL_SIGN( // until("WALL_SIGN", ServerVersion.V1_13_2), // since("OAK_WALL_SIGN", ServerVersion.V1_14) // ); // // private static boolean initialized; // // private final List<CrossMaterialVersion> versions; // private MaterialHandler handle; // // CrossMaterial(CrossMaterialVersion... versions) { // if (versions.length == 0) { // throw new IllegalArgumentException("No versions for material " + name()); // } // this.versions = Arrays.asList(versions); // } // // public List<CrossMaterialVersion> getVersions() { // return Collections.unmodifiableList(versions); // } // // public Optional<CrossMaterialVersion> getMostSuitableVersion(ServerVersion version) { // for (CrossMaterialVersion candidate : Lists.reverse(versions)) { // if (candidate.getValidVersions().isBetweenBounds(version)) { // return Optional.of(candidate); // } // } // return Optional.empty(); // } // // public Optional<MaterialHandler> getHandle() { // return Optional.ofNullable(handle); // } // // public boolean equals(Material material) { // return getHandle().map(handle -> handle.getType() == material).orElse(false); // } // // public Block setMaterial(Block block) { // return getHandle().map(handle -> handle.setMaterial(block, true)).orElseThrow(IllegalStateException::new); // } // // public Block setMaterial(Block block, boolean applyPhysics) { // return getHandle().map(handle -> handle.setMaterial(block, applyPhysics)).orElseThrow(IllegalStateException::new); // } // // public static Collection<CrossMaterial> getMaterials() { // return Collections.unmodifiableList(Arrays.asList(values())); // } // // public static void initialize(ServerVersion serverVersion) { // if (initialized) { // throw new IllegalStateException("Already initialized!"); // } // initialized = true; // for (CrossMaterial material : values()) { // material.getMostSuitableVersion(serverVersion) // .ifPresent(version -> { // String[] query = version.getName().split(":", 2); // Material type = Material.getMaterial(query[0].toUpperCase()); // if (type == null) { // throw new IllegalStateException("Unable to find expected material " + material.name()); // } // Byte data = null; // if (query.length == 2) { // if (serverVersion.isNewerOrSame(ServerVersion.V1_13)) { // throw new IllegalStateException("Can't use material data in >= 1.13"); // } // data = (byte) Integer.parseInt(query[1]); // } // material.handle = new MaterialHandler(type, data); // }); // } // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java // public class ServerService { // private final Logger logger; // private final Server server; // private ServerVersion serverVersion; // // public ServerService(Logger logger, Server server) { // this.logger = logger; // this.server = server; // } // // public ServerVersion getVersion() { // if (serverVersion != null) { // return serverVersion; // } // String versionString = "V" + server.getBukkitVersion().split("-", 2)[0].replace(".", "_"); // try { // serverVersion = ServerVersion.valueOf(versionString); // } catch (IllegalArgumentException e) { // logger.warning("Unknown server version " + versionString + ", assuming newer than " + ServerVersion.getLastKnown()); // serverVersion = ServerVersion.NEWER; // } // return serverVersion; // } // }
import net.licks92.wirelessredstone.materiallib.data.CrossMaterial; import net.licks92.wirelessredstone.materiallib.services.ServerService; import org.bukkit.plugin.Plugin; import java.util.logging.Logger;
package net.licks92.wirelessredstone.materiallib; public class MaterialLib { private final Plugin plugin; private final Logger logger; private ServerService serverService; public MaterialLib(Plugin plugin) { this.plugin = plugin; this.logger = plugin.getLogger(); this.serverService = new ServerService(logger, plugin.getServer()); } public void initialize() {
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java // public enum CrossMaterial { // // AIR( // sinceRelease("AIR") // ), // // COMPARATOR( // until("REDSTONE_COMPARATOR", ServerVersion.V1_12_2), // since("COMPARATOR", ServerVersion.V1_13) // ), // // COMPARATOR_OFF( // until("REDSTONE_COMPARATOR_OFF", ServerVersion.V1_12_2) // ), // // COMPARATOR_ON( // until("REDSTONE_COMPARATOR_ON", ServerVersion.V1_12_2) // ), // // REDSTONE_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_TORCH", ServerVersion.V1_13) // ), // // REDSTONE_WALL_TORCH( // until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), // since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) // ), // // REPEATER( // until("DIODE", ServerVersion.V1_12_2), // since("REPEATER", ServerVersion.V1_13) // ), // // REPEATER_OFF( // until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) // ), // // REPEATER_ON( // until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) // ), // // SIGN( // until("SIGN_POST", ServerVersion.V1_12_2), // between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), // since("OAK_SIGN", ServerVersion.V1_14) // ), // // WALL_SIGN( // until("WALL_SIGN", ServerVersion.V1_13_2), // since("OAK_WALL_SIGN", ServerVersion.V1_14) // ); // // private static boolean initialized; // // private final List<CrossMaterialVersion> versions; // private MaterialHandler handle; // // CrossMaterial(CrossMaterialVersion... versions) { // if (versions.length == 0) { // throw new IllegalArgumentException("No versions for material " + name()); // } // this.versions = Arrays.asList(versions); // } // // public List<CrossMaterialVersion> getVersions() { // return Collections.unmodifiableList(versions); // } // // public Optional<CrossMaterialVersion> getMostSuitableVersion(ServerVersion version) { // for (CrossMaterialVersion candidate : Lists.reverse(versions)) { // if (candidate.getValidVersions().isBetweenBounds(version)) { // return Optional.of(candidate); // } // } // return Optional.empty(); // } // // public Optional<MaterialHandler> getHandle() { // return Optional.ofNullable(handle); // } // // public boolean equals(Material material) { // return getHandle().map(handle -> handle.getType() == material).orElse(false); // } // // public Block setMaterial(Block block) { // return getHandle().map(handle -> handle.setMaterial(block, true)).orElseThrow(IllegalStateException::new); // } // // public Block setMaterial(Block block, boolean applyPhysics) { // return getHandle().map(handle -> handle.setMaterial(block, applyPhysics)).orElseThrow(IllegalStateException::new); // } // // public static Collection<CrossMaterial> getMaterials() { // return Collections.unmodifiableList(Arrays.asList(values())); // } // // public static void initialize(ServerVersion serverVersion) { // if (initialized) { // throw new IllegalStateException("Already initialized!"); // } // initialized = true; // for (CrossMaterial material : values()) { // material.getMostSuitableVersion(serverVersion) // .ifPresent(version -> { // String[] query = version.getName().split(":", 2); // Material type = Material.getMaterial(query[0].toUpperCase()); // if (type == null) { // throw new IllegalStateException("Unable to find expected material " + material.name()); // } // Byte data = null; // if (query.length == 2) { // if (serverVersion.isNewerOrSame(ServerVersion.V1_13)) { // throw new IllegalStateException("Can't use material data in >= 1.13"); // } // data = (byte) Integer.parseInt(query[1]); // } // material.handle = new MaterialHandler(type, data); // }); // } // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java // public class ServerService { // private final Logger logger; // private final Server server; // private ServerVersion serverVersion; // // public ServerService(Logger logger, Server server) { // this.logger = logger; // this.server = server; // } // // public ServerVersion getVersion() { // if (serverVersion != null) { // return serverVersion; // } // String versionString = "V" + server.getBukkitVersion().split("-", 2)[0].replace(".", "_"); // try { // serverVersion = ServerVersion.valueOf(versionString); // } catch (IllegalArgumentException e) { // logger.warning("Unknown server version " + versionString + ", assuming newer than " + ServerVersion.getLastKnown()); // serverVersion = ServerVersion.NEWER; // } // return serverVersion; // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/MaterialLib.java import net.licks92.wirelessredstone.materiallib.data.CrossMaterial; import net.licks92.wirelessredstone.materiallib.services.ServerService; import org.bukkit.plugin.Plugin; import java.util.logging.Logger; package net.licks92.wirelessredstone.materiallib; public class MaterialLib { private final Plugin plugin; private final Logger logger; private ServerService serverService; public MaterialLib(Plugin plugin) { this.plugin = plugin; this.logger = plugin.getLogger(); this.serverService = new ServerService(logger, plugin.getServer()); } public void initialize() {
CrossMaterial.initialize(serverService.getVersion());
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // }
import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Server; import java.util.logging.Logger;
package net.licks92.wirelessredstone.materiallib.services; public class ServerService { private final Logger logger; private final Server server;
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/services/ServerService.java import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Server; import java.util.logging.Logger; package net.licks92.wirelessredstone.materiallib.services; public class ServerService { private final Logger logger; private final Server server;
private ServerVersion serverVersion;
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersionInterval.java // public class ServerVersionInterval { // private final ServerVersion lowBound; // private final ServerVersion highBound; // // private ServerVersionInterval(ServerVersion lowBound, ServerVersion highBound) { // if (lowBound == null && highBound == null) { // throw new IllegalArgumentException("Both lowBound and highBound can't be null at the same time!"); // } // if (lowBound == null) { // lowBound = ServerVersion.OLDER; // } // if (highBound == null) { // highBound = ServerVersion.NEWER; // } // if (lowBound.getOrder() > highBound.getOrder()) { // throw new IllegalArgumentException("The lowBound can't be higher than the highBound!"); // } // this.lowBound = lowBound; // this.highBound = highBound; // } // // public ServerVersion getLowBound() { // return lowBound; // } // // public ServerVersion getHighBound() { // return highBound; // } // // public boolean isBetweenBounds(ServerVersion version) { // return version.isBetween(lowBound, highBound); // } // // public static ServerVersionInterval since(ServerVersion version) { // return new ServerVersionInterval(version, null); // } // // public static ServerVersionInterval until(ServerVersion version) { // return new ServerVersionInterval(null, version); // } // // public static ServerVersionInterval between(ServerVersion lowBound, ServerVersion highBound) { // return new ServerVersionInterval(lowBound, highBound); // } // }
import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersionInterval;
package net.licks92.wirelessredstone.materiallib.data; public class CrossMaterialVersion { private final String name;
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersionInterval.java // public class ServerVersionInterval { // private final ServerVersion lowBound; // private final ServerVersion highBound; // // private ServerVersionInterval(ServerVersion lowBound, ServerVersion highBound) { // if (lowBound == null && highBound == null) { // throw new IllegalArgumentException("Both lowBound and highBound can't be null at the same time!"); // } // if (lowBound == null) { // lowBound = ServerVersion.OLDER; // } // if (highBound == null) { // highBound = ServerVersion.NEWER; // } // if (lowBound.getOrder() > highBound.getOrder()) { // throw new IllegalArgumentException("The lowBound can't be higher than the highBound!"); // } // this.lowBound = lowBound; // this.highBound = highBound; // } // // public ServerVersion getLowBound() { // return lowBound; // } // // public ServerVersion getHighBound() { // return highBound; // } // // public boolean isBetweenBounds(ServerVersion version) { // return version.isBetween(lowBound, highBound); // } // // public static ServerVersionInterval since(ServerVersion version) { // return new ServerVersionInterval(version, null); // } // // public static ServerVersionInterval until(ServerVersion version) { // return new ServerVersionInterval(null, version); // } // // public static ServerVersionInterval between(ServerVersion lowBound, ServerVersion highBound) { // return new ServerVersionInterval(lowBound, highBound); // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersionInterval; package net.licks92.wirelessredstone.materiallib.data; public class CrossMaterialVersion { private final String name;
private final ServerVersionInterval validVersions;
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersionInterval.java // public class ServerVersionInterval { // private final ServerVersion lowBound; // private final ServerVersion highBound; // // private ServerVersionInterval(ServerVersion lowBound, ServerVersion highBound) { // if (lowBound == null && highBound == null) { // throw new IllegalArgumentException("Both lowBound and highBound can't be null at the same time!"); // } // if (lowBound == null) { // lowBound = ServerVersion.OLDER; // } // if (highBound == null) { // highBound = ServerVersion.NEWER; // } // if (lowBound.getOrder() > highBound.getOrder()) { // throw new IllegalArgumentException("The lowBound can't be higher than the highBound!"); // } // this.lowBound = lowBound; // this.highBound = highBound; // } // // public ServerVersion getLowBound() { // return lowBound; // } // // public ServerVersion getHighBound() { // return highBound; // } // // public boolean isBetweenBounds(ServerVersion version) { // return version.isBetween(lowBound, highBound); // } // // public static ServerVersionInterval since(ServerVersion version) { // return new ServerVersionInterval(version, null); // } // // public static ServerVersionInterval until(ServerVersion version) { // return new ServerVersionInterval(null, version); // } // // public static ServerVersionInterval between(ServerVersion lowBound, ServerVersion highBound) { // return new ServerVersionInterval(lowBound, highBound); // } // }
import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersionInterval;
package net.licks92.wirelessredstone.materiallib.data; public class CrossMaterialVersion { private final String name; private final ServerVersionInterval validVersions; private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { this.name = name; this.validVersions = validVersions; } public String getName() { return name; } public ServerVersionInterval getValidVersions() { return validVersions; } public static CrossMaterialVersion sinceRelease(String name) {
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersionInterval.java // public class ServerVersionInterval { // private final ServerVersion lowBound; // private final ServerVersion highBound; // // private ServerVersionInterval(ServerVersion lowBound, ServerVersion highBound) { // if (lowBound == null && highBound == null) { // throw new IllegalArgumentException("Both lowBound and highBound can't be null at the same time!"); // } // if (lowBound == null) { // lowBound = ServerVersion.OLDER; // } // if (highBound == null) { // highBound = ServerVersion.NEWER; // } // if (lowBound.getOrder() > highBound.getOrder()) { // throw new IllegalArgumentException("The lowBound can't be higher than the highBound!"); // } // this.lowBound = lowBound; // this.highBound = highBound; // } // // public ServerVersion getLowBound() { // return lowBound; // } // // public ServerVersion getHighBound() { // return highBound; // } // // public boolean isBetweenBounds(ServerVersion version) { // return version.isBetween(lowBound, highBound); // } // // public static ServerVersionInterval since(ServerVersion version) { // return new ServerVersionInterval(version, null); // } // // public static ServerVersionInterval until(ServerVersion version) { // return new ServerVersionInterval(null, version); // } // // public static ServerVersionInterval between(ServerVersion lowBound, ServerVersion highBound) { // return new ServerVersionInterval(lowBound, highBound); // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersionInterval; package net.licks92.wirelessredstone.materiallib.data; public class CrossMaterialVersion { private final String name; private final ServerVersionInterval validVersions; private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { this.name = name; this.validVersions = validVersions; } public String getName() { return name; } public ServerVersionInterval getValidVersions() { return validVersions; } public static CrossMaterialVersion sinceRelease(String name) {
return since(name, ServerVersion.OLDER);
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java // public class CrossMaterialVersion { // private final String name; // private final ServerVersionInterval validVersions; // // private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { // this.name = name; // this.validVersions = validVersions; // } // // public String getName() { // return name; // } // // public ServerVersionInterval getValidVersions() { // return validVersions; // } // // public static CrossMaterialVersion sinceRelease(String name) { // return since(name, ServerVersion.OLDER); // } // // public static CrossMaterialVersion since(String name, ServerVersion since) { // return new CrossMaterialVersion(name, ServerVersionInterval.since(since)); // } // // public static CrossMaterialVersion until(String name, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.until(until)); // } // // public static CrossMaterialVersion between(String name, ServerVersion since, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.between(since, until)); // } // }
import com.google.common.collect.Lists; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Material; import org.bukkit.block.Block; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import static net.licks92.wirelessredstone.materiallib.data.CrossMaterialVersion.*;
package net.licks92.wirelessredstone.materiallib.data; public enum CrossMaterial { AIR( sinceRelease("AIR") ), COMPARATOR(
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java // public class CrossMaterialVersion { // private final String name; // private final ServerVersionInterval validVersions; // // private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { // this.name = name; // this.validVersions = validVersions; // } // // public String getName() { // return name; // } // // public ServerVersionInterval getValidVersions() { // return validVersions; // } // // public static CrossMaterialVersion sinceRelease(String name) { // return since(name, ServerVersion.OLDER); // } // // public static CrossMaterialVersion since(String name, ServerVersion since) { // return new CrossMaterialVersion(name, ServerVersionInterval.since(since)); // } // // public static CrossMaterialVersion until(String name, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.until(until)); // } // // public static CrossMaterialVersion between(String name, ServerVersion since, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.between(since, until)); // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java import com.google.common.collect.Lists; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Material; import org.bukkit.block.Block; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import static net.licks92.wirelessredstone.materiallib.data.CrossMaterialVersion.*; package net.licks92.wirelessredstone.materiallib.data; public enum CrossMaterial { AIR( sinceRelease("AIR") ), COMPARATOR(
until("REDSTONE_COMPARATOR", ServerVersion.V1_12_2),
WirelessRedstoneGroup/WirelessRedstone
core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java // public class CrossMaterialVersion { // private final String name; // private final ServerVersionInterval validVersions; // // private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { // this.name = name; // this.validVersions = validVersions; // } // // public String getName() { // return name; // } // // public ServerVersionInterval getValidVersions() { // return validVersions; // } // // public static CrossMaterialVersion sinceRelease(String name) { // return since(name, ServerVersion.OLDER); // } // // public static CrossMaterialVersion since(String name, ServerVersion since) { // return new CrossMaterialVersion(name, ServerVersionInterval.since(since)); // } // // public static CrossMaterialVersion until(String name, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.until(until)); // } // // public static CrossMaterialVersion between(String name, ServerVersion since, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.between(since, until)); // } // }
import com.google.common.collect.Lists; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Material; import org.bukkit.block.Block; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import static net.licks92.wirelessredstone.materiallib.data.CrossMaterialVersion.*;
until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) ), REPEATER( until("DIODE", ServerVersion.V1_12_2), since("REPEATER", ServerVersion.V1_13) ), REPEATER_OFF( until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) ), REPEATER_ON( until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) ), SIGN( until("SIGN_POST", ServerVersion.V1_12_2), between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), since("OAK_SIGN", ServerVersion.V1_14) ), WALL_SIGN( until("WALL_SIGN", ServerVersion.V1_13_2), since("OAK_WALL_SIGN", ServerVersion.V1_14) ); private static boolean initialized;
// Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/utilities/ServerVersion.java // public enum ServerVersion { // OLDER, // V1_4_2, V1_4_4, V1_4_5, V1_4_6, V1_4_7, // V1_5, V1_5_1, V1_5_2, // V1_6_1, V1_6_2, V1_6_4, // V1_7_2, V1_7_4, V1_7_5, V1_7_6, V1_7_7, V1_7_8, V1_7_9, V1_7_10, // V1_8, V1_8_1, V1_8_2, V1_8_3, V1_8_4, V1_8_5, V1_8_6, V1_8_7, V1_8_8, V1_8_9, // V1_9, V1_9_1, V1_9_2, V1_9_3, V1_9_4, // V1_10, V1_10_1, V1_10_2, // V1_11, V1_11_1, V1_11_2, // V1_12, V1_12_1, V1_12_2, // V1_13, V1_13_1, V1_13_2, // V1_14, V1_14_1, V1_14_2, V1_14_3, V1_14_4, // NEWER; // // private final String versionNumber; // // ServerVersion() { // this.versionNumber = name().substring(1).replace("_", "."); // } // // public String versionNumber() { // return versionNumber; // } // // public int getOrder() { // if (this == OLDER) { // return -1; // } // if (this == NEWER) { // return Integer.MAX_VALUE; // } // return ordinal(); // } // // public static ServerVersion getLastKnown() { // return values()[values().length - 2]; // } // // public boolean isNewer(ServerVersion other) { // return getOrder() > other.getOrder(); // } // // public boolean isNewerOrSame(ServerVersion other) { // return getOrder() >= other.getOrder(); // } // // public boolean isOlder(ServerVersion other) { // return getOrder() < other.getOrder(); // } // // public boolean isBetween(ServerVersion older, ServerVersion newer) { // return getOrder() >= older.getOrder() && getOrder() <= newer.getOrder(); // } // } // // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterialVersion.java // public class CrossMaterialVersion { // private final String name; // private final ServerVersionInterval validVersions; // // private CrossMaterialVersion(String name, ServerVersionInterval validVersions) { // this.name = name; // this.validVersions = validVersions; // } // // public String getName() { // return name; // } // // public ServerVersionInterval getValidVersions() { // return validVersions; // } // // public static CrossMaterialVersion sinceRelease(String name) { // return since(name, ServerVersion.OLDER); // } // // public static CrossMaterialVersion since(String name, ServerVersion since) { // return new CrossMaterialVersion(name, ServerVersionInterval.since(since)); // } // // public static CrossMaterialVersion until(String name, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.until(until)); // } // // public static CrossMaterialVersion between(String name, ServerVersion since, ServerVersion until) { // return new CrossMaterialVersion(name, ServerVersionInterval.between(since, until)); // } // } // Path: core/src/main/java/net/licks92/wirelessredstone/materiallib/data/CrossMaterial.java import com.google.common.collect.Lists; import net.licks92.wirelessredstone.materiallib.utilities.ServerVersion; import org.bukkit.Material; import org.bukkit.block.Block; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import static net.licks92.wirelessredstone.materiallib.data.CrossMaterialVersion.*; until("REDSTONE_TORCH_ON", ServerVersion.V1_12_2), since("REDSTONE_WALL_TORCH", ServerVersion.V1_13) ), REPEATER( until("DIODE", ServerVersion.V1_12_2), since("REPEATER", ServerVersion.V1_13) ), REPEATER_OFF( until("DIODE_BLOCK_OFF", ServerVersion.V1_12_2) ), REPEATER_ON( until("DIODE_BLOCK_ON", ServerVersion.V1_12_2) ), SIGN( until("SIGN_POST", ServerVersion.V1_12_2), between("SIGN", ServerVersion.V1_13, ServerVersion.V1_13_2), since("OAK_SIGN", ServerVersion.V1_14) ), WALL_SIGN( until("WALL_SIGN", ServerVersion.V1_13_2), since("OAK_WALL_SIGN", ServerVersion.V1_14) ); private static boolean initialized;
private final List<CrossMaterialVersion> versions;
UweTrottmann/thetvdb-java
src/test/java/com/uwetrottmann/thetvdb/TestData.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // }
import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating;
package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7;
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // } // Path: src/test/java/com/uwetrottmann/thetvdb/TestData.java import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating; package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7;
public static final String RATING_TYPE = UserRating.TYPE_SERIES;
UweTrottmann/thetvdb-java
src/test/java/com/uwetrottmann/thetvdb/TestData.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // }
import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating;
package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7; public static final String RATING_TYPE = UserRating.TYPE_SERIES; public static final int RATING_VALUE = 7; // add show that has double episode DVD numbers public static final int SERIES_TVDB_ID_STARGATE = 72449;
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // } // Path: src/test/java/com/uwetrottmann/thetvdb/TestData.java import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating; package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7; public static final String RATING_TYPE = UserRating.TYPE_SERIES; public static final int RATING_VALUE = 7; // add show that has double episode DVD numbers public static final int SERIES_TVDB_ID_STARGATE = 72449;
public static void assertTestSeries(Series series) {
UweTrottmann/thetvdb-java
src/test/java/com/uwetrottmann/thetvdb/TestData.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // }
import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating;
package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7; public static final String RATING_TYPE = UserRating.TYPE_SERIES; public static final int RATING_VALUE = 7; // add show that has double episode DVD numbers public static final int SERIES_TVDB_ID_STARGATE = 72449; public static void assertTestSeries(Series series) { assertThat(series.id).isEqualTo(SERIES_TVDB_ID); assertThat(series.slug).isEqualTo(SERIES_SLUG); assertThat(series.seriesName).isEqualTo(SERIES_NAME); assertThat(series.imdbId).isEqualTo("tt1219024"); assertThat(series.zap2itId).isEqualTo("EP01085588"); assertThat(series.added).isEqualTo("2008-10-17 15:05:50"); // Assert to catch changes to images. assertThat(series.image).isNull(); assertThat(series.poster).matches("posters/.*\\.jpg"); assertThat(series.banner).matches("graphical/.*\\.jpg"); assertThat(series.fanart).matches("fanart/original/.*\\.jpg"); }
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Episode.java // public class Episode { // // public Integer id; // public Integer absoluteNumber; // public Integer airedEpisodeNumber; // public Integer airedSeason; // public Integer airedSeasonID; // public Double dvdEpisodeNumber; // public Integer dvdSeason; // public String episodeName; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // /** ISO 639-1 language codes, like "en". */ // public Translations language; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // public String overview; // // public Integer airsAfterSeason; // public Integer airsBeforeEpisode; // public Integer airsBeforeSeason; // public List<String> directors; // public String dvdChapter; // public String dvdDiscid; // /** Episode image path suffix, like "episodes/83462/398671.jpg". */ // public String filename; // public List<String> guestStars; // public String imdbId; // /** TheTVDB user id. */ // public Integer lastUpdatedBy; // public String productionCode; // /** TheTVDB series id. */ // public Integer seriesId; // public String showUrl; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // public String thumbAdded; // /** TheTVDB user id. */ // public Integer thumbAuthor; // public String thumbWidth; // public String thumbHeight; // public List<String> writers; // // public static class Translations { // public String episodeName; // public String overview; // } // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/Series.java // public class Series { // // /** // * An unsigned integer assigned by our site to the series. It does not change and will always represent the same // * series. Cannot be null. // */ // public Integer id; // public String seriesName; // public List<String> aliases = new ArrayList<>(); // public String slug; // // /** Only set for search results. Points to the poster. */ // public String image; // // public String poster; // /** Image path suffix, like "graphical/83462-g20.jpg". */ // public String banner; // public String fanart; // /** // * A string containing either "Ended" or "Continuing". Can be null. // */ // public String status; // /** ISO 8601 date string, like "2010-09-20". */ // public String firstAired; // public String network; // public String networkId; // /** In minutes. */ // public String runtime; // public List<String> genre = new ArrayList<>(); // public String overview; // /** Time in seconds, like 1430845514. */ // public Long lastUpdated; // /** An English day string, like "Monday". */ // public String airsDayOfWeek; // /** In most cases a AM/PM time string, like "9:00 PM". Good luck with this. */ // public String airsTime; // /** US rating, like "TV-MA". */ // public String rating; // public String imdbId; // public String zap2itId; // /** ISO 8601 date-time string, like "2010-09-20 15:05:50". */ // public String added; // /** TheTVDB user id. */ // public Integer addedBy; // /** Value from 0.0 to 10.0. */ // public Double siteRating; // public Integer siteRatingCount; // // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRating.java // public class UserRating { // public static final int MIN_RATING = 1; // public static final int MAX_RATING = 10; // // public static final String TYPE_BANNER = "banner"; // public static final String TYPE_EPISODE = "episode"; // public static final String TYPE_SERIES = "series"; // // public Integer ratingItemId; // public Integer rating; // public String ratingType; // // @Override // public boolean equals(Object obj) { // return obj != null && // obj instanceof UserRating && // equals(((UserRating) obj).ratingItemId, ratingItemId) && // equals(((UserRating) obj).rating, rating) && // equals(((UserRating) obj).ratingType, ratingType); // } // // protected boolean equals(Object o1, Object o2) { // return (o1 == o2) || // (o1 != null && o1.equals(o2)) || // (o2 != null && o2.equals(o1)); // } // } // Path: src/test/java/com/uwetrottmann/thetvdb/TestData.java import static com.google.common.truth.Truth.assertThat; import com.uwetrottmann.thetvdb.entities.Episode; import com.uwetrottmann.thetvdb.entities.Series; import com.uwetrottmann.thetvdb.entities.UserRating; package com.uwetrottmann.thetvdb; public class TestData { public static final int SERIES_TVDB_ID = 83462; public static final int EPISODE_TVDB_ID = 398671; public static final String SERIES_NAME = "Castle (2009)"; public static final String SERIES_SLUG = "castle-2009"; public static final String LANGUAGE_EN = "en"; public static final int LANGUAGE_EN_ID = 7; public static final String RATING_TYPE = UserRating.TYPE_SERIES; public static final int RATING_VALUE = 7; // add show that has double episode DVD numbers public static final int SERIES_TVDB_ID_STARGATE = 72449; public static void assertTestSeries(Series series) { assertThat(series.id).isEqualTo(SERIES_TVDB_ID); assertThat(series.slug).isEqualTo(SERIES_SLUG); assertThat(series.seriesName).isEqualTo(SERIES_NAME); assertThat(series.imdbId).isEqualTo("tt1219024"); assertThat(series.zap2itId).isEqualTo("EP01085588"); assertThat(series.added).isEqualTo("2008-10-17 15:05:50"); // Assert to catch changes to images. assertThat(series.image).isNull(); assertThat(series.poster).matches("posters/.*\\.jpg"); assertThat(series.banner).matches("graphical/.*\\.jpg"); assertThat(series.fanart).matches("fanart/original/.*\\.jpg"); }
public static void assertBasicEpisode(Episode episode) {
UweTrottmann/thetvdb-java
src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // }
import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user")
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // } // Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user")
Call<UserResponse> user();
UweTrottmann/thetvdb-java
src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // }
import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user") Call<UserResponse> user(); /** * Returns an array of favorite series for a given user, will be a blank array if no favorites exist. */ @GET("/user/favorites")
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // } // Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user") Call<UserResponse> user(); /** * Returns an array of favorite series for a given user, will be a blank array if no favorites exist. */ @GET("/user/favorites")
Call<UserFavoritesResponse> favorites();
UweTrottmann/thetvdb-java
src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // }
import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user") Call<UserResponse> user(); /** * Returns an array of favorite series for a given user, will be a blank array if no favorites exist. */ @GET("/user/favorites") Call<UserFavoritesResponse> favorites(); /** * Deletes the given series ID from the user’s favorite’s list and returns the updated list. */ @DELETE("/user/favorites/{id}") Call<UserFavoritesResponse> deleteFavorite( @Path("id") long id ); /** * Adds the supplied series ID to the user’s favorite’s list and returns the updated list. */ @PUT("/user/favorites/{id}") Call<UserFavoritesResponse> addFavorite( @Path("id") long id ); /** * Returns an array of ratings for the given user. */ @GET("/user/ratings")
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java // public class UserFavoritesResponse { // public UserFavorites data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java // public class UserRatingsQueryParamsRepsonse { // public List<String> data; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java // public class UserRatingsResponse { // public List<UserRating> data; // public Links links; // } // // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java // public class UserResponse { // public User data; // } // Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse; import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse; import com.uwetrottmann.thetvdb.entities.UserRatingsResponse; import com.uwetrottmann.thetvdb.entities.UserResponse; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; package com.uwetrottmann.thetvdb.services; public interface TheTvdbUser { /** * Returns basic information about the currently authenticated user. */ @GET("/user") Call<UserResponse> user(); /** * Returns an array of favorite series for a given user, will be a blank array if no favorites exist. */ @GET("/user/favorites") Call<UserFavoritesResponse> favorites(); /** * Deletes the given series ID from the user’s favorite’s list and returns the updated list. */ @DELETE("/user/favorites/{id}") Call<UserFavoritesResponse> deleteFavorite( @Path("id") long id ); /** * Adds the supplied series ID to the user’s favorite’s list and returns the updated list. */ @PUT("/user/favorites/{id}") Call<UserFavoritesResponse> addFavorite( @Path("id") long id ); /** * Returns an array of ratings for the given user. */ @GET("/user/ratings")
Call<UserRatingsResponse> ratings();