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
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/graph/Undirected.java
// Path: src/main/java/io/github/marioluan/datastructures/multiset/Bag.java // public class Bag<T extends Comparable<T>> implements Iterable<T> { // private static final String CANNOT_BE_NULL_MSG = "item cannot be null"; // private Node<T> head; // private int size; // // /** // * Adds the item to the bag. // * // * @param item to be added // * @throws IllegalArgumentException when item is null // */ // public void add(T item) throws IllegalArgumentException { // if (item == null) // throw new IllegalArgumentException(CANNOT_BE_NULL_MSG); // // Node<T> node = new Node<>(item); // Node<T> next = head; // head = node; // head.next = next; // // if (next != null) // next.prev = head; // // size++; // } // // /** // * Returns whether the bag is empty or not. // * // * @return whether the bag is empty or not // */ // public boolean isEmpty() { // return size == 0; // } // // /** // * Returns the number of items in the bag. // * // * @return number of items in the bag // */ // public int size() { // return size; // } // // @Override // public Iterator<T> iterator() { // return new LinkedListIterator(head); // } // }
import io.github.marioluan.datastructures.multiset.Bag; import java.util.stream.IntStream;
package io.github.marioluan.datastructures.graph; /** * Undirected {@link Graph} implementation using an adjacency-list.<br> * Maintain vertex-indexed array of lists.<br> * <b>Space complexity: E + V</b> */ public class Undirected implements Graph { private final int V; private int E;
// Path: src/main/java/io/github/marioluan/datastructures/multiset/Bag.java // public class Bag<T extends Comparable<T>> implements Iterable<T> { // private static final String CANNOT_BE_NULL_MSG = "item cannot be null"; // private Node<T> head; // private int size; // // /** // * Adds the item to the bag. // * // * @param item to be added // * @throws IllegalArgumentException when item is null // */ // public void add(T item) throws IllegalArgumentException { // if (item == null) // throw new IllegalArgumentException(CANNOT_BE_NULL_MSG); // // Node<T> node = new Node<>(item); // Node<T> next = head; // head = node; // head.next = next; // // if (next != null) // next.prev = head; // // size++; // } // // /** // * Returns whether the bag is empty or not. // * // * @return whether the bag is empty or not // */ // public boolean isEmpty() { // return size == 0; // } // // /** // * Returns the number of items in the bag. // * // * @return number of items in the bag // */ // public int size() { // return size; // } // // @Override // public Iterator<T> iterator() { // return new LinkedListIterator(head); // } // } // Path: src/main/java/io/github/marioluan/datastructures/graph/Undirected.java import io.github.marioluan.datastructures.multiset.Bag; import java.util.stream.IntStream; package io.github.marioluan.datastructures.graph; /** * Undirected {@link Graph} implementation using an adjacency-list.<br> * Maintain vertex-indexed array of lists.<br> * <b>Space complexity: E + V</b> */ public class Undirected implements Graph { private final int V; private int E;
private Bag<Integer>[] adj;
marioluan/java-data-structures
src/test/java/io/github/marioluan/datastructures/graph/DigraphTest.java
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // }
import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import org.junit.Assert; import org.junit.runner.RunWith; import java.util.Random; import java.util.stream.IntStream; import static com.greghaskins.spectrum.Spectrum.*;
}); it("returns the number of vertices", () -> { Assert.assertEquals(V, subject.V()); }); }); describe("#E", () -> { beforeEach(() -> { w = new Random().nextInt(V); v = new Random().nextInt(V); subject.addEdge(v, w); }); it("returns the number of edges", () -> { Assert.assertEquals(1, subject.E()); }); }); describe("#reverse", () -> { describe("when it's empty", () -> { it("does not set any edges", () -> { Digraph reversed = (Digraph) subject.reverse(); Assert.assertEquals(0, reversed.E()); }); }); describe("when it isn't empty", () -> { beforeEach(() -> {
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // } // Path: src/test/java/io/github/marioluan/datastructures/graph/DigraphTest.java import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import org.junit.Assert; import org.junit.runner.RunWith; import java.util.Random; import java.util.stream.IntStream; import static com.greghaskins.spectrum.Spectrum.*; }); it("returns the number of vertices", () -> { Assert.assertEquals(V, subject.V()); }); }); describe("#E", () -> { beforeEach(() -> { w = new Random().nextInt(V); v = new Random().nextInt(V); subject.addEdge(v, w); }); it("returns the number of edges", () -> { Assert.assertEquals(1, subject.E()); }); }); describe("#reverse", () -> { describe("when it's empty", () -> { it("does not set any edges", () -> { Digraph reversed = (Digraph) subject.reverse(); Assert.assertEquals(0, reversed.E()); }); }); describe("when it isn't empty", () -> { beforeEach(() -> {
subject = DigraphGraphFactory.build();
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/graph/search/PathDecorator.java
// Path: src/main/java/io/github/marioluan/datastructures/stack/LinkedList.java // public class LinkedList<T> implements Stack<T> { // // private final class Node { // private T data; // private Node next; // // private Node(T data, Node next) { // this.data = data; // this.next = next; // } // } // // private Node head; // private int n; // // /** // * Constructs an empty stack. // */ // public LinkedList() { // this.head = null; // this.n = 0; // } // // @Override // public boolean isEmpty() { // return n == 0; // } // // @Override // public int size() { // return n; // } // // @Override // public void push(T item) throws IllegalArgumentException { // if (item == null) // throw new IllegalArgumentException("item must not be null"); // // head = new Node(item, head); // n++; // } // // @Override // public T pop() throws NoSuchElementException { // if (isEmpty()) // throw new NoSuchElementException(); // // T data = head.data; // head = head.next; // n--; // // return data; // } // // @Override // public T peek() throws NoSuchElementException { // if (isEmpty()) // throw new NoSuchElementException(); // // return head.data; // } // // @Override // public Iterator<T> iterator() { // return new LinkedListIterator(head); // } // // private final class LinkedListIterator implements Iterator<T> { // // private Node cursor; // // LinkedListIterator(Node cursor) { // this.cursor = cursor; // } // // @Override // public boolean hasNext() { // return cursor != null; // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // // @Override // public T next() { // if (!hasNext()) // throw new NoSuchElementException(); // // T data = cursor.data; // cursor = cursor.next; // // return data; // } // // } // }
import io.github.marioluan.datastructures.stack.LinkedList;
package io.github.marioluan.datastructures.graph.search; /** * Decorator for {@link io.github.marioluan.datastructures.graph.Graph} search algorithms. */ public abstract class PathDecorator extends MarkedDecorator implements Paths { /** * Returns all edges found connecting source vertex to all possible destination vertices. * * @return edges found connecting source vertex to all possible destination vertices */ protected abstract Integer[] getEdgeTo(); @Override public boolean hasPathTo(int v) { return getMarked()[v]; } @Override public Iterable<Integer> pathTo(int v) { // path not found if (!hasPathTo(v)) return null; // makes code more readable
// Path: src/main/java/io/github/marioluan/datastructures/stack/LinkedList.java // public class LinkedList<T> implements Stack<T> { // // private final class Node { // private T data; // private Node next; // // private Node(T data, Node next) { // this.data = data; // this.next = next; // } // } // // private Node head; // private int n; // // /** // * Constructs an empty stack. // */ // public LinkedList() { // this.head = null; // this.n = 0; // } // // @Override // public boolean isEmpty() { // return n == 0; // } // // @Override // public int size() { // return n; // } // // @Override // public void push(T item) throws IllegalArgumentException { // if (item == null) // throw new IllegalArgumentException("item must not be null"); // // head = new Node(item, head); // n++; // } // // @Override // public T pop() throws NoSuchElementException { // if (isEmpty()) // throw new NoSuchElementException(); // // T data = head.data; // head = head.next; // n--; // // return data; // } // // @Override // public T peek() throws NoSuchElementException { // if (isEmpty()) // throw new NoSuchElementException(); // // return head.data; // } // // @Override // public Iterator<T> iterator() { // return new LinkedListIterator(head); // } // // private final class LinkedListIterator implements Iterator<T> { // // private Node cursor; // // LinkedListIterator(Node cursor) { // this.cursor = cursor; // } // // @Override // public boolean hasNext() { // return cursor != null; // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // // @Override // public T next() { // if (!hasNext()) // throw new NoSuchElementException(); // // T data = cursor.data; // cursor = cursor.next; // // return data; // } // // } // } // Path: src/main/java/io/github/marioluan/datastructures/graph/search/PathDecorator.java import io.github.marioluan.datastructures.stack.LinkedList; package io.github.marioluan.datastructures.graph.search; /** * Decorator for {@link io.github.marioluan.datastructures.graph.Graph} search algorithms. */ public abstract class PathDecorator extends MarkedDecorator implements Paths { /** * Returns all edges found connecting source vertex to all possible destination vertices. * * @return edges found connecting source vertex to all possible destination vertices */ protected abstract Integer[] getEdgeTo(); @Override public boolean hasPathTo(int v) { return getMarked()[v]; } @Override public Iterable<Integer> pathTo(int v) { // path not found if (!hasPathTo(v)) return null; // makes code more readable
LinkedList<Integer> path = new LinkedList<>();
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/stack/DynamicArray.java
// Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // }
import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Util; import io.github.marioluan.datastructures.wrappers.Resizable;
package io.github.marioluan.datastructures.stack; /** * {@link Stack} implementation using a generic dynamic array data * structure.<br> * All operations take constant time in the worst case, except the * {@link #iterator} method. * * @author marioluan * @param <T> * the generic type of items from the stack */ public class DynamicArray<T> implements Stack<T> { private static final int DEFAULT_CAPACITY = 2; private T[] array; private int n;
// Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // } // Path: src/main/java/io/github/marioluan/datastructures/stack/DynamicArray.java import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Util; import io.github.marioluan.datastructures.wrappers.Resizable; package io.github.marioluan.datastructures.stack; /** * {@link Stack} implementation using a generic dynamic array data * structure.<br> * All operations take constant time in the worst case, except the * {@link #iterator} method. * * @author marioluan * @param <T> * the generic type of items from the stack */ public class DynamicArray<T> implements Stack<T> { private static final int DEFAULT_CAPACITY = 2; private T[] array; private int n;
private final Resizable<T[]> rs;
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/stack/DynamicArray.java
// Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // }
import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Util; import io.github.marioluan.datastructures.wrappers.Resizable;
// avoids loitering array[--n] = null; // shrink size of array if necessary if (n > 0 && n == array.length / FOUR_TIMES) array = rs.resize(array, n, array.length / TWICE); return item; } @Override public T peek() throws NoSuchElementException { if (isEmpty()) throw new NoSuchElementException(); return array[n - 1]; } @Override public Iterator<T> iterator() { return new ArrayIterator(array); } private final class ArrayIterator implements Iterator<T> { private DynamicArray<T> copy; @SuppressWarnings("unchecked") private ArrayIterator(T[] array) { T[] arrayCopy = (T[]) new Object[n];
// Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // } // Path: src/main/java/io/github/marioluan/datastructures/stack/DynamicArray.java import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Util; import io.github.marioluan.datastructures.wrappers.Resizable; // avoids loitering array[--n] = null; // shrink size of array if necessary if (n > 0 && n == array.length / FOUR_TIMES) array = rs.resize(array, n, array.length / TWICE); return item; } @Override public T peek() throws NoSuchElementException { if (isEmpty()) throw new NoSuchElementException(); return array[n - 1]; } @Override public Iterator<T> iterator() { return new ArrayIterator(array); } private final class ArrayIterator implements Iterator<T> { private DynamicArray<T> copy; @SuppressWarnings("unchecked") private ArrayIterator(T[] array) { T[] arrayCopy = (T[]) new Object[n];
Util.copy(array, arrayCopy, 0, n - 1);
marioluan/java-data-structures
src/test/java/io/github/marioluan/datastructures/graph/search/DepthFirstSearchTest.java
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // } // // Path: src/test/java/io/github/marioluan/datastructures/factory/UndirectedGraphFactory.java // public final class UndirectedGraphFactory { // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://www.coursera.org/learn/algorithms-part2/lecture/mW9aG/depth-first-search</strong> // */ // public static Undirected build() { // Undirected graph = new Undirected(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 2); // graph.addEdge(0, 5); // graph.addEdge(0, 6); // graph.addEdge(6, 4); // graph.addEdge(4, 3); // graph.addEdge(4, 5); // graph.addEdge(3, 5); // // graph.addEdge(7, 8); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // graph.addEdge(9, 12); // graph.addEdge(11, 12); // // return graph; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Undirected.java // public class Undirected implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Undirected(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // adj[w].add(v); // E++; // } // // // time complexity: degree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // return this; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // }
import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import io.github.marioluan.datastructures.factory.UndirectedGraphFactory; import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.graph.Undirected; import org.hamcrest.CoreMatchers; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; import org.junit.runner.RunWith; import static com.greghaskins.spectrum.Spectrum.*;
package io.github.marioluan.datastructures.graph.search; @RunWith(Spectrum.class) public class DepthFirstSearchTest {
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // } // // Path: src/test/java/io/github/marioluan/datastructures/factory/UndirectedGraphFactory.java // public final class UndirectedGraphFactory { // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://www.coursera.org/learn/algorithms-part2/lecture/mW9aG/depth-first-search</strong> // */ // public static Undirected build() { // Undirected graph = new Undirected(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 2); // graph.addEdge(0, 5); // graph.addEdge(0, 6); // graph.addEdge(6, 4); // graph.addEdge(4, 3); // graph.addEdge(4, 5); // graph.addEdge(3, 5); // // graph.addEdge(7, 8); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // graph.addEdge(9, 12); // graph.addEdge(11, 12); // // return graph; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Undirected.java // public class Undirected implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Undirected(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // adj[w].add(v); // E++; // } // // // time complexity: degree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // return this; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // } // Path: src/test/java/io/github/marioluan/datastructures/graph/search/DepthFirstSearchTest.java import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import io.github.marioluan.datastructures.factory.UndirectedGraphFactory; import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.graph.Undirected; import org.hamcrest.CoreMatchers; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; import org.junit.runner.RunWith; import static com.greghaskins.spectrum.Spectrum.*; package io.github.marioluan.datastructures.graph.search; @RunWith(Spectrum.class) public class DepthFirstSearchTest {
private Graph graph;
marioluan/java-data-structures
src/test/java/io/github/marioluan/datastructures/graph/search/DepthFirstSearchTest.java
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // } // // Path: src/test/java/io/github/marioluan/datastructures/factory/UndirectedGraphFactory.java // public final class UndirectedGraphFactory { // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://www.coursera.org/learn/algorithms-part2/lecture/mW9aG/depth-first-search</strong> // */ // public static Undirected build() { // Undirected graph = new Undirected(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 2); // graph.addEdge(0, 5); // graph.addEdge(0, 6); // graph.addEdge(6, 4); // graph.addEdge(4, 3); // graph.addEdge(4, 5); // graph.addEdge(3, 5); // // graph.addEdge(7, 8); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // graph.addEdge(9, 12); // graph.addEdge(11, 12); // // return graph; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Undirected.java // public class Undirected implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Undirected(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // adj[w].add(v); // E++; // } // // // time complexity: degree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // return this; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // }
import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import io.github.marioluan.datastructures.factory.UndirectedGraphFactory; import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.graph.Undirected; import org.hamcrest.CoreMatchers; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; import org.junit.runner.RunWith; import static com.greghaskins.spectrum.Spectrum.*;
package io.github.marioluan.datastructures.graph.search; @RunWith(Spectrum.class) public class DepthFirstSearchTest { private Graph graph; private DepthFirstSearch subject; { describe("DepthFirstSearch", () -> { beforeEach(() -> {
// Path: src/test/java/io/github/marioluan/datastructures/factory/DigraphGraphFactory.java // public final class DigraphGraphFactory { // private DigraphGraphFactory() { // } // // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://algs4.cs.princeton.edu/lectures/42DirectedGraphs.pdf</strong> // */ // public static Digraph build() { // Digraph graph = new Digraph(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 5); // // graph.addEdge(2, 0); // graph.addEdge(2, 3); // // graph.addEdge(3, 2); // graph.addEdge(3, 5); // // graph.addEdge(4, 2); // graph.addEdge(4, 3); // // graph.addEdge(5, 4); // // graph.addEdge(6, 0); // graph.addEdge(6, 9); // graph.addEdge(6, 4); // graph.addEdge(6, 8); // // graph.addEdge(7, 6); // graph.addEdge(7, 9); // // graph.addEdge(8, 6); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // // graph.addEdge(10, 12); // // graph.addEdge(11, 12); // graph.addEdge(11, 4); // // graph.addEdge(12, 9); // // return graph; // } // } // // Path: src/test/java/io/github/marioluan/datastructures/factory/UndirectedGraphFactory.java // public final class UndirectedGraphFactory { // /** // * Builds a graph with the same vertices and edges from lecture slides. <br> // * <strong>https://www.coursera.org/learn/algorithms-part2/lecture/mW9aG/depth-first-search</strong> // */ // public static Undirected build() { // Undirected graph = new Undirected(13); // // graph.addEdge(0, 1); // graph.addEdge(0, 2); // graph.addEdge(0, 5); // graph.addEdge(0, 6); // graph.addEdge(6, 4); // graph.addEdge(4, 3); // graph.addEdge(4, 5); // graph.addEdge(3, 5); // // graph.addEdge(7, 8); // // graph.addEdge(9, 10); // graph.addEdge(9, 11); // graph.addEdge(9, 12); // graph.addEdge(11, 12); // // return graph; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/Undirected.java // public class Undirected implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Undirected(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // adj[w].add(v); // E++; // } // // // time complexity: degree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // return this; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // } // Path: src/test/java/io/github/marioluan/datastructures/graph/search/DepthFirstSearchTest.java import com.greghaskins.spectrum.Spectrum; import io.github.marioluan.datastructures.factory.DigraphGraphFactory; import io.github.marioluan.datastructures.factory.UndirectedGraphFactory; import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.graph.Undirected; import org.hamcrest.CoreMatchers; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; import org.junit.runner.RunWith; import static com.greghaskins.spectrum.Spectrum.*; package io.github.marioluan.datastructures.graph.search; @RunWith(Spectrum.class) public class DepthFirstSearchTest { private Graph graph; private DepthFirstSearch subject; { describe("DepthFirstSearch", () -> { beforeEach(() -> {
graph = new Undirected(13);
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/graph/search/StronglyConnectedComponents.java
// Path: src/main/java/io/github/marioluan/datastructures/graph/Digraph.java // public class Digraph implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Digraph(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // E++; // } // // // time complexity: outdegree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // Digraph reversed = new Digraph(V); // // for (int i = 0; i < V; i++) // for (int s : adj(i)) // reversed.addEdge(s, i); // // return reversed; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/sort/TopologicalSort.java // public class TopologicalSort { // private Graph graph; // private LinkedList<Integer> reversePost; // private boolean[] marked; // // /** // * Performs a DFS and sort graph's vertices in topological order. // * // * @param graph the graph to be sorted // */ // public TopologicalSort(Graph graph) { // // TODO: validate if graph is acyclic (it cannot have cycles) // this.graph = graph; // reversePost = new LinkedList<>(); // marked = new boolean[graph.V()]; // // search(); // } // // /** // * Performs a DFS from each vertex in the graph. // */ // private void search() { // for (int s = 0; s < graph.V(); s++) // // do not traverse the same vertex twice // if (!marked[s]) // search(s); // } // // /** // * Performs a DFS from vertex s to its adjacent vertices. // * // * @param s source vertex // */ // private void search(int s) { // // tell the world, we already visited it // marked[s] = true; // // // go deep into its adjacent vertices // for (int v : graph.adj(s)) // // repeat the same process for its adjacent vertex // // only if we have not done it before // if (!marked[v]) // search(v); // // // when we reached the last adjacent vertex of s // reversePost.push(s); // } // // /** // * Returns the vertices in reverse postorder. // * // * @return the vertices in reverse postorder // */ // public Iterable<Integer> reversePost() { // return reversePost; // } // }
import io.github.marioluan.datastructures.graph.Digraph; import io.github.marioluan.datastructures.graph.sort.TopologicalSort;
package io.github.marioluan.datastructures.graph.search; /** * Implementation of a Strongly-Connected Components data structure using Kosaraju-Sharir algorithm and {@link DepthFirstSearch} (twice). <br> * Goal: given a {@link Digraph directed graph}, finds whether a vertex s is strongly-connected to vertex v. * Applications: * - ecological food webs * -- vertex: species * -- edge: from producer to consumer * -- strong component: subset of species with common energy flow * - software modules * -- vertex: software module * -- edge: from module to dependency * -- strong component: subset of mutually interacting modules * -- approaches: * --- 1. package strong components together * --- 2. use to improve design */ public class StronglyConnectedComponents { private final Digraph graph; private int[] id; private int count; private boolean[] marked; private Iterable<Integer> reversePost; /** * Builds a cluster of strongly-connected components for every source vertex in the {@link Digraph graph}. <br> * Goal: given a {@link Digraph directed graph}, finds whether vertex s is strongly-connected to vertex v in O(1). * Algorithm: * - 1. reverse G® * - 2. run DFS on G® to compute reverse postorder. * - 3. run DFS on G, considering vertices in order given by first DFS. * * @param graph a given graph */ public StronglyConnectedComponents(Digraph graph) { this.graph = graph; marked = new boolean[graph.V()]; id = new int[graph.V()]; // 1 Digraph reversed = (Digraph) graph.reverse(); // 2
// Path: src/main/java/io/github/marioluan/datastructures/graph/Digraph.java // public class Digraph implements Graph { // private final int V; // private int E; // private Bag<Integer>[] adj; // // /** // * Creates an empty {@link Digraph}.<br> // * time complexity: O(V) // * // * @param V number of vertices // */ // public Digraph(int V) { // this.V = V; // adj = (Bag<Integer>[]) new Bag[V]; // IntStream.range(0, V).forEach(v -> adj[v] = new Bag<>()); // E = 0; // } // // // time complexity: O(1) // @Override // public void addEdge(int v, int w) { // adj[v].add(w); // E++; // } // // // time complexity: outdegree(v) // @Override // public Iterable<Integer> adj(int v) { // return adj[v]; // } // // // time complexity: O(1) // @Override // public int V() { // return V; // } // // // time complexity: O(1) // @Override // public int E() { // return E; // } // // @Override // public Graph reverse() { // Digraph reversed = new Digraph(V); // // for (int i = 0; i < V; i++) // for (int s : adj(i)) // reversed.addEdge(s, i); // // return reversed; // } // // // TODO: implement me! // @Override // public String toString() { // return null; // } // } // // Path: src/main/java/io/github/marioluan/datastructures/graph/sort/TopologicalSort.java // public class TopologicalSort { // private Graph graph; // private LinkedList<Integer> reversePost; // private boolean[] marked; // // /** // * Performs a DFS and sort graph's vertices in topological order. // * // * @param graph the graph to be sorted // */ // public TopologicalSort(Graph graph) { // // TODO: validate if graph is acyclic (it cannot have cycles) // this.graph = graph; // reversePost = new LinkedList<>(); // marked = new boolean[graph.V()]; // // search(); // } // // /** // * Performs a DFS from each vertex in the graph. // */ // private void search() { // for (int s = 0; s < graph.V(); s++) // // do not traverse the same vertex twice // if (!marked[s]) // search(s); // } // // /** // * Performs a DFS from vertex s to its adjacent vertices. // * // * @param s source vertex // */ // private void search(int s) { // // tell the world, we already visited it // marked[s] = true; // // // go deep into its adjacent vertices // for (int v : graph.adj(s)) // // repeat the same process for its adjacent vertex // // only if we have not done it before // if (!marked[v]) // search(v); // // // when we reached the last adjacent vertex of s // reversePost.push(s); // } // // /** // * Returns the vertices in reverse postorder. // * // * @return the vertices in reverse postorder // */ // public Iterable<Integer> reversePost() { // return reversePost; // } // } // Path: src/main/java/io/github/marioluan/datastructures/graph/search/StronglyConnectedComponents.java import io.github.marioluan.datastructures.graph.Digraph; import io.github.marioluan.datastructures.graph.sort.TopologicalSort; package io.github.marioluan.datastructures.graph.search; /** * Implementation of a Strongly-Connected Components data structure using Kosaraju-Sharir algorithm and {@link DepthFirstSearch} (twice). <br> * Goal: given a {@link Digraph directed graph}, finds whether a vertex s is strongly-connected to vertex v. * Applications: * - ecological food webs * -- vertex: species * -- edge: from producer to consumer * -- strong component: subset of species with common energy flow * - software modules * -- vertex: software module * -- edge: from module to dependency * -- strong component: subset of mutually interacting modules * -- approaches: * --- 1. package strong components together * --- 2. use to improve design */ public class StronglyConnectedComponents { private final Digraph graph; private int[] id; private int count; private boolean[] marked; private Iterable<Integer> reversePost; /** * Builds a cluster of strongly-connected components for every source vertex in the {@link Digraph graph}. <br> * Goal: given a {@link Digraph directed graph}, finds whether vertex s is strongly-connected to vertex v in O(1). * Algorithm: * - 1. reverse G® * - 2. run DFS on G® to compute reverse postorder. * - 3. run DFS on G, considering vertices in order given by first DFS. * * @param graph a given graph */ public StronglyConnectedComponents(Digraph graph) { this.graph = graph; marked = new boolean[graph.V()]; id = new int[graph.V()]; // 1 Digraph reversed = (Digraph) graph.reverse(); // 2
reversePost = new TopologicalSort(reversed).reversePost();
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/graph/search/BreadthFirstSearch.java
// Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/queue/Deque.java // public class Deque<T extends Comparable<T>> implements Iterable<T> { // // private Node<T> head; // private Node<T> tail; // private int size; // // /** // * Construct an empty deque. // */ // public Deque() { // this.head = null; // this.tail = null; // this.size = 0; // } // // /** // * Is the deque empty? // * // * @return returns if it is empty or not // */ // public boolean isEmpty() { // return this.size == 0; // } // // /** // * Return the number of items on the deque. // * // * @return the size // */ // public int size() { // return this.size; // } // // /** // * Add the {@link T data} to the front.<br> // * <strong>Time complexity:</strong> O(1)<br> // * // * @param data // */ // public void addFirst(T data) { // if (data == null) // throw new NullPointerException(); // // Node<T> oldHead = this.head; // this.head = new Node<T>(data); // this.head.next = oldHead; // // if (oldHead != null) // oldHead.prev = this.head; // // // when the dequeue is empty, head == tail // if (this.isEmpty()) // this.tail = this.head; // // this.size++; // // } // // /** // * Add the {@link T data} to the end.<br> // * <strong>Time complexity:</strong> O(1)<br> // * // * @param data // */ // public void addLast(T data) { // if (data == null) // throw new NullPointerException(); // // Node<T> oldTail = this.tail; // this.tail = new Node<T>(data); // this.tail.prev = oldTail; // // if (oldTail != null) // oldTail.next = this.tail; // // // when the deque is empty, head == tail // if (this.isEmpty()) // this.head = this.tail; // // this.size++; // } // // /** // * Remove and return the data from the front. // * <strong>Time complexity:</strong> O(1)<br> // * // * @return returns the first data // */ // public T removeFirst() { // if (this.isEmpty()) // throw new NoSuchElementException(); // // Node<T> oldHead = this.head; // this.head = this.head.next; // // if (this.head != null) // this.head.prev = null; // // this.size--; // // // when the dequeue becomes empty, head == tail // if (this.isEmpty()) // this.tail = null; // // return oldHead.data; // } // // /** // * Remove and return the data from the end. // * <strong>Time complexity:</strong> O(1)<br> // * // * @return returns the last data // */ // public T removeLast() { // if (this.isEmpty()) // throw new NoSuchElementException(); // // Node<T> oldTail = this.tail; // this.tail = this.tail.prev; // // if (this.tail != null) // this.tail.next = null; // // this.size--; // // // when the dequeue becomes empty, head == tail // if (this.isEmpty()) // this.head = null; // // return oldTail.data; // } // // /** // * Return the iterator over items in order from front to end. // * // * @return returns a new instance // */ // @Override // public Iterator<T> iterator() { // return new LinkedListIterator<T>(this.head); // } // }
import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.queue.Deque;
package io.github.marioluan.datastructures.graph.search; /** * Bread-first search implementation. <br> * Put unvisited vertices on a queue. <br> * Goal: Find path from s to v that uses fewest number of edges. * Category: single-source reachability. */ public class BreadthFirstSearch extends PathDecorator { private final Graph graph; private final int s; private boolean[] marked; private Integer[] edgeTo; private Integer[] disTo; /** * Performs a BFS. * * @param graph the given graph * @param s the source vertex */ public BreadthFirstSearch(Graph graph, int s) { this.graph = graph; this.s = s; marked = new boolean[graph.V()]; edgeTo = new Integer[graph.V()]; disTo = new Integer[graph.V()]; search(); } // Time complexity: O(V + E) private void search() {
// Path: src/main/java/io/github/marioluan/datastructures/graph/Graph.java // public interface Graph { // // /** // * Adds an edge v-w. // * // * @param v vertex v // * @param w vertex w // */ // void addEdge(int v, int w); // // /** // * Returns the vertices adjacent to v. // * // * @param v vertex v // * @return vertices adjacent to v // */ // Iterable<Integer> adj(int v); // // /** // * Returns the number of vertices. // * // * @return number of vertices // */ // int V(); // // /** // * Returns the number of edges. // * // * @return number of edges // */ // int E(); // // /** // * Returns its reverse order. // * // * @return its reverse order // */ // Graph reverse(); // // /** // * Returns its string representation. // * // * @return string representation // */ // String toString(); // } // // Path: src/main/java/io/github/marioluan/datastructures/queue/Deque.java // public class Deque<T extends Comparable<T>> implements Iterable<T> { // // private Node<T> head; // private Node<T> tail; // private int size; // // /** // * Construct an empty deque. // */ // public Deque() { // this.head = null; // this.tail = null; // this.size = 0; // } // // /** // * Is the deque empty? // * // * @return returns if it is empty or not // */ // public boolean isEmpty() { // return this.size == 0; // } // // /** // * Return the number of items on the deque. // * // * @return the size // */ // public int size() { // return this.size; // } // // /** // * Add the {@link T data} to the front.<br> // * <strong>Time complexity:</strong> O(1)<br> // * // * @param data // */ // public void addFirst(T data) { // if (data == null) // throw new NullPointerException(); // // Node<T> oldHead = this.head; // this.head = new Node<T>(data); // this.head.next = oldHead; // // if (oldHead != null) // oldHead.prev = this.head; // // // when the dequeue is empty, head == tail // if (this.isEmpty()) // this.tail = this.head; // // this.size++; // // } // // /** // * Add the {@link T data} to the end.<br> // * <strong>Time complexity:</strong> O(1)<br> // * // * @param data // */ // public void addLast(T data) { // if (data == null) // throw new NullPointerException(); // // Node<T> oldTail = this.tail; // this.tail = new Node<T>(data); // this.tail.prev = oldTail; // // if (oldTail != null) // oldTail.next = this.tail; // // // when the deque is empty, head == tail // if (this.isEmpty()) // this.head = this.tail; // // this.size++; // } // // /** // * Remove and return the data from the front. // * <strong>Time complexity:</strong> O(1)<br> // * // * @return returns the first data // */ // public T removeFirst() { // if (this.isEmpty()) // throw new NoSuchElementException(); // // Node<T> oldHead = this.head; // this.head = this.head.next; // // if (this.head != null) // this.head.prev = null; // // this.size--; // // // when the dequeue becomes empty, head == tail // if (this.isEmpty()) // this.tail = null; // // return oldHead.data; // } // // /** // * Remove and return the data from the end. // * <strong>Time complexity:</strong> O(1)<br> // * // * @return returns the last data // */ // public T removeLast() { // if (this.isEmpty()) // throw new NoSuchElementException(); // // Node<T> oldTail = this.tail; // this.tail = this.tail.prev; // // if (this.tail != null) // this.tail.next = null; // // this.size--; // // // when the dequeue becomes empty, head == tail // if (this.isEmpty()) // this.head = null; // // return oldTail.data; // } // // /** // * Return the iterator over items in order from front to end. // * // * @return returns a new instance // */ // @Override // public Iterator<T> iterator() { // return new LinkedListIterator<T>(this.head); // } // } // Path: src/main/java/io/github/marioluan/datastructures/graph/search/BreadthFirstSearch.java import io.github.marioluan.datastructures.graph.Graph; import io.github.marioluan.datastructures.queue.Deque; package io.github.marioluan.datastructures.graph.search; /** * Bread-first search implementation. <br> * Put unvisited vertices on a queue. <br> * Goal: Find path from s to v that uses fewest number of edges. * Category: single-source reachability. */ public class BreadthFirstSearch extends PathDecorator { private final Graph graph; private final int s; private boolean[] marked; private Integer[] edgeTo; private Integer[] disTo; /** * Performs a BFS. * * @param graph the given graph * @param s the source vertex */ public BreadthFirstSearch(Graph graph, int s) { this.graph = graph; this.s = s; marked = new boolean[graph.V()]; edgeTo = new Integer[graph.V()]; disTo = new Integer[graph.V()]; search(); } // Time complexity: O(V + E) private void search() {
Deque<Integer> queue = new Deque<>();
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/priority/queue/MinUnorderedLinkedListPriorityQueue.java
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // }
import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util;
package io.github.marioluan.datastructures.priority.queue; /** * Priority Queue implementation using an unordered linked list data type. <br> * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class MinUnorderedLinkedListPriorityQueue<T extends Comparable<T>> implements Iterable<T> {
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // Path: src/main/java/io/github/marioluan/datastructures/priority/queue/MinUnorderedLinkedListPriorityQueue.java import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util; package io.github.marioluan.datastructures.priority.queue; /** * Priority Queue implementation using an unordered linked list data type. <br> * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class MinUnorderedLinkedListPriorityQueue<T extends Comparable<T>> implements Iterable<T> {
private Node<T> head;
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/priority/queue/MinUnorderedLinkedListPriorityQueue.java
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // }
import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util;
* @param item */ public void insert(T item) { if (item == null) throw new NullPointerException(); Node<T> oldHead = this.head; this.head = new Node<T>(item); this.head.next = oldHead; if (!this.isEmpty()) oldHead.prev = this.head; this.size++; } /** * Remove and return the smallest item from the priority queue.<br> * <strong>Time complexity:</strong> O(N) * * @return returns the first item */ public T removeMin() { if (this.isEmpty()) throw new NoSuchElementException(); Node<T> min = this.head; Node<T> cursor = this.head; while (cursor != null) {
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // Path: src/main/java/io/github/marioluan/datastructures/priority/queue/MinUnorderedLinkedListPriorityQueue.java import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util; * @param item */ public void insert(T item) { if (item == null) throw new NullPointerException(); Node<T> oldHead = this.head; this.head = new Node<T>(item); this.head.next = oldHead; if (!this.isEmpty()) oldHead.prev = this.head; this.size++; } /** * Remove and return the smallest item from the priority queue.<br> * <strong>Time complexity:</strong> O(N) * * @return returns the first item */ public T removeMin() { if (this.isEmpty()) throw new NoSuchElementException(); Node<T> min = this.head; Node<T> cursor = this.head; while (cursor != null) {
if (Util.less(cursor, min))
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/queue/RandomizedQueue.java
// Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // }
import java.util.Iterator; import java.util.NoSuchElementException; import edu.princeton.cs.algs4.StdRandom; import io.github.marioluan.datastructures.wrappers.Resizable;
package io.github.marioluan.datastructures.queue; /** * Randomized queue implementation using an array. * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class RandomizedQueue<T> implements Iterable<T> { private T[] a; private int n;
// Path: src/main/java/io/github/marioluan/datastructures/wrappers/Resizable.java // public interface Resizable<T> { // // /** // * Resize the underlying object T holding the elements and returns a copy of // * it. // * <strong>Time complexity:</strong> O(n)<br> // * // * @param a // * the array to be resized // * @param n // * the number of elements on the array // * @param capacity // * the new capacity of the array // * @return the resized copy of a // */ // T resize(T a, int n, int capacity); // } // Path: src/main/java/io/github/marioluan/datastructures/queue/RandomizedQueue.java import java.util.Iterator; import java.util.NoSuchElementException; import edu.princeton.cs.algs4.StdRandom; import io.github.marioluan.datastructures.wrappers.Resizable; package io.github.marioluan.datastructures.queue; /** * Randomized queue implementation using an array. * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class RandomizedQueue<T> implements Iterable<T> { private T[] a; private int n;
private final Resizable<T[]> rs;
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/priority/queue/LinkedListIterator.java
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // }
import io.github.marioluan.datastructures.Node; import java.util.Iterator; import java.util.NoSuchElementException;
package io.github.marioluan.datastructures.priority.queue; /** * Implements an Iterator for a LinkedList data type. * * @author marioluan * @param <T> * the class type of the data from nodes */ public class LinkedListIterator<T extends Comparable<T>> implements Iterator<T> {
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // Path: src/main/java/io/github/marioluan/datastructures/priority/queue/LinkedListIterator.java import io.github.marioluan.datastructures.Node; import java.util.Iterator; import java.util.NoSuchElementException; package io.github.marioluan.datastructures.priority.queue; /** * Implements an Iterator for a LinkedList data type. * * @author marioluan * @param <T> * the class type of the data from nodes */ public class LinkedListIterator<T extends Comparable<T>> implements Iterator<T> {
private Node<T> cursor;
marioluan/java-data-structures
src/main/java/io/github/marioluan/datastructures/priority/queue/MinOrderedLinkedListPriorityQueue.java
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // }
import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util;
package io.github.marioluan.datastructures.priority.queue; /** * Priority Queue implementation using an ordered linked list data type. * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class MinOrderedLinkedListPriorityQueue<T extends Comparable<T>> implements Iterable<T> {
// Path: src/main/java/io/github/marioluan/datastructures/Node.java // public class Node<T extends Comparable<T>> implements Comparable<Node<T>> { // // /** // * The value of the node. // */ // public T data; // // /** // * A link to the next node. // */ // public Node<T> next; // // /** // * A link to the previous node. // */ // public Node<T> prev; // // /** // * Construct a new node with the given data. // * // * @param data // */ // public Node(T data) { // this.data = data; // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Node<T> that) { // return this.data.compareTo(that.data); // } // // /** // * Checks whether there is a link to next node. // * // * @return whether the next field is not null // */ // public boolean hasNext() { // return this.next != null; // } // // /** // * Checks whether there is a link to previous node. // * // * @return whether the prev field is not null // */ // public boolean hasPrev() { // return this.prev != null; // } // // } // // Path: src/main/java/io/github/marioluan/datastructures/Util.java // public final class Util { // // private Util() { // } // // /** // * Check whether {@link Comparable a} is lesser than {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean less(Comparable a, Comparable b) { // return a.compareTo(b) < 0; // } // // /** // * Check whether {@link a} is lesser than {@link b}. // * // * @param <T> // * @param a // * @param b // * @return returns whether a is lesser than b // */ // @SuppressWarnings("unchecked") // public static <T> boolean less(T a, T b) { // return ((Comparable<T>) a).compareTo(b) < 0; // } // // /** // * Check whether {@link Comparable a} is lesser or equal to // * {@link Comparable b}. // * // * @param a // * @param b // * @return returns whether a is lesser or equal to b // */ // @SuppressWarnings({ "rawtypes", "unchecked" }) // public static boolean lessOrEqual(Comparable a, Comparable b) { // return a.compareTo(b) < 1; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param a // * @param i // * @param j // */ // @SuppressWarnings("rawtypes") // public static void swap(Comparable[] a, int i, int j) { // Comparable copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Swap item in position i by item in position j from array {@link a}. // * // * @param <T> // * @param a // * @param i // * @param j // */ // public static <T> void swap(T[] a, int i, int j) { // T copy = a[i]; // a[i] = a[j]; // a[j] = copy; // } // // /** // * Find and return the index from the minimum item from array a within // * lowerBound and upperBound. // * // * @param a // * @param lowerBound // * @param upperBound // * @return returns the index from the element with the minimum value // */ // @SuppressWarnings("rawtypes") // public static int findMin(Comparable[] a, int lowerBound, int upperBound) { // int min = lowerBound; // for (int i = lowerBound + 1; i < upperBound; i++) // if (less(a[i], a[min])) // min = i; // // return min; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param a // * @param aux // * @param lo // * @param hi // */ // @SuppressWarnings("rawtypes") // public static void copy(Comparable[] a, Comparable[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // // /** // * Make a copy of items from array a within lo and hi bounds into array aux. // * // * @param <T> // * @param a // * @param aux // * @param lo // * @param hi // */ // public static <T> void copy(T[] a, T[] aux, int lo, int hi) { // for (int i = lo; i <= hi; i++) // aux[i] = a[i]; // } // } // Path: src/main/java/io/github/marioluan/datastructures/priority/queue/MinOrderedLinkedListPriorityQueue.java import java.util.Iterator; import java.util.NoSuchElementException; import io.github.marioluan.datastructures.Node; import io.github.marioluan.datastructures.Util; package io.github.marioluan.datastructures.priority.queue; /** * Priority Queue implementation using an ordered linked list data type. * * @author marioluan * @param <T> * the class type of elements to be handled. */ public class MinOrderedLinkedListPriorityQueue<T extends Comparable<T>> implements Iterable<T> {
private Node<T> head;
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // }
import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream;
/* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermList extends TermStruct { private static final int INDEX_HEAD = 0; private static final int INDEX_TAIL = 1; TermList() { super(Terms.LIST_FUNCTOR, null); } TermList(final Term term) { super(Terms.LIST_FUNCTOR, new Term[] {term, Terms.NULL_LIST}); } TermList(final Term head, final Term tail) { super(Terms.LIST_FUNCTOR, new Term[] {head, tail}); } public static TermList asTermList(final Term... elements) { if (elements.length == 0) { return Terms.NULL_LIST; } else if (elements.length == 1) { final Term element = elements[0]; switch (element.getTermType()) { case LIST: return (TermList) element; case STRUCT: { final TermStruct struct = (TermStruct) element;
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; /* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermList extends TermStruct { private static final int INDEX_HEAD = 0; private static final int INDEX_TAIL = 1; TermList() { super(Terms.LIST_FUNCTOR, null); } TermList(final Term term) { super(Terms.LIST_FUNCTOR, new Term[] {term, Terms.NULL_LIST}); } TermList(final Term head, final Term tail) { super(Terms.LIST_FUNCTOR, new Term[] {head, tail}); } public static TermList asTermList(final Term... elements) { if (elements.length == 0) { return Terms.NULL_LIST; } else if (elements.length == 1) { final Term element = elements[0]; switch (element.getTermType()) { case LIST: return (TermList) element; case STRUCT: { final TermStruct struct = (TermStruct) element;
final TermList result = newList(struct.getFunctor());
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // }
import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream;
/* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermList extends TermStruct { private static final int INDEX_HEAD = 0; private static final int INDEX_TAIL = 1; TermList() { super(Terms.LIST_FUNCTOR, null); } TermList(final Term term) { super(Terms.LIST_FUNCTOR, new Term[] {term, Terms.NULL_LIST}); } TermList(final Term head, final Term tail) { super(Terms.LIST_FUNCTOR, new Term[] {head, tail}); } public static TermList asTermList(final Term... elements) { if (elements.length == 0) { return Terms.NULL_LIST; } else if (elements.length == 1) { final Term element = elements[0]; switch (element.getTermType()) { case LIST: return (TermList) element; case STRUCT: { final TermStruct struct = (TermStruct) element; final TermList result = newList(struct.getFunctor()); TermList curResult = result; final int arity = struct.getArity(); for (int li = 0; li < arity; li++) {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; /* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermList extends TermStruct { private static final int INDEX_HEAD = 0; private static final int INDEX_TAIL = 1; TermList() { super(Terms.LIST_FUNCTOR, null); } TermList(final Term term) { super(Terms.LIST_FUNCTOR, new Term[] {term, Terms.NULL_LIST}); } TermList(final Term head, final Term tail) { super(Terms.LIST_FUNCTOR, new Term[] {head, tail}); } public static TermList asTermList(final Term... elements) { if (elements.length == 0) { return Terms.NULL_LIST; } else if (elements.length == 1) { final Term element = elements[0]; switch (element.getTermType()) { case LIST: return (TermList) element; case STRUCT: { final TermStruct struct = (TermStruct) element; final TermList result = newList(struct.getFunctor()); TermList curResult = result; final int arity = struct.getArity(); for (int li = 0; li < arity; li++) {
curResult = createOrAppendToList(curResult, struct.getElement(li));
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // }
import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream;
while (list != Terms.NULL_LIST) { if (list.getTermType() == LIST) { if (notfirst) { builder.append(','); } final TermList asList = (TermList) list; builder.append(asList.getHead().toSrcString()); list = asList.getTail(); } else { if (notfirst) { builder.append('|'); } builder.append(list.toSrcString()); break; } notfirst = true; } builder.append(']'); return builder.toString(); } @Override public String getSignature() { return "./2"; } public final void replaceLastElement(final Term newLastElement) { if (isNullList()) {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; while (list != Terms.NULL_LIST) { if (list.getTermType() == LIST) { if (notfirst) { builder.append(','); } final TermList asList = (TermList) list; builder.append(asList.getHead().toSrcString()); list = asList.getTail(); } else { if (notfirst) { builder.append('|'); } builder.append(list.toSrcString()); break; } notfirst = true; } builder.append(']'); return builder.toString(); } @Override public String getSignature() { return "./2"; } public final void replaceLastElement(final Term newLastElement) { if (isNullList()) {
throw new ProlCriticalError("Attemption to change Null list");
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // }
import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream;
curlist = (TermList) nextList; } else { arraylist.add(nextList); break; } } return arraylist.toArray(new Term[0]); } public Term toAtom() { if (this.isNullList()) { return new Term("<empty>"); } if (this.getTail() == Terms.NULL_LIST) { return this.getHead(); } else { final int length = this.calculateLength(); if (length == 3) { if (this.getHead() == Terms.LIST_FUNCTOR) { final TermList secondElement = this.getTail(); final TermList thirdElement = secondElement.getTail(); if (thirdElement.getHead().getTermType() == LIST) { return newList(secondElement.getHead(), thirdElement.getHead()); } } } final TermStruct result; if (length == 1) {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermList newList(final Term term) { // return new TermList(term); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermStruct newStruct(final Term functor) { // return new TermStruct(functor); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static TermList createOrAppendToList(final TermList nullableList, final Term term) { // final TermList newList = Terms.newList(term); // // if (nullableList != null && !nullableList.isNullList()) { // newList.setTail(nullableList.getTail()); // nullableList.setTail(newList); // } // // return newList; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlCriticalError.java // public class ProlCriticalError extends Error { // // private static final long serialVersionUID = 1340153646373377400L; // // public ProlCriticalError(final Throwable cause) { // super(cause); // } // // public ProlCriticalError(final String message, final Throwable cause) { // super(message, cause); // } // // public ProlCriticalError(final String message) { // super(message); // } // // public ProlCriticalError() { // super(); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermList.java import static com.igormaznitsa.jprol.data.TermType.LIST; import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newList; import static com.igormaznitsa.jprol.data.Terms.newStruct; import static com.igormaznitsa.jprol.utils.Utils.createOrAppendToList; import com.igormaznitsa.jprol.exceptions.ProlCriticalError; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.stream.Stream; curlist = (TermList) nextList; } else { arraylist.add(nextList); break; } } return arraylist.toArray(new Term[0]); } public Term toAtom() { if (this.isNullList()) { return new Term("<empty>"); } if (this.getTail() == Terms.NULL_LIST) { return this.getHead(); } else { final int length = this.calculateLength(); if (length == 3) { if (this.getHead() == Terms.LIST_FUNCTOR) { final TermList secondElement = this.getTail(); final TermList thirdElement = secondElement.getTail(); if (thirdElement.getHead().getTermType() == LIST) { return newList(secondElement.getHead(), thirdElement.getHead()); } } } final TermStruct result; if (length == 1) {
result = newStruct(this.getHead());
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermLong.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermLong newLong(final String text) { // return new TermLong(text); // }
import static com.igormaznitsa.jprol.data.Terms.newLong;
@Override public Number toNumber() { return this.value; } @Override public String toSrcString() { return Long.toString(value); } @Override public String getText() { return Long.toString(this.value); } @Override public int compare(final NumericTerm atom) { if (atom.isDouble()) { final double value = atom.toNumber().doubleValue(); return Double.compare((double) this.value, value); } return Long.compare(this.value, atom.toNumber().longValue()); } @Override public NumericTerm add(final NumericTerm atom) { if (atom.isDouble()) { final double value = atom.toNumber().doubleValue(); return Terms.newDouble((double) this.value + value); } else {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermLong newLong(final String text) { // return new TermLong(text); // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermLong.java import static com.igormaznitsa.jprol.data.Terms.newLong; @Override public Number toNumber() { return this.value; } @Override public String toSrcString() { return Long.toString(value); } @Override public String getText() { return Long.toString(this.value); } @Override public int compare(final NumericTerm atom) { if (atom.isDouble()) { final double value = atom.toNumber().doubleValue(); return Double.compare((double) this.value, value); } return Long.compare(this.value, atom.toNumber().longValue()); } @Override public NumericTerm add(final NumericTerm atom) { if (atom.isDouble()) { final double value = atom.toNumber().doubleValue(); return Terms.newDouble((double) this.value + value); } else {
return newLong(this.value + atom.toNumber().longValue());
raydac/jprol
engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/OptionsDialog.java
// Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/AbstractProlEditor.java // public final static class PropertyLink { // // private final Object ownerObject; // private final Class<?> ownerClass; // private final String name; // private final String property; // // public PropertyLink(final Object object, final String name, final String property) { // this.name = name; // this.ownerObject = object; // this.ownerClass = object.getClass(); // this.property = property; // } // // public Object getOwner() { // return ownerObject; // } // // @SuppressWarnings("unchecked") // public Object getProperty() { // try { // Method meth = ownerClass.getMethod("get" + property, (Class[]) null); // return meth.invoke(ownerObject); // } catch (Throwable thr) { // throw new RuntimeException("Can't read property", thr); // } // } // // @SuppressWarnings("unchecked") // public void setProperty(final Object obj) { // try { // ownerClass.getMethod("set" + property, new Class<?>[] {obj.getClass()}).invoke(ownerObject, obj); // } catch (Throwable thr) { // throw new RuntimeException("Can't set property", thr); // } // } // // @Override // public String toString() { // String str = this.name; // final Object val = getProperty(); // if (val instanceof Boolean) { // str += " (" + val.toString() + ")"; // } // // return str; // } // }
import java.util.ArrayList; import java.util.Arrays; import com.igormaznitsa.jprol.easygui.AbstractProlEditor.PropertyLink; import javax.swing.*; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
.addComponent(buttonCloseDialog, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCloseDialog, buttonEditOption}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonEditOption) .addComponent(buttonCloseDialog)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void buttonCloseDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseDialogActionPerformed dispose(); }//GEN-LAST:event_buttonCloseDialogActionPerformed private void buttonEditOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditOptionActionPerformed final TreePath path = optionsTree.getSelectionPath(); if (path == null) { return; }
// Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/AbstractProlEditor.java // public final static class PropertyLink { // // private final Object ownerObject; // private final Class<?> ownerClass; // private final String name; // private final String property; // // public PropertyLink(final Object object, final String name, final String property) { // this.name = name; // this.ownerObject = object; // this.ownerClass = object.getClass(); // this.property = property; // } // // public Object getOwner() { // return ownerObject; // } // // @SuppressWarnings("unchecked") // public Object getProperty() { // try { // Method meth = ownerClass.getMethod("get" + property, (Class[]) null); // return meth.invoke(ownerObject); // } catch (Throwable thr) { // throw new RuntimeException("Can't read property", thr); // } // } // // @SuppressWarnings("unchecked") // public void setProperty(final Object obj) { // try { // ownerClass.getMethod("set" + property, new Class<?>[] {obj.getClass()}).invoke(ownerObject, obj); // } catch (Throwable thr) { // throw new RuntimeException("Can't set property", thr); // } // } // // @Override // public String toString() { // String str = this.name; // final Object val = getProperty(); // if (val instanceof Boolean) { // str += " (" + val.toString() + ")"; // } // // return str; // } // } // Path: engine/jprol-gui/src/main/java/com/igormaznitsa/jprol/easygui/OptionsDialog.java import java.util.ArrayList; import java.util.Arrays; import com.igormaznitsa.jprol.easygui.AbstractProlEditor.PropertyLink; import javax.swing.*; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; .addComponent(buttonCloseDialog, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCloseDialog, buttonEditOption}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonEditOption) .addComponent(buttonCloseDialog)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void buttonCloseDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseDialogActionPerformed dispose(); }//GEN-LAST:event_buttonCloseDialogActionPerformed private void buttonEditOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditOptionActionPerformed final TreePath path = optionsTree.getSelectionPath(); if (path == null) { return; }
final AbstractProlEditor.PropertyLink prop = (PropertyLink) path.getLastPathComponent();
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermVar.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermVar newVar(final String name) { // return new TermVar(name); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlInstantiationErrorException.java // public class ProlInstantiationErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -5157739502740121566L; // // private static final Term TERM_ERROR = newAtom("instantiation_error"); // // public ProlInstantiationErrorException(final Term culprit, final Throwable cause) { // super(culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit) { // super(message, culprit); // } // // public ProlInstantiationErrorException(final Term culprit) { // super(culprit); // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, this.getCulprit()); // } // }
import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newVar; import com.igormaznitsa.jprol.exceptions.ProlInstantiationErrorException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream;
/* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermVar extends Term { private static final AtomicInteger ANONYM_GENERATOR = new AtomicInteger(0); private static final AtomicInteger UID_GENERATOR = new AtomicInteger(0); private final int uid; private final boolean anonymous; private volatile Term value; private TermVar(final String name, final boolean anonymous) { super(name); this.uid = UID_GENERATOR.incrementAndGet(); this.anonymous = anonymous; } TermVar(final String name) { this(name, false); } TermVar() { this("_$" + Long.toHexString(ANONYM_GENERATOR.incrementAndGet()), true); } public final int getVarUid() { return this.uid; } @Override public TermType getTermType() { return VAR; } @Override public Term makeClone() { final Term value = this.getThisValue();
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermVar newVar(final String name) { // return new TermVar(name); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlInstantiationErrorException.java // public class ProlInstantiationErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -5157739502740121566L; // // private static final Term TERM_ERROR = newAtom("instantiation_error"); // // public ProlInstantiationErrorException(final Term culprit, final Throwable cause) { // super(culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit) { // super(message, culprit); // } // // public ProlInstantiationErrorException(final Term culprit) { // super(culprit); // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, this.getCulprit()); // } // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermVar.java import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newVar; import com.igormaznitsa.jprol.exceptions.ProlInstantiationErrorException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; /* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.data; public final class TermVar extends Term { private static final AtomicInteger ANONYM_GENERATOR = new AtomicInteger(0); private static final AtomicInteger UID_GENERATOR = new AtomicInteger(0); private final int uid; private final boolean anonymous; private volatile Term value; private TermVar(final String name, final boolean anonymous) { super(name); this.uid = UID_GENERATOR.incrementAndGet(); this.anonymous = anonymous; } TermVar(final String name) { this(name, false); } TermVar() { this("_$" + Long.toHexString(ANONYM_GENERATOR.incrementAndGet()), true); } public final int getVarUid() { return this.uid; } @Override public TermType getTermType() { return VAR; } @Override public Term makeClone() { final Term value = this.getThisValue();
TermVar result = this.isAnonymous() ? newVar() : newVar(this.getText());
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermVar.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermVar newVar(final String name) { // return new TermVar(name); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlInstantiationErrorException.java // public class ProlInstantiationErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -5157739502740121566L; // // private static final Term TERM_ERROR = newAtom("instantiation_error"); // // public ProlInstantiationErrorException(final Term culprit, final Throwable cause) { // super(culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit) { // super(message, culprit); // } // // public ProlInstantiationErrorException(final Term culprit) { // super(culprit); // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, this.getCulprit()); // } // }
import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newVar; import com.igormaznitsa.jprol.exceptions.ProlInstantiationErrorException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream;
this("_$" + Long.toHexString(ANONYM_GENERATOR.incrementAndGet()), true); } public final int getVarUid() { return this.uid; } @Override public TermType getTermType() { return VAR; } @Override public Term makeClone() { final Term value = this.getThisValue(); TermVar result = this.isAnonymous() ? newVar() : newVar(this.getText()); if (value != null) { final Map<Integer, TermVar> vars = new HashMap<>(); vars.put(this.getVarUid(), result); result.setThisValue(doMakeClone(vars)); } return result; } @Override public Number toNumber() { final Term data = this.getValue(); if (data instanceof NumericTerm) { return data.toNumber(); }
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Terms.java // public static TermVar newVar(final String name) { // return new TermVar(name); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlInstantiationErrorException.java // public class ProlInstantiationErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -5157739502740121566L; // // private static final Term TERM_ERROR = newAtom("instantiation_error"); // // public ProlInstantiationErrorException(final Term culprit, final Throwable cause) { // super(culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // } // // public ProlInstantiationErrorException(final String message, final Term culprit) { // super(message, culprit); // } // // public ProlInstantiationErrorException(final Term culprit) { // super(culprit); // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, this.getCulprit()); // } // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/TermVar.java import static com.igormaznitsa.jprol.data.TermType.VAR; import static com.igormaznitsa.jprol.data.Terms.newVar; import com.igormaznitsa.jprol.exceptions.ProlInstantiationErrorException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; this("_$" + Long.toHexString(ANONYM_GENERATOR.incrementAndGet()), true); } public final int getVarUid() { return this.uid; } @Override public TermType getTermType() { return VAR; } @Override public Term makeClone() { final Term value = this.getThisValue(); TermVar result = this.isAnonymous() ? newVar() : newVar(this.getText()); if (value != null) { final Map<Integer, TermVar> vars = new HashMap<>(); vars.put(this.getVarUid(), result); result.setThisValue(doMakeClone(vars)); } return result; } @Override public Number toNumber() { final Term data = this.getValue(); if (data instanceof NumericTerm) { return data.toNumber(); }
throw new ProlInstantiationErrorException("NonInstantiated variable", this);
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Term.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String escapeSrc(final String string) { // // if (string.length() == 0) { // return string; // } // // final StringBuilder builder = new StringBuilder(string.length()); // // for (int li = 0; li < string.length(); li++) { // final char curChar = string.charAt(li); // // switch (curChar) { // case '\\': // builder.append("\\\\"); // break; // case '\'': // builder.append("\\'"); // break; // case '\"': // builder.append("\\\""); // break; // case '\n': // builder.append("\\n"); // break; // case '\f': // builder.append("\\f"); // break; // case '\r': // builder.append("\\r"); // break; // case '\t': // builder.append("\\t"); // break; // case '_': { // builder.append('_'); // } // break; // case '%': // case '.': // default: { // builder.append(curChar); // } // break; // } // } // // return builder.toString(); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlTypeErrorException.java // public class ProlTypeErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -3258214534404942716L; // // private static final Term TERM_ERROR = newAtom("type_error"); // // private final String validType; // // public ProlTypeErrorException(final String validType, final Term culprit, final Throwable cause) { // super(culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit) { // super(message, culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final Term culprit) { // super(culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public String getValidType() { // return validType; // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, asTermList(newAtom(this.validType), getCulprit())); // } // // }
import static com.igormaznitsa.jprol.data.TermType.ATOM; import static com.igormaznitsa.jprol.utils.Utils.escapeSrc; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toMap; import com.igormaznitsa.jprol.exceptions.ProlTypeErrorException; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream;
public Map<String, Term> allNamedVarValuesAsMap() { return this.variables() .filter(v -> !v.isFree()) .collect(toMap(TermVar::getText, e -> e.<Term>findNonVarOrDefault(e), (v1, v2) -> v2)); } public boolean isGround() { return true; } @SuppressWarnings("unchecked") public <T extends Term> T findNonVarOrSame() { return (T) this; } @SuppressWarnings("unchecked") public <T extends Term> T findNonVarOrDefault(final T term) { return (T) this; } public Stream<Term> stream() { return Stream.of(this); } public Stream<TermVar> variables() { return Stream.empty(); } public String toSrcString() {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String escapeSrc(final String string) { // // if (string.length() == 0) { // return string; // } // // final StringBuilder builder = new StringBuilder(string.length()); // // for (int li = 0; li < string.length(); li++) { // final char curChar = string.charAt(li); // // switch (curChar) { // case '\\': // builder.append("\\\\"); // break; // case '\'': // builder.append("\\'"); // break; // case '\"': // builder.append("\\\""); // break; // case '\n': // builder.append("\\n"); // break; // case '\f': // builder.append("\\f"); // break; // case '\r': // builder.append("\\r"); // break; // case '\t': // builder.append("\\t"); // break; // case '_': { // builder.append('_'); // } // break; // case '%': // case '.': // default: { // builder.append(curChar); // } // break; // } // } // // return builder.toString(); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlTypeErrorException.java // public class ProlTypeErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -3258214534404942716L; // // private static final Term TERM_ERROR = newAtom("type_error"); // // private final String validType; // // public ProlTypeErrorException(final String validType, final Term culprit, final Throwable cause) { // super(culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit) { // super(message, culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final Term culprit) { // super(culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public String getValidType() { // return validType; // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, asTermList(newAtom(this.validType), getCulprit())); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Term.java import static com.igormaznitsa.jprol.data.TermType.ATOM; import static com.igormaznitsa.jprol.utils.Utils.escapeSrc; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toMap; import com.igormaznitsa.jprol.exceptions.ProlTypeErrorException; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; public Map<String, Term> allNamedVarValuesAsMap() { return this.variables() .filter(v -> !v.isFree()) .collect(toMap(TermVar::getText, e -> e.<Term>findNonVarOrDefault(e), (v1, v2) -> v2)); } public boolean isGround() { return true; } @SuppressWarnings("unchecked") public <T extends Term> T findNonVarOrSame() { return (T) this; } @SuppressWarnings("unchecked") public <T extends Term> T findNonVarOrDefault(final T term) { return (T) this; } public Stream<Term> stream() { return Stream.of(this); } public Stream<TermVar> variables() { return Stream.empty(); } public String toSrcString() {
return String.format("'%s'", escapeSrc(getText()));
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Term.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String escapeSrc(final String string) { // // if (string.length() == 0) { // return string; // } // // final StringBuilder builder = new StringBuilder(string.length()); // // for (int li = 0; li < string.length(); li++) { // final char curChar = string.charAt(li); // // switch (curChar) { // case '\\': // builder.append("\\\\"); // break; // case '\'': // builder.append("\\'"); // break; // case '\"': // builder.append("\\\""); // break; // case '\n': // builder.append("\\n"); // break; // case '\f': // builder.append("\\f"); // break; // case '\r': // builder.append("\\r"); // break; // case '\t': // builder.append("\\t"); // break; // case '_': { // builder.append('_'); // } // break; // case '%': // case '.': // default: { // builder.append(curChar); // } // break; // } // } // // return builder.toString(); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlTypeErrorException.java // public class ProlTypeErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -3258214534404942716L; // // private static final Term TERM_ERROR = newAtom("type_error"); // // private final String validType; // // public ProlTypeErrorException(final String validType, final Term culprit, final Throwable cause) { // super(culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit) { // super(message, culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final Term culprit) { // super(culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public String getValidType() { // return validType; // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, asTermList(newAtom(this.validType), getCulprit())); // } // // }
import static com.igormaznitsa.jprol.data.TermType.ATOM; import static com.igormaznitsa.jprol.utils.Utils.escapeSrc; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toMap; import com.igormaznitsa.jprol.exceptions.ProlTypeErrorException; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream;
return (T) this; } public Stream<Term> stream() { return Stream.of(this); } public Stream<TermVar> variables() { return Stream.empty(); } public String toSrcString() { return String.format("'%s'", escapeSrc(getText())); } @Override public String toString() { return toSrcString(); } @Override public int hashCode() { if (text == null) { return super.hashCode(); } else { return text.hashCode(); } } public Number toNumber() {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String escapeSrc(final String string) { // // if (string.length() == 0) { // return string; // } // // final StringBuilder builder = new StringBuilder(string.length()); // // for (int li = 0; li < string.length(); li++) { // final char curChar = string.charAt(li); // // switch (curChar) { // case '\\': // builder.append("\\\\"); // break; // case '\'': // builder.append("\\'"); // break; // case '\"': // builder.append("\\\""); // break; // case '\n': // builder.append("\\n"); // break; // case '\f': // builder.append("\\f"); // break; // case '\r': // builder.append("\\r"); // break; // case '\t': // builder.append("\\t"); // break; // case '_': { // builder.append('_'); // } // break; // case '%': // case '.': // default: { // builder.append(curChar); // } // break; // } // } // // return builder.toString(); // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/exceptions/ProlTypeErrorException.java // public class ProlTypeErrorException extends ProlAbstractCatcheableException { // // private static final long serialVersionUID = -3258214534404942716L; // // private static final Term TERM_ERROR = newAtom("type_error"); // // private final String validType; // // public ProlTypeErrorException(final String validType, final Term culprit, final Throwable cause) { // super(culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit, // final Throwable cause) { // super(message, culprit, cause); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final String message, final Term culprit) { // super(message, culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public ProlTypeErrorException(final String validType, final Term culprit) { // super(culprit); // this.validType = validType == null ? UNDEFINED.getText() : validType; // } // // public String getValidType() { // return validType; // } // // // @Override // public Term getErrorTerm() { // return TERM_ERROR; // } // // @Override // public TermStruct getAsStruct() { // return this.makeErrorStruct(TERM_ERROR, asTermList(newAtom(this.validType), getCulprit())); // } // // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/data/Term.java import static com.igormaznitsa.jprol.data.TermType.ATOM; import static com.igormaznitsa.jprol.utils.Utils.escapeSrc; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toMap; import com.igormaznitsa.jprol.exceptions.ProlTypeErrorException; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; return (T) this; } public Stream<Term> stream() { return Stream.of(this); } public Stream<TermVar> variables() { return Stream.empty(); } public String toSrcString() { return String.format("'%s'", escapeSrc(getText())); } @Override public String toString() { return toSrcString(); } @Override public int hashCode() { if (text == null) { return super.hashCode(); } else { return text.hashCode(); } } public Number toNumber() {
throw new ProlTypeErrorException("numeric", "NonNumeric term", this);
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/logic/triggers/AbstractJProlTrigger.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String normalizeSignature(final String signature) { // if (signature == null) { // return null; // } // String sig = signature.trim(); // // if (sig.length() > 0 && sig.charAt(0) == '\'') { // sig = sig.substring(1); // final int lastIndex = sig.lastIndexOf('/'); // if (lastIndex < 0) { // sig = null; // } else { // final String arity = sig.substring(lastIndex + 1).trim(); // String name = sig.substring(0, lastIndex - 1).trim(); // if (name.length() > 0 && name.charAt(name.length() - 1) == '\'') { // name = name.substring(0, name.length() - 1); // sig = name + '/' + arity; // } else { // sig = null; // } // } // } // return sig; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String validateSignature(final String signature) { // final String[] parsed = // Objects.requireNonNull(signature, "Null signature not allowed").split("/"); // if (parsed.length == 2) { // String str = parsed[0].trim(); // boolean quoted = false; // if (str.length() != 0) { // if (str.charAt(0) == '\'') { // if (str.length() > 1 && str.charAt(str.length() - 1) == '\'') { // str = str.substring(1, str.length() - 1); // if (str.length() == 0) { // return null; // } // quoted = true; // } else { // // wrong name, it must not contain '\'' as the only symbol // return null; // } // } // // final char firstChar = str.charAt(0); // if (!quoted && (Character.isDigit(firstChar) || Character.isUpperCase(firstChar) || // Character.isWhitespace(firstChar) || firstChar == '.')) { // return null; // } // // // ok. the first part is ok, check the second part // final int arity; // try { // arity = Integer.parseInt(parsed[1].trim()); // if (arity < 0) { // throw new NumberFormatException("Negate number is not supported as arity"); // } // } catch (NumberFormatException ex) { // return null; // } // // final StringBuilder builder = new StringBuilder(signature.length()); // // if (quoted) { // builder.append('\'').append(str).append('\'').append('/').append(arity); // } else { // builder.append(str).append('/').append(arity); // } // // return builder.toString(); // } // } // return null; // }
import static com.igormaznitsa.jprol.utils.Utils.normalizeSignature; import static com.igormaznitsa.jprol.utils.Utils.validateSignature; import static java.util.Objects.requireNonNull; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.logic.triggers; public abstract class AbstractJProlTrigger implements JProlTrigger { private final Map<String, JProlTriggerType> signatureMap; public AbstractJProlTrigger() { this.signatureMap = Collections.synchronizedMap(new HashMap<>()); } public AbstractJProlTrigger addSignature(final String signature, final JProlTriggerType observedEvent) {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String normalizeSignature(final String signature) { // if (signature == null) { // return null; // } // String sig = signature.trim(); // // if (sig.length() > 0 && sig.charAt(0) == '\'') { // sig = sig.substring(1); // final int lastIndex = sig.lastIndexOf('/'); // if (lastIndex < 0) { // sig = null; // } else { // final String arity = sig.substring(lastIndex + 1).trim(); // String name = sig.substring(0, lastIndex - 1).trim(); // if (name.length() > 0 && name.charAt(name.length() - 1) == '\'') { // name = name.substring(0, name.length() - 1); // sig = name + '/' + arity; // } else { // sig = null; // } // } // } // return sig; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String validateSignature(final String signature) { // final String[] parsed = // Objects.requireNonNull(signature, "Null signature not allowed").split("/"); // if (parsed.length == 2) { // String str = parsed[0].trim(); // boolean quoted = false; // if (str.length() != 0) { // if (str.charAt(0) == '\'') { // if (str.length() > 1 && str.charAt(str.length() - 1) == '\'') { // str = str.substring(1, str.length() - 1); // if (str.length() == 0) { // return null; // } // quoted = true; // } else { // // wrong name, it must not contain '\'' as the only symbol // return null; // } // } // // final char firstChar = str.charAt(0); // if (!quoted && (Character.isDigit(firstChar) || Character.isUpperCase(firstChar) || // Character.isWhitespace(firstChar) || firstChar == '.')) { // return null; // } // // // ok. the first part is ok, check the second part // final int arity; // try { // arity = Integer.parseInt(parsed[1].trim()); // if (arity < 0) { // throw new NumberFormatException("Negate number is not supported as arity"); // } // } catch (NumberFormatException ex) { // return null; // } // // final StringBuilder builder = new StringBuilder(signature.length()); // // if (quoted) { // builder.append('\'').append(str).append('\'').append('/').append(arity); // } else { // builder.append(str).append('/').append(arity); // } // // return builder.toString(); // } // } // return null; // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/logic/triggers/AbstractJProlTrigger.java import static com.igormaznitsa.jprol.utils.Utils.normalizeSignature; import static com.igormaznitsa.jprol.utils.Utils.validateSignature; import static java.util.Objects.requireNonNull; import java.util.Collections; import java.util.HashMap; import java.util.Map; /* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.logic.triggers; public abstract class AbstractJProlTrigger implements JProlTrigger { private final Map<String, JProlTriggerType> signatureMap; public AbstractJProlTrigger() { this.signatureMap = Collections.synchronizedMap(new HashMap<>()); } public AbstractJProlTrigger addSignature(final String signature, final JProlTriggerType observedEvent) {
String processedsignature = validateSignature(requireNonNull(signature));
raydac/jprol
engine/jprol-core/src/main/java/com/igormaznitsa/jprol/logic/triggers/AbstractJProlTrigger.java
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String normalizeSignature(final String signature) { // if (signature == null) { // return null; // } // String sig = signature.trim(); // // if (sig.length() > 0 && sig.charAt(0) == '\'') { // sig = sig.substring(1); // final int lastIndex = sig.lastIndexOf('/'); // if (lastIndex < 0) { // sig = null; // } else { // final String arity = sig.substring(lastIndex + 1).trim(); // String name = sig.substring(0, lastIndex - 1).trim(); // if (name.length() > 0 && name.charAt(name.length() - 1) == '\'') { // name = name.substring(0, name.length() - 1); // sig = name + '/' + arity; // } else { // sig = null; // } // } // } // return sig; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String validateSignature(final String signature) { // final String[] parsed = // Objects.requireNonNull(signature, "Null signature not allowed").split("/"); // if (parsed.length == 2) { // String str = parsed[0].trim(); // boolean quoted = false; // if (str.length() != 0) { // if (str.charAt(0) == '\'') { // if (str.length() > 1 && str.charAt(str.length() - 1) == '\'') { // str = str.substring(1, str.length() - 1); // if (str.length() == 0) { // return null; // } // quoted = true; // } else { // // wrong name, it must not contain '\'' as the only symbol // return null; // } // } // // final char firstChar = str.charAt(0); // if (!quoted && (Character.isDigit(firstChar) || Character.isUpperCase(firstChar) || // Character.isWhitespace(firstChar) || firstChar == '.')) { // return null; // } // // // ok. the first part is ok, check the second part // final int arity; // try { // arity = Integer.parseInt(parsed[1].trim()); // if (arity < 0) { // throw new NumberFormatException("Negate number is not supported as arity"); // } // } catch (NumberFormatException ex) { // return null; // } // // final StringBuilder builder = new StringBuilder(signature.length()); // // if (quoted) { // builder.append('\'').append(str).append('\'').append('/').append(arity); // } else { // builder.append(str).append('/').append(arity); // } // // return builder.toString(); // } // } // return null; // }
import static com.igormaznitsa.jprol.utils.Utils.normalizeSignature; import static com.igormaznitsa.jprol.utils.Utils.validateSignature; import static java.util.Objects.requireNonNull; import java.util.Collections; import java.util.HashMap; import java.util.Map;
/* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.logic.triggers; public abstract class AbstractJProlTrigger implements JProlTrigger { private final Map<String, JProlTriggerType> signatureMap; public AbstractJProlTrigger() { this.signatureMap = Collections.synchronizedMap(new HashMap<>()); } public AbstractJProlTrigger addSignature(final String signature, final JProlTriggerType observedEvent) { String processedsignature = validateSignature(requireNonNull(signature)); if (processedsignature == null) { throw new IllegalArgumentException("Wrong signature format [" + signature + ']'); } else {
// Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String normalizeSignature(final String signature) { // if (signature == null) { // return null; // } // String sig = signature.trim(); // // if (sig.length() > 0 && sig.charAt(0) == '\'') { // sig = sig.substring(1); // final int lastIndex = sig.lastIndexOf('/'); // if (lastIndex < 0) { // sig = null; // } else { // final String arity = sig.substring(lastIndex + 1).trim(); // String name = sig.substring(0, lastIndex - 1).trim(); // if (name.length() > 0 && name.charAt(name.length() - 1) == '\'') { // name = name.substring(0, name.length() - 1); // sig = name + '/' + arity; // } else { // sig = null; // } // } // } // return sig; // } // // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/utils/Utils.java // public static String validateSignature(final String signature) { // final String[] parsed = // Objects.requireNonNull(signature, "Null signature not allowed").split("/"); // if (parsed.length == 2) { // String str = parsed[0].trim(); // boolean quoted = false; // if (str.length() != 0) { // if (str.charAt(0) == '\'') { // if (str.length() > 1 && str.charAt(str.length() - 1) == '\'') { // str = str.substring(1, str.length() - 1); // if (str.length() == 0) { // return null; // } // quoted = true; // } else { // // wrong name, it must not contain '\'' as the only symbol // return null; // } // } // // final char firstChar = str.charAt(0); // if (!quoted && (Character.isDigit(firstChar) || Character.isUpperCase(firstChar) || // Character.isWhitespace(firstChar) || firstChar == '.')) { // return null; // } // // // ok. the first part is ok, check the second part // final int arity; // try { // arity = Integer.parseInt(parsed[1].trim()); // if (arity < 0) { // throw new NumberFormatException("Negate number is not supported as arity"); // } // } catch (NumberFormatException ex) { // return null; // } // // final StringBuilder builder = new StringBuilder(signature.length()); // // if (quoted) { // builder.append('\'').append(str).append('\'').append('/').append(arity); // } else { // builder.append(str).append('/').append(arity); // } // // return builder.toString(); // } // } // return null; // } // Path: engine/jprol-core/src/main/java/com/igormaznitsa/jprol/logic/triggers/AbstractJProlTrigger.java import static com.igormaznitsa.jprol.utils.Utils.normalizeSignature; import static com.igormaznitsa.jprol.utils.Utils.validateSignature; import static java.util.Objects.requireNonNull; import java.util.Collections; import java.util.HashMap; import java.util.Map; /* * Copyright 2014 Igor Maznitsa (http://www.igormaznitsa.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.igormaznitsa.jprol.logic.triggers; public abstract class AbstractJProlTrigger implements JProlTrigger { private final Map<String, JProlTriggerType> signatureMap; public AbstractJProlTrigger() { this.signatureMap = Collections.synchronizedMap(new HashMap<>()); } public AbstractJProlTrigger addSignature(final String signature, final JProlTriggerType observedEvent) { String processedsignature = validateSignature(requireNonNull(signature)); if (processedsignature == null) { throw new IllegalArgumentException("Wrong signature format [" + signature + ']'); } else {
processedsignature = normalizeSignature(processedsignature);
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/datastore/H2DataStore.java
// Path: src/main/java/guru/franz/mc/bcl/datastore/database/H2.java // public class H2 extends MySQL { // // /** // * Get a dataSource to execute Queries against // * // * @return the DataStore // * @throws SQLException if there is any errors with the MySQL // * @throws MySQLConnectionException If we can't connect to the database. // */ // protected DataSource getDataSource() throws SQLException, MySQLConnectionException { // Path datastoreDir = Paths.get(Config.getInstance().getDirectory() + "/datastore"); // if (!Files.exists(datastoreDir)) { // try { // Files.createDirectories(datastoreDir); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger() // .error("Could not create datastore directory.", e); // } // } // // String jdbcConnection = String.format("jdbc:h2:%s/h2;mode=MySQL", datastoreDir); // return Sponge.getServiceManager().provide(SqlService.class).orElseThrow(SQLException::new) // .getDataSource(jdbcConnection); // // } // } // // Path: src/main/java/guru/franz/mc/bcl/datastore/exceptions/MySQLConnectionException.java // public class MySQLConnectionException extends SQLException { // // public MySQLConnectionException(String message) { // super(message); // } // }
import guru.franz.mc.bcl.datastore.database.H2; import guru.franz.mc.bcl.datastore.exceptions.MySQLConnectionException;
package guru.franz.mc.bcl.datastore; public class H2DataStore extends DatabaseDataStore { @Override public String getName() {
// Path: src/main/java/guru/franz/mc/bcl/datastore/database/H2.java // public class H2 extends MySQL { // // /** // * Get a dataSource to execute Queries against // * // * @return the DataStore // * @throws SQLException if there is any errors with the MySQL // * @throws MySQLConnectionException If we can't connect to the database. // */ // protected DataSource getDataSource() throws SQLException, MySQLConnectionException { // Path datastoreDir = Paths.get(Config.getInstance().getDirectory() + "/datastore"); // if (!Files.exists(datastoreDir)) { // try { // Files.createDirectories(datastoreDir); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger() // .error("Could not create datastore directory.", e); // } // } // // String jdbcConnection = String.format("jdbc:h2:%s/h2;mode=MySQL", datastoreDir); // return Sponge.getServiceManager().provide(SqlService.class).orElseThrow(SQLException::new) // .getDataSource(jdbcConnection); // // } // } // // Path: src/main/java/guru/franz/mc/bcl/datastore/exceptions/MySQLConnectionException.java // public class MySQLConnectionException extends SQLException { // // public MySQLConnectionException(String message) { // super(message); // } // } // Path: src/main/java/guru/franz/mc/bcl/datastore/H2DataStore.java import guru.franz.mc.bcl.datastore.database.H2; import guru.franz.mc.bcl.datastore.exceptions.MySQLConnectionException; package guru.franz.mc.bcl.datastore; public class H2DataStore extends DatabaseDataStore { @Override public String getName() {
return "H2";
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/datastore/H2DataStore.java
// Path: src/main/java/guru/franz/mc/bcl/datastore/database/H2.java // public class H2 extends MySQL { // // /** // * Get a dataSource to execute Queries against // * // * @return the DataStore // * @throws SQLException if there is any errors with the MySQL // * @throws MySQLConnectionException If we can't connect to the database. // */ // protected DataSource getDataSource() throws SQLException, MySQLConnectionException { // Path datastoreDir = Paths.get(Config.getInstance().getDirectory() + "/datastore"); // if (!Files.exists(datastoreDir)) { // try { // Files.createDirectories(datastoreDir); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger() // .error("Could not create datastore directory.", e); // } // } // // String jdbcConnection = String.format("jdbc:h2:%s/h2;mode=MySQL", datastoreDir); // return Sponge.getServiceManager().provide(SqlService.class).orElseThrow(SQLException::new) // .getDataSource(jdbcConnection); // // } // } // // Path: src/main/java/guru/franz/mc/bcl/datastore/exceptions/MySQLConnectionException.java // public class MySQLConnectionException extends SQLException { // // public MySQLConnectionException(String message) { // super(message); // } // }
import guru.franz.mc.bcl.datastore.database.H2; import guru.franz.mc.bcl.datastore.exceptions.MySQLConnectionException;
package guru.franz.mc.bcl.datastore; public class H2DataStore extends DatabaseDataStore { @Override public String getName() { return "H2"; } @Override
// Path: src/main/java/guru/franz/mc/bcl/datastore/database/H2.java // public class H2 extends MySQL { // // /** // * Get a dataSource to execute Queries against // * // * @return the DataStore // * @throws SQLException if there is any errors with the MySQL // * @throws MySQLConnectionException If we can't connect to the database. // */ // protected DataSource getDataSource() throws SQLException, MySQLConnectionException { // Path datastoreDir = Paths.get(Config.getInstance().getDirectory() + "/datastore"); // if (!Files.exists(datastoreDir)) { // try { // Files.createDirectories(datastoreDir); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger() // .error("Could not create datastore directory.", e); // } // } // // String jdbcConnection = String.format("jdbc:h2:%s/h2;mode=MySQL", datastoreDir); // return Sponge.getServiceManager().provide(SqlService.class).orElseThrow(SQLException::new) // .getDataSource(jdbcConnection); // // } // } // // Path: src/main/java/guru/franz/mc/bcl/datastore/exceptions/MySQLConnectionException.java // public class MySQLConnectionException extends SQLException { // // public MySQLConnectionException(String message) { // super(message); // } // } // Path: src/main/java/guru/franz/mc/bcl/datastore/H2DataStore.java import guru.franz.mc.bcl.datastore.database.H2; import guru.franz.mc.bcl.datastore.exceptions.MySQLConnectionException; package guru.franz.mc.bcl.datastore; public class H2DataStore extends DatabaseDataStore { @Override public String getName() { return "H2"; } @Override
public void load() throws MySQLConnectionException {
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/model/PlayerData.java
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // }
import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID;
package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount;
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // } // Path: src/main/java/guru/franz/mc/bcl/model/PlayerData.java import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID; package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount;
public PlayerData(UUID playerId) throws UserNotFound {
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/model/PlayerData.java
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // }
import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID;
package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount; public PlayerData(UUID playerId) throws UserNotFound { this.playerId = playerId;
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // } // Path: src/main/java/guru/franz/mc/bcl/model/PlayerData.java import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID; package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount; public PlayerData(UUID playerId) throws UserNotFound { this.playerId = playerId;
User player = Utilities.getUserFromUUID(playerId);
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/model/PlayerData.java
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // }
import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID;
package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount; public PlayerData(UUID playerId) throws UserNotFound { this.playerId = playerId; User player = Utilities.getUserFromUUID(playerId);
// Path: src/main/java/guru/franz/mc/bcl/config/Config.java // @ConfigSerializable // public class Config { // // private static Config instance; // private static final ObjectMapper<Config> MAPPER; // // private Path configDir; // private ConfigurationNode node; // @Setting(value = "DataStore", comment = "Available data storage types include: MySQL, H2.") // private String dataStore = "H2"; // @Setting("Items") // private ItemsNode itemsNode = new ItemsNode(); // @Setting("DefaultChunksAmount") // private ChunksAmountNode defaultChunksNode = new ChunksAmountNode(); // @Setting("MaxChunksAmount") // private MaxChunksAmountNode maxChunksNode = new MaxChunksAmountNode(); // @Setting(value = "MaxHoursOffline", comment = "Time in hours before a player's chunkloaders become inactive.") // private int maxHoursOffline = 72; // @Setting("MySQL") // private final MySQLNode mySQL = new MySQLNode(); // @Setting(value = "ServerName", comment = "Unique name of the server.") // private String serverName = "aServer"; // // static { // try { // MAPPER = ObjectMapper.forClass(Config.class); // } catch (ObjectMappingException e) { // throw new ExceptionInInitializerError(e); // } // } // // public Config(Path configDir, ConfigurationNode node) { // this.configDir = configDir; // this.node = node; // } // // public static Config getInstance() { // return instance; // } // // /** // * @return The {@link ConfigurationNode} that was used to create this {@link Config}. // */ // public ConfigurationNode getNode() { // return node; // } // // public Path getDirectory() { // return configDir; // } // // public void setDirectory(Path configDir) { // this.configDir = configDir; // } // // /** // * Loads a {@link Config} instance from the provided {@link ConfigurationNode}. // * The newly created instance is then used when returning {@link #getInstance()}. // * // * @param configDir The {@link Path} where the config resides, used to return {@link #getDirectory()}. // * @param node The {@link ConfigurationNode} to load from. // * @return The newly created instance. // * @throws ObjectMappingException If an error occurs when populating the config. // */ // public static Config loadFrom(Path configDir, ConfigurationNode node) throws ObjectMappingException { // // Apply any version transformations before generating the config object // Transformations.versionedTransformation().apply(node); // instance = new Config(configDir, node); // // Populate fields // MAPPER.bind(instance).populate(node); // return instance; // } // // public static void moveOldConfig(Path configDir, Path newConfigPath) { // Path oldConfigPath = configDir.resolve("config.conf"); // if (Files.exists(oldConfigPath) && !Files.exists(newConfigPath)) { // try { // Files.move(oldConfigPath, newConfigPath); // } catch (IOException e) { // BetterChunkLoader.instance().getLogger().error("Could not move old config file.", e); // } // } // } // // public void saveToFile(ConfigurationLoader<CommentedConfigurationNode> configLoader) throws ObjectMappingException, IOException { // this.saveToNode(node); // configLoader.save(node); // } // // public void saveToNode(ConfigurationNode node) throws ObjectMappingException { // MAPPER.bind(this).serialize(node); // } // // public ItemsNode getItems() { // return itemsNode; // } // // public String getDataStore() { // return dataStore; // } // // public void setDataStore(String dataStore) { // this.dataStore = dataStore; // } // // public ChunksAmountNode getDefaultChunksAmount() { // return defaultChunksNode; // } // // public void setDefaultChunksAmount(ChunksAmountNode defaultChunksNode) { // this.defaultChunksNode = defaultChunksNode; // } // // public MaxChunksAmountNode getMaxChunksAmount() { // return maxChunksNode; // } // // public void setMaxChunksAmount(MaxChunksAmountNode maxChunksNode) { // this.maxChunksNode = maxChunksNode; // } // // public int getMaxHoursOffline() { // return maxHoursOffline; // } // // public void setMaxHoursOffline(int maxHoursOffline) { // this.maxHoursOffline = maxHoursOffline; // } // // public MySQLNode getMySQL() { // return mySQL; // } // // public String getServerName() { // return serverName; // } // // public void setServerName(String serverName) { // this.serverName = serverName; // } // } // // Path: src/main/java/guru/franz/mc/bcl/exception/UserNotFound.java // public class UserNotFound extends Exception { // // public UserNotFound() { // } // // } // // Path: src/main/java/guru/franz/mc/bcl/utils/Utilities.java // public class Utilities { // // public static User getUserFromUUID(UUID uuid) throws UserNotFound { // return Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid).orElseThrow(UserNotFound::new); // } // // public static int getOptionOrDefault(User player, String key, int defaultValue) { // Optional<String> option = player.getOption(key); // return option.map(Integer::parseInt).orElse(defaultValue); // // } // } // Path: src/main/java/guru/franz/mc/bcl/model/PlayerData.java import guru.franz.mc.bcl.config.Config; import guru.franz.mc.bcl.exception.UserNotFound; import guru.franz.mc.bcl.utils.Utilities; import org.spongepowered.api.entity.living.player.User; import java.util.UUID; package guru.franz.mc.bcl.model; public class PlayerData { private final UUID playerId; private int alwaysOnChunksAmount; private int onlineOnlyChunksAmount; public PlayerData(UUID playerId) throws UserNotFound { this.playerId = playerId; User player = Utilities.getUserFromUUID(playerId);
this.alwaysOnChunksAmount = Utilities.getOptionOrDefault(player, "bcl.world", Config.getInstance().getDefaultChunksAmount().getWorld());
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/datastore/DataStoreManager.java
// Path: src/main/java/guru/franz/mc/bcl/exception/Exception.java // public class Exception extends java.lang.Exception { // // public Exception() { // } // // public Exception(Throwable cause) { // super(cause); // } // // public Exception(String message) { // super(message); // } // }
import guru.franz.mc.bcl.exception.Exception; import java.util.HashMap; import java.util.Map;
package guru.franz.mc.bcl.datastore; /** * DataStore manager<br> * See IDataStore interface if you want to implement your custom DataStore */ public final class DataStoreManager { private static final Map<String, Class<? extends IDataStore>> dataStores = new HashMap<>(); private static IDataStore dataStore; /** * Register a new DataStore. This should be run at onLoad()<br> * * @param dataStoreId ID that identifies this DataStore <br> * @param dataStoreClass a class that implements IDataStore */ public static void registerDataStore(String dataStoreId, Class<? extends IDataStore> dataStoreClass) { dataStores.put(dataStoreId, dataStoreClass); } /** * Sets and instantiate the DataStore */
// Path: src/main/java/guru/franz/mc/bcl/exception/Exception.java // public class Exception extends java.lang.Exception { // // public Exception() { // } // // public Exception(Throwable cause) { // super(cause); // } // // public Exception(String message) { // super(message); // } // } // Path: src/main/java/guru/franz/mc/bcl/datastore/DataStoreManager.java import guru.franz.mc.bcl.exception.Exception; import java.util.HashMap; import java.util.Map; package guru.franz.mc.bcl.datastore; /** * DataStore manager<br> * See IDataStore interface if you want to implement your custom DataStore */ public final class DataStoreManager { private static final Map<String, Class<? extends IDataStore>> dataStores = new HashMap<>(); private static IDataStore dataStore; /** * Register a new DataStore. This should be run at onLoad()<br> * * @param dataStoreId ID that identifies this DataStore <br> * @param dataStoreClass a class that implements IDataStore */ public static void registerDataStore(String dataStoreId, Class<? extends IDataStore> dataStoreClass) { dataStores.put(dataStoreId, dataStoreClass); } /** * Sets and instantiate the DataStore */
public static void setDataStoreInstance(String dataStoreId) throws Exception {
KasperFranz/BetterChunkLoader
src/main/java/guru/franz/mc/bcl/command/elements/SimpleValueElement.java
// Path: src/main/java/guru/franz/mc/bcl/utils/Messages.java // public final class Messages { // // public static final String CREATE_CHUNKLOADER_LOG = "%s created a %s at %s with radius %s"; // public static final String CREATE_CHUNKLOADER_USER = "Chunk loader created to cover %s chunks."; // public static final String EDIT_CHUNKLOADER_LOG_OTHER = "%s edited %s's chunk loader at %s's radius from %s to %s,"; // public static final String EDIT_CHUNKLOADER_LOG_SELF = "%s edited their chunk loader at %s's radius from %s to %s."; // public static final String EDIT_CHUNKLOADER_USER = "The chunk loader is now updated to cover %s chunks."; // public static final String DELETE_CHUNKLOADER_LOG_OTHER = "%s deleted %s's chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_LOG_SELF = "%s deleted their chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_OTHER = "You just removed %s's chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_INFORM = "%s just removed your chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_SELF = "You just removed your chunk loader at %s."; // public static final String LIST_CHUNKLOADERS_TITLE = "%s chunk loaders"; // public static final String LIST_NO_CHUNKLOADERS = "%s has no chunk loaders"; // public static final String LIST_PERMISSION_ERROR = "You do not have permission to delete this chunk loader"; // public static final String LIST_ACTION_DELETE = "[DEL]"; // public static final String LIST_ACTION_DELETE_HOVER = "Click to delete the chunk loader"; // public static final String LIST_ACTION_TELEPORT = "[TP]"; // public static final String LIST_ACTION_TELEPORT_HOVER = "Click to teleport on top of the chunk loader"; // public static final String CMD_DELETE_OTHER_NO_CHUNKLOADERS = "%s does not have any chunk loaders."; // public static final String CMD_DELETE_OTHER_SUCCESS = "All %d chunk loaders placed by %s have been removed!"; // public static final String CMD_DELETE_OTHER_SUCCESS_LOG = "%s deleted all %s's chunk loaders."; // public static final String CMD_DELETE_OTHER_PERMISSION = "You do not have permission to delete others chunk loaders."; // public static final String CMD_DELETE_OWN_NO_CHUNKLOADERS = "You do not have any chunk loaders to delete."; // public static final String CMD_DELETE_OWN_SUCCESS = "All %d of your chunk loaders have been removed!"; // public static final String CMD_DELETE_OWN_SUCCESS_LOG = "%s deleted all their chunk loaders."; // public static final String CMD_DELETE_OWN_PERMISSION = "You do not have permission to delete your own chunk loaders."; // public static final String CMD_DELETE_OWN_CONFIRM = "Are you sure you want to delete all of your chunk loaders"; // public static final String PLUGIN_DISABLED_DATASTORE = // "The plugin is disabled as we could not connect to the datastore - please verify the password and check database information. once " // + "correct you can run /bcl reload."; // public static final String ARGUMENT_INVALID = "%s is not a valid argument, valid arguments: %s"; // }
import guru.franz.mc.bcl.utils.Messages; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.command.args.ArgumentParseException; import org.spongepowered.api.command.args.CommandArgs; import org.spongepowered.api.command.args.CommandContext; import org.spongepowered.api.command.args.CommandElement; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.format.TextColors; import java.util.List; import javax.annotation.Nullable;
package guru.franz.mc.bcl.command.elements; public abstract class SimpleValueElement extends CommandElement { public SimpleValueElement(Text key) { super(key); } protected abstract List<String> getValues(); @Nullable @Override protected Object parseValue(CommandSource commandSource, CommandArgs commandArgs) throws ArgumentParseException { String arg = commandArgs.next(); if (!getValues().contains(arg)) { throw commandArgs.createError( Text.of( TextColors.RED, String.format(
// Path: src/main/java/guru/franz/mc/bcl/utils/Messages.java // public final class Messages { // // public static final String CREATE_CHUNKLOADER_LOG = "%s created a %s at %s with radius %s"; // public static final String CREATE_CHUNKLOADER_USER = "Chunk loader created to cover %s chunks."; // public static final String EDIT_CHUNKLOADER_LOG_OTHER = "%s edited %s's chunk loader at %s's radius from %s to %s,"; // public static final String EDIT_CHUNKLOADER_LOG_SELF = "%s edited their chunk loader at %s's radius from %s to %s."; // public static final String EDIT_CHUNKLOADER_USER = "The chunk loader is now updated to cover %s chunks."; // public static final String DELETE_CHUNKLOADER_LOG_OTHER = "%s deleted %s's chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_LOG_SELF = "%s deleted their chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_OTHER = "You just removed %s's chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_INFORM = "%s just removed your chunk loader at %s."; // public static final String DELETE_CHUNKLOADER_USER_SELF = "You just removed your chunk loader at %s."; // public static final String LIST_CHUNKLOADERS_TITLE = "%s chunk loaders"; // public static final String LIST_NO_CHUNKLOADERS = "%s has no chunk loaders"; // public static final String LIST_PERMISSION_ERROR = "You do not have permission to delete this chunk loader"; // public static final String LIST_ACTION_DELETE = "[DEL]"; // public static final String LIST_ACTION_DELETE_HOVER = "Click to delete the chunk loader"; // public static final String LIST_ACTION_TELEPORT = "[TP]"; // public static final String LIST_ACTION_TELEPORT_HOVER = "Click to teleport on top of the chunk loader"; // public static final String CMD_DELETE_OTHER_NO_CHUNKLOADERS = "%s does not have any chunk loaders."; // public static final String CMD_DELETE_OTHER_SUCCESS = "All %d chunk loaders placed by %s have been removed!"; // public static final String CMD_DELETE_OTHER_SUCCESS_LOG = "%s deleted all %s's chunk loaders."; // public static final String CMD_DELETE_OTHER_PERMISSION = "You do not have permission to delete others chunk loaders."; // public static final String CMD_DELETE_OWN_NO_CHUNKLOADERS = "You do not have any chunk loaders to delete."; // public static final String CMD_DELETE_OWN_SUCCESS = "All %d of your chunk loaders have been removed!"; // public static final String CMD_DELETE_OWN_SUCCESS_LOG = "%s deleted all their chunk loaders."; // public static final String CMD_DELETE_OWN_PERMISSION = "You do not have permission to delete your own chunk loaders."; // public static final String CMD_DELETE_OWN_CONFIRM = "Are you sure you want to delete all of your chunk loaders"; // public static final String PLUGIN_DISABLED_DATASTORE = // "The plugin is disabled as we could not connect to the datastore - please verify the password and check database information. once " // + "correct you can run /bcl reload."; // public static final String ARGUMENT_INVALID = "%s is not a valid argument, valid arguments: %s"; // } // Path: src/main/java/guru/franz/mc/bcl/command/elements/SimpleValueElement.java import guru.franz.mc.bcl.utils.Messages; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.command.args.ArgumentParseException; import org.spongepowered.api.command.args.CommandArgs; import org.spongepowered.api.command.args.CommandContext; import org.spongepowered.api.command.args.CommandElement; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.format.TextColors; import java.util.List; import javax.annotation.Nullable; package guru.franz.mc.bcl.command.elements; public abstract class SimpleValueElement extends CommandElement { public SimpleValueElement(Text key) { super(key); } protected abstract List<String> getValues(); @Nullable @Override protected Object parseValue(CommandSource commandSource, CommandArgs commandArgs) throws ArgumentParseException { String arg = commandArgs.next(); if (!getValues().contains(arg)) { throw commandArgs.createError( Text.of( TextColors.RED, String.format(
Messages.ARGUMENT_INVALID,
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java
// Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.util.Assert;
/* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.selector; /** * @author Daniel Bechler */ public final class BeanPropertyElementSelector extends ElementSelector { private final String propertyName; public BeanPropertyElementSelector(final String propertyName) {
// Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java import de.danielbechler.util.Assert; /* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.selector; /** * @author Daniel Bechler */ public final class BeanPropertyElementSelector extends ElementSelector { private final String propertyName; public BeanPropertyElementSelector(final String propertyName) {
Assert.hasText(propertyName, "propertyName");
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/NodeHierarchyVisitor.java
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // }
import de.danielbechler.util.Strings;
if (currentLevel <= maxDepth) { print(node, currentLevel); } else { visit.dontGoDeeper(); } } else if (maxDepth < 0) { print(node, currentLevel); } } private static int calculateDepth(final DiffNode node) { int count = 0; DiffNode parentNode = node.getParentNode(); while (parentNode != null) { count++; parentNode = parentNode.getParentNode(); } return count; } protected void print(final DiffNode node, final int level) { final String nodeAsString = node.getPath() + " ===> " + node.toString();
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // } // Path: src/main/java/de/danielbechler/diff/node/NodeHierarchyVisitor.java import de.danielbechler.util.Strings; if (currentLevel <= maxDepth) { print(node, currentLevel); } else { visit.dontGoDeeper(); } } else if (maxDepth < 0) { print(node, currentLevel); } } private static int calculateDepth(final DiffNode node) { int count = 0; DiffNode parentNode = node.getParentNode(); while (parentNode != null) { count++; parentNode = parentNode.getParentNode(); } return count; } protected void print(final DiffNode node, final int level) { final String nodeAsString = node.getPath() + " ===> " + node.toString();
final String indentedNodeString = Strings.indent(level, nodeAsString);
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.path; /** * @author Daniel Bechler * @see de.danielbechler.diff.inclusion.ValueNode * @deprecated The ConfigNode provides a much more powerful way to store values for NodePaths. */ @Deprecated public class NodePathValueHolder<T> {
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.path; /** * @author Daniel Bechler * @see de.danielbechler.diff.inclusion.ValueNode * @deprecated The ConfigNode provides a much more powerful way to store values for NodePaths. */ @Deprecated public class NodePathValueHolder<T> {
private final Map<ElementSelector, NodePathValueHolder<T>> elementValueHolders = new HashMap<ElementSelector, NodePathValueHolder<T>>();
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.path; /** * @author Daniel Bechler * @see de.danielbechler.diff.inclusion.ValueNode * @deprecated The ConfigNode provides a much more powerful way to store values for NodePaths. */ @Deprecated public class NodePathValueHolder<T> { private final Map<ElementSelector, NodePathValueHolder<T>> elementValueHolders = new HashMap<ElementSelector, NodePathValueHolder<T>>(); private T value; public static <T> NodePathValueHolder<T> of(final Class<T> type) {
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.path; /** * @author Daniel Bechler * @see de.danielbechler.diff.inclusion.ValueNode * @deprecated The ConfigNode provides a much more powerful way to store values for NodePaths. */ @Deprecated public class NodePathValueHolder<T> { private final Map<ElementSelector, NodePathValueHolder<T>> elementValueHolders = new HashMap<ElementSelector, NodePathValueHolder<T>>(); private T value; public static <T> NodePathValueHolder<T> of(final Class<T> type) {
Assert.notNull(type, "type");
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map;
} else { for (final NodePathValueHolder<T> valueHolder : elementValueHolders.values()) { if (valueHolder.containsValue(value)) { return true; } } return false; } } public void collect(final Collector<T> collector) { collect(null, collector); } private void collect(final NodePath nodePath, final Collector<T> collector) { if (nodePath != null && value != null) { collector.it(nodePath, value); } for (final Map.Entry<ElementSelector, NodePathValueHolder<T>> entry : elementValueHolders.entrySet()) { final NodePath childNodePath; final ElementSelector elementSelector = entry.getKey(); final NodePathValueHolder<T> valueHolder = entry.getValue();
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/RootElementSelector.java // public final class RootElementSelector extends ElementSelector // { // private static final RootElementSelector instance = new RootElementSelector(); // // RootElementSelector() // { // } // // public static RootElementSelector getInstance() // { // return instance; // } // // @Override // public String toHumanReadableString() // { // return ""; // } // // @Override // public boolean equals(final Object element) // { // if (this == element) // { // return true; // } // if (element != null && getClass().equals(element.getClass())) // { // return true; // } // return false; // } // // @Override // public int hashCode() // { // return 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/path/NodePathValueHolder.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.RootElementSelector; import de.danielbechler.util.Assert; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; } else { for (final NodePathValueHolder<T> valueHolder : elementValueHolders.values()) { if (valueHolder.containsValue(value)) { return true; } } return false; } } public void collect(final Collector<T> collector) { collect(null, collector); } private void collect(final NodePath nodePath, final Collector<T> collector) { if (nodePath != null && value != null) { collector.it(nodePath, value); } for (final Map.Entry<ElementSelector, NodePathValueHolder<T>> entry : elementValueHolders.entrySet()) { final NodePath childNodePath; final ElementSelector elementSelector = entry.getKey(); final NodePathValueHolder<T> valueHolder = entry.getValue();
if (elementSelector == RootElementSelector.getInstance())
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/introspection/ObjectDiffProperty.java
// Path: src/main/java/de/danielbechler/diff/inclusion/Inclusion.java // public enum Inclusion // { // DEFAULT, // INCLUDED, // EXCLUDED // }
import de.danielbechler.diff.inclusion.Inclusion; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; /** * Annotation to be used on property getters in order to configure if and how they should be treated during * object comparison. * * @author Daniel Bechler */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Inherited public @interface ObjectDiffProperty { /** * Causes the {@link de.danielbechler.diff.differ.Differ Differs} to skip the marked property and all its children. * * @return <code>true</code> if the property should be ignored. * @deprecated Please use {@linkplain #inclusion()} instead. When used in conjunction with {@linkplain * #inclusion()}, the latter one will win over {@linkplain #excluded()}. */ @Deprecated public boolean excluded() default false;
// Path: src/main/java/de/danielbechler/diff/inclusion/Inclusion.java // public enum Inclusion // { // DEFAULT, // INCLUDED, // EXCLUDED // } // Path: src/main/java/de/danielbechler/diff/introspection/ObjectDiffProperty.java import de.danielbechler.diff.inclusion.Inclusion; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; /** * Annotation to be used on property getters in order to configure if and how they should be treated during * object comparison. * * @author Daniel Bechler */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Inherited public @interface ObjectDiffProperty { /** * Causes the {@link de.danielbechler.diff.differ.Differ Differs} to skip the marked property and all its children. * * @return <code>true</code> if the property should be ignored. * @deprecated Please use {@linkplain #inclusion()} instead. When used in conjunction with {@linkplain * #inclusion()}, the latter one will win over {@linkplain #excluded()}. */ @Deprecated public boolean excluded() default false;
public Inclusion inclusion() default Inclusion.DEFAULT;
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/introspection/InstanceFactoryFallbackDecorator.java
// Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.instantiation.InstanceFactory; import de.danielbechler.diff.instantiation.PublicNoArgsConstructorInstanceFactory; import de.danielbechler.util.Assert;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; class InstanceFactoryFallbackDecorator implements InstanceFactory { private final InstanceFactory fallbackInstanceFactory = new PublicNoArgsConstructorInstanceFactory(); private final InstanceFactory instanceFactory; InstanceFactoryFallbackDecorator(final InstanceFactory instanceFactory) {
// Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/introspection/InstanceFactoryFallbackDecorator.java import de.danielbechler.diff.instantiation.InstanceFactory; import de.danielbechler.diff.instantiation.PublicNoArgsConstructorInstanceFactory; import de.danielbechler.util.Assert; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; class InstanceFactoryFallbackDecorator implements InstanceFactory { private final InstanceFactory fallbackInstanceFactory = new PublicNoArgsConstructorInstanceFactory(); private final InstanceFactory instanceFactory; InstanceFactoryFallbackDecorator(final InstanceFactory instanceFactory) {
Assert.notNull(instanceFactory, "instanceFactory");
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map;
/* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.access; /** * @author Daniel Bechler */ public final class MapEntryAccessor implements Accessor { private final Object referenceKey; public MapEntryAccessor(final Object referenceKey) {
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map; /* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.access; /** * @author Daniel Bechler */ public final class MapEntryAccessor implements Accessor { private final Object referenceKey; public MapEntryAccessor(final Object referenceKey) {
Assert.notNull(referenceKey, "referenceKey");
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map;
} return null; } @Override public int hashCode() { return referenceKey.hashCode(); } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } return referenceKey.equals(((MapEntryAccessor) o).referenceKey); } @Override public String toString() { return "map key " + getElementSelector(); }
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map; } return null; } @Override public int hashCode() { return referenceKey.hashCode(); } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } return referenceKey.equals(((MapEntryAccessor) o).referenceKey); } @Override public String toString() { return "map key " + getElementSelector(); }
public ElementSelector getElementSelector()
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map;
} @Override public int hashCode() { return referenceKey.hashCode(); } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } return referenceKey.equals(((MapEntryAccessor) o).referenceKey); } @Override public String toString() { return "map key " + getElementSelector(); } public ElementSelector getElementSelector() {
// Path: src/main/java/de/danielbechler/diff/selector/ElementSelector.java // public abstract class ElementSelector // { // public abstract String toHumanReadableString(); // // /** // * Must be implemented in a way so that this element can be distinguished from the other ones. // * // * @param obj The object to check equality against. // * @return <code>true</code> is the given object equals this one, otherwise <code>false</code>. // */ // public abstract boolean equals(Object obj); // // /** // * Make sure to implement this properly. If two elements are equal, their hash code must be equal as well. // * However, it is absolutely okay if two unequal elements return the same hash code. A simple implementation // * could just return <code>0</code>. // * // * @return The hash code of this element. // */ // public abstract int hashCode(); // // /** // * The string representation will only be used to print readable property paths for debug purposes. // * // * @return A string representation of this element for debug purposes. // */ // public final String toString() // { // return toHumanReadableString(); // } // } // // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java // public final class MapKeyElementSelector extends ElementSelector // { // private final Object key; // // public MapKeyElementSelector(final Object key) // { // this.key = key; // } // // /** // * @deprecated Low-level API. Don't use in production code. May be removed in future versions. // */ // @SuppressWarnings({"UnusedDeclaration"}) // @Deprecated // public Object getKey() // { // return key; // } // // @Override // public String toHumanReadableString() // { // return "{" + Strings.toSingleLineString(key) + "}"; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final MapKeyElementSelector that = (MapKeyElementSelector) o; // // if (key != null ? !key.equals(that.key) : that.key != null) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return key != null ? key.hashCode() : 0; // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/access/MapEntryAccessor.java import de.danielbechler.diff.selector.ElementSelector; import de.danielbechler.diff.selector.MapKeyElementSelector; import de.danielbechler.util.Assert; import java.util.Map; } @Override public int hashCode() { return referenceKey.hashCode(); } @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } return referenceKey.equals(((MapEntryAccessor) o).referenceKey); } @Override public String toString() { return "map key " + getElementSelector(); } public ElementSelector getElementSelector() {
return new MapKeyElementSelector(referenceKey);
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/NodeQueryService.java
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // }
import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver,
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // } // Path: src/main/java/de/danielbechler/diff/NodeQueryService.java import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver,
IsIntrospectableResolver,
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/NodeQueryService.java
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // }
import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver,
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // } // Path: src/main/java/de/danielbechler/diff/NodeQueryService.java import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver,
IsReturnableResolver,
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/NodeQueryService.java
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // }
import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver, IsReturnableResolver,
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // } // Path: src/main/java/de/danielbechler/diff/NodeQueryService.java import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver, IsReturnableResolver,
ComparisonStrategyResolver,
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/NodeQueryService.java
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // }
import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver, IsReturnableResolver, ComparisonStrategyResolver,
// Path: src/main/java/de/danielbechler/diff/category/CategoryResolver.java // public interface CategoryResolver // { // Set<String> resolveCategories(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/ComparisonStrategyResolver.java // public interface ComparisonStrategyResolver // { // ComparisonStrategy resolveComparisonStrategy(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/comparison/PrimitiveDefaultValueModeResolver.java // public interface PrimitiveDefaultValueModeResolver // { // PrimitiveDefaultValueMode resolvePrimitiveDefaultValueMode(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/filtering/IsReturnableResolver.java // public interface IsReturnableResolver // { // boolean isReturnable(DiffNode node); // } // // Path: src/main/java/de/danielbechler/diff/introspection/IsIntrospectableResolver.java // public interface IsIntrospectableResolver // { // /** // * @return Returns <code>true</code> if the object represented by the given node should be compared via // * introspection. // */ // boolean isIntrospectable(DiffNode node); // } // Path: src/main/java/de/danielbechler/diff/NodeQueryService.java import de.danielbechler.diff.category.CategoryResolver; import de.danielbechler.diff.comparison.ComparisonStrategyResolver; import de.danielbechler.diff.comparison.PrimitiveDefaultValueModeResolver; import de.danielbechler.diff.filtering.IsReturnableResolver; import de.danielbechler.diff.inclusion.IsIgnoredResolver; import de.danielbechler.diff.introspection.IsIntrospectableResolver; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff; /** * Created by Daniel Bechler. */ public interface NodeQueryService extends CategoryResolver, IsIntrospectableResolver, IsIgnoredResolver, IsReturnableResolver, ComparisonStrategyResolver,
PrimitiveDefaultValueModeResolver
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // }
import de.danielbechler.util.Strings;
/* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.selector; /** * @author Daniel Bechler */ public final class MapKeyElementSelector extends ElementSelector { private final Object key; public MapKeyElementSelector(final Object key) { this.key = key; } /** * @deprecated Low-level API. Don't use in production code. May be removed in future versions. */ @SuppressWarnings({"UnusedDeclaration"}) @Deprecated public Object getKey() { return key; } @Override public String toHumanReadableString() {
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // } // Path: src/main/java/de/danielbechler/diff/selector/MapKeyElementSelector.java import de.danielbechler.util.Strings; /* * Copyright 2012 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.selector; /** * @author Daniel Bechler */ public final class MapKeyElementSelector extends ElementSelector { private final Object key; public MapKeyElementSelector(final Object key) { this.key = key; } /** * @deprecated Low-level API. Don't use in production code. May be removed in future versions. */ @SuppressWarnings({"UnusedDeclaration"}) @Deprecated public Object getKey() { return key; } @Override public String toHumanReadableString() {
return "{" + Strings.toSingleLineString(key) + "}";
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/comparison/ObjectDiffPropertyComparisonStrategyResolver.java
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // }
import de.danielbechler.diff.introspection.ObjectDiffEqualsOnlyType; import de.danielbechler.diff.introspection.ObjectDiffProperty; import de.danielbechler.util.Strings;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.comparison; /** * Created by Daniel Bechler. */ public class ObjectDiffPropertyComparisonStrategyResolver { public static final ObjectDiffPropertyComparisonStrategyResolver instance; static { instance = new ObjectDiffPropertyComparisonStrategyResolver(); } private ObjectDiffPropertyComparisonStrategyResolver() { } @SuppressWarnings("MethodMayBeStatic") public ComparisonStrategy comparisonStrategyForAnnotation(final ObjectDiffProperty annotation) { if (annotation == null || !annotation.equalsOnly()) { return null; }
// Path: src/main/java/de/danielbechler/util/Strings.java // public class Strings // { // private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\s*\\n\\s*"); // // private Strings() // { // } // // @SuppressWarnings("SizeReplaceableByIsEmpty") // String.isEmpty() is a Java 1.6 feature // public static boolean hasText(final String s) // { // return s != null && s.trim().length() != 0; // } // // public static boolean isEmpty(final String s) // { // return !hasText(s); // } // // /** // * Joins all non-null elements of the given <code>elements</code> into one String. // * // * @param delimiter Inserted as separator between consecutive elements. // * @param elements The elements to join. // * // * @return A long string containing all non-null elements. // */ // public static String join(final String delimiter, final Object... elements) // { // final StringBuilder sb = new StringBuilder(); // for (final Object part : elements) // { // if (part == null) // { // continue; // } // if (sb.length() > 0) // { // sb.append(delimiter); // } // sb.append(part.toString()); // } // return sb.toString(); // } // // /** // * Same as {@link #join(String, Object...)} but with a {@link Collection} instead of an Array for the // * elements. // * // * @see #join(String, java.util.Collection) // */ // public static String join(final String delimiter, final Collection<?> elements) // { // if (elements == null || elements.isEmpty()) // { // return ""; // } // return join(delimiter, elements.toArray(new Object[elements.size()])); // } // // public static String toSingleLineString(final Object object) // { // if (object != null) // { // final String s = object.toString().trim(); // final Matcher matcher = LINE_BREAK_PATTERN.matcher(s); // return matcher.replaceAll(" \\\\ "); // } // return null; // } // // public static String indent(final int times, final String text) // { // final StringBuilder sb = new StringBuilder(); // for (int i = 0; i < times; i++) // { // sb.append(" "); // } // sb.append(text); // return sb.toString(); // } // } // Path: src/main/java/de/danielbechler/diff/comparison/ObjectDiffPropertyComparisonStrategyResolver.java import de.danielbechler.diff.introspection.ObjectDiffEqualsOnlyType; import de.danielbechler.diff.introspection.ObjectDiffProperty; import de.danielbechler.util.Strings; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.comparison; /** * Created by Daniel Bechler. */ public class ObjectDiffPropertyComparisonStrategyResolver { public static final ObjectDiffPropertyComparisonStrategyResolver instance; static { instance = new ObjectDiffPropertyComparisonStrategyResolver(); } private ObjectDiffPropertyComparisonStrategyResolver() { } @SuppressWarnings("MethodMayBeStatic") public ComparisonStrategy comparisonStrategyForAnnotation(final ObjectDiffProperty annotation) { if (annotation == null || !annotation.equalsOnly()) { return null; }
if (Strings.hasText(annotation.equalsOnlyValueProviderMethod()))
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java
// Path: src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java // public final class BeanPropertyElementSelector extends ElementSelector // { // private final String propertyName; // // public BeanPropertyElementSelector(final String propertyName) // { // Assert.hasText(propertyName, "propertyName"); // this.propertyName = propertyName; // } // // public String getPropertyName() // { // return propertyName; // } // // @Override // public String toHumanReadableString() // { // return propertyName; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final BeanPropertyElementSelector that = (BeanPropertyElementSelector) o; // // if (!propertyName.equals(that.propertyName)) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return propertyName.hashCode(); // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import static java.util.Arrays.asList; import de.danielbechler.diff.access.PropertyAwareAccessor; import de.danielbechler.diff.selector.BeanPropertyElementSelector; import de.danielbechler.util.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet;
/* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; public class PropertyAccessor implements PropertyAwareAccessor { private static final Logger logger = LoggerFactory.getLogger(PropertyAccessor.class); private final String propertyName; private final Class<?> type; private final Method readMethod; private final Method writeMethod; public PropertyAccessor(final String propertyName, final Method readMethod, final Method writeMethod) {
// Path: src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java // public final class BeanPropertyElementSelector extends ElementSelector // { // private final String propertyName; // // public BeanPropertyElementSelector(final String propertyName) // { // Assert.hasText(propertyName, "propertyName"); // this.propertyName = propertyName; // } // // public String getPropertyName() // { // return propertyName; // } // // @Override // public String toHumanReadableString() // { // return propertyName; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final BeanPropertyElementSelector that = (BeanPropertyElementSelector) o; // // if (!propertyName.equals(that.propertyName)) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return propertyName.hashCode(); // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java import static java.util.Arrays.asList; import de.danielbechler.diff.access.PropertyAwareAccessor; import de.danielbechler.diff.selector.BeanPropertyElementSelector; import de.danielbechler.util.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet; /* * Copyright 2014 Daniel Bechler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.danielbechler.diff.introspection; public class PropertyAccessor implements PropertyAwareAccessor { private static final Logger logger = LoggerFactory.getLogger(PropertyAccessor.class); private final String propertyName; private final Class<?> type; private final Method readMethod; private final Method writeMethod; public PropertyAccessor(final String propertyName, final Method readMethod, final Method writeMethod) {
Assert.notNull(propertyName, "propertyName");
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java
// Path: src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java // public final class BeanPropertyElementSelector extends ElementSelector // { // private final String propertyName; // // public BeanPropertyElementSelector(final String propertyName) // { // Assert.hasText(propertyName, "propertyName"); // this.propertyName = propertyName; // } // // public String getPropertyName() // { // return propertyName; // } // // @Override // public String toHumanReadableString() // { // return propertyName; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final BeanPropertyElementSelector that = (BeanPropertyElementSelector) o; // // if (!propertyName.equals(that.propertyName)) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return propertyName.hashCode(); // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // }
import static java.util.Arrays.asList; import de.danielbechler.diff.access.PropertyAwareAccessor; import de.danielbechler.diff.selector.BeanPropertyElementSelector; import de.danielbechler.util.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet;
{ return annotationClass.cast(annotation); } } return null; } /** * @return The annotations of the getter used to access this property. */ public Set<Annotation> getReadMethodAnnotations() { return new LinkedHashSet<Annotation>(asList(readMethod.getAnnotations())); } public <T extends Annotation> T getReadMethodAnnotation(final Class<T> annotationClass) { final Set<? extends Annotation> annotations = getReadMethodAnnotations(); assert (annotations != null) : "Something is wrong here. " + "The contract of getReadAnnotations() guarantees a non-null return value."; for (final Annotation annotation : annotations) { if (annotationClass.isAssignableFrom(annotation.annotationType())) { return annotationClass.cast(annotation); } } return null; }
// Path: src/main/java/de/danielbechler/diff/selector/BeanPropertyElementSelector.java // public final class BeanPropertyElementSelector extends ElementSelector // { // private final String propertyName; // // public BeanPropertyElementSelector(final String propertyName) // { // Assert.hasText(propertyName, "propertyName"); // this.propertyName = propertyName; // } // // public String getPropertyName() // { // return propertyName; // } // // @Override // public String toHumanReadableString() // { // return propertyName; // } // // @Override // public boolean equals(final Object o) // { // if (this == o) // { // return true; // } // if (o == null || getClass() != o.getClass()) // { // return false; // } // // final BeanPropertyElementSelector that = (BeanPropertyElementSelector) o; // // if (!propertyName.equals(that.propertyName)) // { // return false; // } // // return true; // } // // @Override // public int hashCode() // { // return propertyName.hashCode(); // } // } // // Path: src/main/java/de/danielbechler/util/Assert.java // public class Assert // { // private Assert() // { // } // // public static void equalTypesOrNull(final Object... objects) // { // final Collection<Class<?>> types = Classes.typesOf(objects); // Class<?> previousType = null; // for (final Class<?> type : types) // { // if (previousType != null && !type.equals(previousType)) // { // throw new IllegalArgumentException("The given objects should be either null or of the same type ('" + previousType + "') = " + types); // } // previousType = type; // } // } // // public static void notNull(final Object object, final String name) // { // if (object == null) // { // throw new IllegalArgumentException("'" + name + "' must not be null"); // } // } // // public static void notEmpty(final Collection<?> collection, final String name) // { // if (Collections.isEmpty(collection)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // // /** // * Same as {@link #hasText(String, String)}. // * // * @see #hasText(String, String) // */ // public static void notEmpty(final String text, final String name) throws IllegalArgumentException // { // hasText(text, name); // } // // /** // * Ensures that the given <code>value</code> contains characters. // * // * @param value The value to check. // * @param name The name of the variable (used for the exception message). // * // * @throws IllegalArgumentException If the given value is <code>null</code> or doesn't contain any non-whitespace // * characters. // */ // public static void hasText(final String value, final String name) throws IllegalArgumentException // { // if (Strings.isEmpty(name)) // Yo dawg, I heard you like assertions, so I put an assertion in your assertion // { // throw new IllegalArgumentException("'name' must not be null or empty"); // } // if (Strings.isEmpty(value)) // { // throw new IllegalArgumentException("'" + name + "' must not be null or empty"); // } // } // } // Path: src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java import static java.util.Arrays.asList; import de.danielbechler.diff.access.PropertyAwareAccessor; import de.danielbechler.diff.selector.BeanPropertyElementSelector; import de.danielbechler.util.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet; { return annotationClass.cast(annotation); } } return null; } /** * @return The annotations of the getter used to access this property. */ public Set<Annotation> getReadMethodAnnotations() { return new LinkedHashSet<Annotation>(asList(readMethod.getAnnotations())); } public <T extends Annotation> T getReadMethodAnnotation(final Class<T> annotationClass) { final Set<? extends Annotation> annotations = getReadMethodAnnotations(); assert (annotations != null) : "Something is wrong here. " + "The contract of getReadAnnotations() guarantees a non-null return value."; for (final Annotation annotation : annotations) { if (annotationClass.isAssignableFrom(annotation.annotationType())) { return annotationClass.cast(annotation); } } return null; }
public BeanPropertyElementSelector getElementSelector()
zillachan/AndZilla
app/src/main/java/com/zilla/andzilla/log/Normal.java
// Path: libzilla/src/main/java/ggx/com/libzilla/util/BaseViewHolder.java // public abstract class BaseViewHolder<M extends ItemModel> extends RecyclerView.ViewHolder { // // private int viewType; // public BaseViewHolder(View itemView) { // super(itemView); // initView(itemView); // } // // public int getViewType() { // return viewType; // } // // public void setViewType(int viewType) { // this.viewType = viewType; // } // // public void setOnItemClickListener(final MutilRecycleAdapter.OnItemClickListener listener, final int position){ // super.itemView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // if(listener!=null){ // listener.onItemClick(position); // } // } // }); // } // public void setOnItemLongClickListener(final MutilRecycleAdapter.OnItemLongClickListener listener, final int position){ // if(!super.itemView.isLongClickable()){ // super.itemView.setLongClickable(true); // } // super.itemView.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // if(listener!=null){ // listener.onItemLongClick(position); // } // return false; // } // }); // } // // public abstract void initView(View itemView); // // public abstract void setLogic(M model, int position,int itemType); // } // // Path: libzilla/src/main/java/ggx/com/libzilla/util/Visitor.java // public interface Visitor { // // //创建需要访问的ViewHodler // BaseViewHolder createViewHolder(View itemView); // //访问者需要提供的布局 // int getViewLayout(); // }
import android.view.View; import android.widget.TextView; import com.zilla.andzilla.R; import ggx.com.libzilla.util.BaseViewHolder; import ggx.com.libzilla.util.Visitor;
package com.zilla.andzilla.log; /** * @author jerry.Guan * created by 2017/4/10 */ public class Normal implements Visitor{ @Override
// Path: libzilla/src/main/java/ggx/com/libzilla/util/BaseViewHolder.java // public abstract class BaseViewHolder<M extends ItemModel> extends RecyclerView.ViewHolder { // // private int viewType; // public BaseViewHolder(View itemView) { // super(itemView); // initView(itemView); // } // // public int getViewType() { // return viewType; // } // // public void setViewType(int viewType) { // this.viewType = viewType; // } // // public void setOnItemClickListener(final MutilRecycleAdapter.OnItemClickListener listener, final int position){ // super.itemView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // if(listener!=null){ // listener.onItemClick(position); // } // } // }); // } // public void setOnItemLongClickListener(final MutilRecycleAdapter.OnItemLongClickListener listener, final int position){ // if(!super.itemView.isLongClickable()){ // super.itemView.setLongClickable(true); // } // super.itemView.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // if(listener!=null){ // listener.onItemLongClick(position); // } // return false; // } // }); // } // // public abstract void initView(View itemView); // // public abstract void setLogic(M model, int position,int itemType); // } // // Path: libzilla/src/main/java/ggx/com/libzilla/util/Visitor.java // public interface Visitor { // // //创建需要访问的ViewHodler // BaseViewHolder createViewHolder(View itemView); // //访问者需要提供的布局 // int getViewLayout(); // } // Path: app/src/main/java/com/zilla/andzilla/log/Normal.java import android.view.View; import android.widget.TextView; import com.zilla.andzilla.R; import ggx.com.libzilla.util.BaseViewHolder; import ggx.com.libzilla.util.Visitor; package com.zilla.andzilla.log; /** * @author jerry.Guan * created by 2017/4/10 */ public class Normal implements Visitor{ @Override
public BaseViewHolder createViewHolder(View itemView) {
zillachan/AndZilla
app/src/main/java/com/zilla/andzilla/TestLifeCycle1.java
// Path: libzilla/src/main/java/ggx/com/libzilla/core/log/AppLog.java // public class AppLog { // // private static AbsLog log; // private static FileLog fileLog; // // private AppLog(){} // static { // log=new AbsLog(); // fileLog=new FileLog(log); // } // // //配置Debug开关 // public static void setDebug(boolean debug) { // AppLog.log.setDebug(debug); // } // // public static AbsLog getLog() { // return log; // } // // public static FileLog getfileLog() { // return fileLog; // } // // public static void print(Object o){ // log.i(buildMessage(String.valueOf(o))); // } // public static void print(double x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(int x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(boolean x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(short x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(float x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(long x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char[] x){ // log.i(buildMessage(String.valueOf(x))); // } // // public static void print(Object ...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void i(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void e(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void w(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void d(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // // public static void i(String str){ // log.i(buildMessage(str)); // } // public static void w(String str){ // log.w(buildMessage(str)); // } // public static void d(String str){ // log.d(buildMessage(str)); // } // public static void e(String str){ // log.e(buildMessage(str)); // } // // public static void i(String str,Throwable tr){ // log.i(buildMessage(str), tr); // } // public static void w(String str,Throwable tr){ // log.w(buildMessage(str), tr); // } // public static void d(String str,Throwable tr){ // log.d(buildMessage(str), tr); // } // public static void e(String str,Throwable tr){ // log.e(buildMessage(str), tr); // } // // private static String buildMessage(String log){ // StackTraceElement caller = new Throwable().fillInStackTrace() // .getStackTrace()[2]; // StringBuilder builder=new StringBuilder(); // builder.append(caller.toString()); // builder.append(System.getProperty("line.separator")); // builder.append(log); // return builder.toString(); // } // // //****************权限申请用*********************** // public static FileLog apply(AppCompatActivity appCompatActivity){ // fileLog.apply(appCompatActivity); // return fileLog; // } // // public static FileLog apply(Fragment fragment){ // fileLog.apply(fragment); // return fileLog; // } // // //******************华丽的分割线************************ // }
import android.app.Activity; import android.app.Application; import android.os.Bundle; import ggx.com.libzilla.core.log.AppLog;
package com.zilla.andzilla; /** * Created by jerry.guan on 5/12/2017. */ public class TestLifeCycle1 implements Application.ActivityLifecycleCallbacks{ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// Path: libzilla/src/main/java/ggx/com/libzilla/core/log/AppLog.java // public class AppLog { // // private static AbsLog log; // private static FileLog fileLog; // // private AppLog(){} // static { // log=new AbsLog(); // fileLog=new FileLog(log); // } // // //配置Debug开关 // public static void setDebug(boolean debug) { // AppLog.log.setDebug(debug); // } // // public static AbsLog getLog() { // return log; // } // // public static FileLog getfileLog() { // return fileLog; // } // // public static void print(Object o){ // log.i(buildMessage(String.valueOf(o))); // } // public static void print(double x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(int x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(boolean x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(short x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(float x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(long x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char[] x){ // log.i(buildMessage(String.valueOf(x))); // } // // public static void print(Object ...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void i(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void e(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void w(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void d(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // // public static void i(String str){ // log.i(buildMessage(str)); // } // public static void w(String str){ // log.w(buildMessage(str)); // } // public static void d(String str){ // log.d(buildMessage(str)); // } // public static void e(String str){ // log.e(buildMessage(str)); // } // // public static void i(String str,Throwable tr){ // log.i(buildMessage(str), tr); // } // public static void w(String str,Throwable tr){ // log.w(buildMessage(str), tr); // } // public static void d(String str,Throwable tr){ // log.d(buildMessage(str), tr); // } // public static void e(String str,Throwable tr){ // log.e(buildMessage(str), tr); // } // // private static String buildMessage(String log){ // StackTraceElement caller = new Throwable().fillInStackTrace() // .getStackTrace()[2]; // StringBuilder builder=new StringBuilder(); // builder.append(caller.toString()); // builder.append(System.getProperty("line.separator")); // builder.append(log); // return builder.toString(); // } // // //****************权限申请用*********************** // public static FileLog apply(AppCompatActivity appCompatActivity){ // fileLog.apply(appCompatActivity); // return fileLog; // } // // public static FileLog apply(Fragment fragment){ // fileLog.apply(fragment); // return fileLog; // } // // //******************华丽的分割线************************ // } // Path: app/src/main/java/com/zilla/andzilla/TestLifeCycle1.java import android.app.Activity; import android.app.Application; import android.os.Bundle; import ggx.com.libzilla.core.log.AppLog; package com.zilla.andzilla; /** * Created by jerry.guan on 5/12/2017. */ public class TestLifeCycle1 implements Application.ActivityLifecycleCallbacks{ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
AppLog.print("TestLifeCycle1 oncreat测试成功");
zillachan/AndZilla
app/src/main/java/com/zilla/andzilla/log/Special.java
// Path: libzilla/src/main/java/ggx/com/libzilla/util/BaseViewHolder.java // public abstract class BaseViewHolder<M extends ItemModel> extends RecyclerView.ViewHolder { // // private int viewType; // public BaseViewHolder(View itemView) { // super(itemView); // initView(itemView); // } // // public int getViewType() { // return viewType; // } // // public void setViewType(int viewType) { // this.viewType = viewType; // } // // public void setOnItemClickListener(final MutilRecycleAdapter.OnItemClickListener listener, final int position){ // super.itemView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // if(listener!=null){ // listener.onItemClick(position); // } // } // }); // } // public void setOnItemLongClickListener(final MutilRecycleAdapter.OnItemLongClickListener listener, final int position){ // if(!super.itemView.isLongClickable()){ // super.itemView.setLongClickable(true); // } // super.itemView.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // if(listener!=null){ // listener.onItemLongClick(position); // } // return false; // } // }); // } // // public abstract void initView(View itemView); // // public abstract void setLogic(M model, int position,int itemType); // } // // Path: libzilla/src/main/java/ggx/com/libzilla/util/Visitor.java // public interface Visitor { // // //创建需要访问的ViewHodler // BaseViewHolder createViewHolder(View itemView); // //访问者需要提供的布局 // int getViewLayout(); // }
import android.view.View; import android.widget.TextView; import com.zilla.andzilla.R; import ggx.com.libzilla.util.BaseViewHolder; import ggx.com.libzilla.util.Visitor;
package com.zilla.andzilla.log; /** * @author jerry.Guan * created by 2017/4/10 */ public class Special implements Visitor{ @Override
// Path: libzilla/src/main/java/ggx/com/libzilla/util/BaseViewHolder.java // public abstract class BaseViewHolder<M extends ItemModel> extends RecyclerView.ViewHolder { // // private int viewType; // public BaseViewHolder(View itemView) { // super(itemView); // initView(itemView); // } // // public int getViewType() { // return viewType; // } // // public void setViewType(int viewType) { // this.viewType = viewType; // } // // public void setOnItemClickListener(final MutilRecycleAdapter.OnItemClickListener listener, final int position){ // super.itemView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // if(listener!=null){ // listener.onItemClick(position); // } // } // }); // } // public void setOnItemLongClickListener(final MutilRecycleAdapter.OnItemLongClickListener listener, final int position){ // if(!super.itemView.isLongClickable()){ // super.itemView.setLongClickable(true); // } // super.itemView.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // if(listener!=null){ // listener.onItemLongClick(position); // } // return false; // } // }); // } // // public abstract void initView(View itemView); // // public abstract void setLogic(M model, int position,int itemType); // } // // Path: libzilla/src/main/java/ggx/com/libzilla/util/Visitor.java // public interface Visitor { // // //创建需要访问的ViewHodler // BaseViewHolder createViewHolder(View itemView); // //访问者需要提供的布局 // int getViewLayout(); // } // Path: app/src/main/java/com/zilla/andzilla/log/Special.java import android.view.View; import android.widget.TextView; import com.zilla.andzilla.R; import ggx.com.libzilla.util.BaseViewHolder; import ggx.com.libzilla.util.Visitor; package com.zilla.andzilla.log; /** * @author jerry.Guan * created by 2017/4/10 */ public class Special implements Visitor{ @Override
public BaseViewHolder createViewHolder(View itemView) {
zillachan/AndZilla
app/src/main/java/com/zilla/andzilla/AndZillaApplication.java
// Path: libzilla/src/main/java/ggx/com/libzilla/design/lifecycle/ActivityLifeCycle.java // public class ActivityLifeCycle implements ActivityLifecycleCallbacks { // // ILifecycleManager manager; // // // public ActivityLifeCycle() { // try { // Class<?> clazz=Class.forName("com.ggx.lib.lifecycle.LifecycleManager"); // manager= (ILifecycleManager) clazz.newInstance(); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // // private ActivityLifecycleCallbacks getLifeCycle(Activity activity){ // String fullName=activity.getClass().getName(); // //通过activity的名字获取对应的生命周期注册对象 // if(manager!=null){ // return manager.getLifecycle(fullName); // } // return null; // } // // @Override // public void onActivityCreated(Activity activity, Bundle savedInstanceState) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityCreated(activity,savedInstanceState); // } // } // // @Override // public void onActivityStarted(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityStarted(activity); // } // } // // @Override // public void onActivityResumed(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityResumed(activity); // } // } // // @Override // public void onActivityPaused(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityPaused(activity); // } // } // // @Override // public void onActivityStopped(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityStopped(activity); // } // } // // @Override // public void onActivitySaveInstanceState(Activity activity, Bundle outState) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivitySaveInstanceState(activity,outState); // } // } // // @Override // public void onActivityDestroyed(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityDestroyed(activity); // } // } // }
import android.app.Activity; import android.app.Application; import android.content.Context; import android.os.Bundle; import com.squareup.leakcanary.LeakCanary; import com.squareup.leakcanary.RefWatcher; import ggx.com.libzilla.design.lifecycle.ActivityLifeCycle;
package com.zilla.andzilla; /** * Created by jerry.guan on 3/28/2017. */ public class AndZillaApplication extends Application{ public static RefWatcher getRefWatcher(Context context) { AndZillaApplication application = (AndZillaApplication) context.getApplicationContext(); return application.refWatcher; } private RefWatcher refWatcher; @Override public void onCreate() { super.onCreate(); refWatcher= LeakCanary.install(this);
// Path: libzilla/src/main/java/ggx/com/libzilla/design/lifecycle/ActivityLifeCycle.java // public class ActivityLifeCycle implements ActivityLifecycleCallbacks { // // ILifecycleManager manager; // // // public ActivityLifeCycle() { // try { // Class<?> clazz=Class.forName("com.ggx.lib.lifecycle.LifecycleManager"); // manager= (ILifecycleManager) clazz.newInstance(); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // // private ActivityLifecycleCallbacks getLifeCycle(Activity activity){ // String fullName=activity.getClass().getName(); // //通过activity的名字获取对应的生命周期注册对象 // if(manager!=null){ // return manager.getLifecycle(fullName); // } // return null; // } // // @Override // public void onActivityCreated(Activity activity, Bundle savedInstanceState) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityCreated(activity,savedInstanceState); // } // } // // @Override // public void onActivityStarted(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityStarted(activity); // } // } // // @Override // public void onActivityResumed(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityResumed(activity); // } // } // // @Override // public void onActivityPaused(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityPaused(activity); // } // } // // @Override // public void onActivityStopped(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityStopped(activity); // } // } // // @Override // public void onActivitySaveInstanceState(Activity activity, Bundle outState) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivitySaveInstanceState(activity,outState); // } // } // // @Override // public void onActivityDestroyed(Activity activity) { // ActivityLifecycleCallbacks callbacks=getLifeCycle(activity); // if(callbacks!=null){ // callbacks.onActivityDestroyed(activity); // } // } // } // Path: app/src/main/java/com/zilla/andzilla/AndZillaApplication.java import android.app.Activity; import android.app.Application; import android.content.Context; import android.os.Bundle; import com.squareup.leakcanary.LeakCanary; import com.squareup.leakcanary.RefWatcher; import ggx.com.libzilla.design.lifecycle.ActivityLifeCycle; package com.zilla.andzilla; /** * Created by jerry.guan on 3/28/2017. */ public class AndZillaApplication extends Application{ public static RefWatcher getRefWatcher(Context context) { AndZillaApplication application = (AndZillaApplication) context.getApplicationContext(); return application.refWatcher; } private RefWatcher refWatcher; @Override public void onCreate() { super.onCreate(); refWatcher= LeakCanary.install(this);
registerActivityLifecycleCallbacks(new ActivityLifeCycle());
zillachan/AndZilla
app/src/main/java/com/zilla/andzilla/TestLifeCycle.java
// Path: libzilla/src/main/java/ggx/com/libzilla/core/log/AppLog.java // public class AppLog { // // private static AbsLog log; // private static FileLog fileLog; // // private AppLog(){} // static { // log=new AbsLog(); // fileLog=new FileLog(log); // } // // //配置Debug开关 // public static void setDebug(boolean debug) { // AppLog.log.setDebug(debug); // } // // public static AbsLog getLog() { // return log; // } // // public static FileLog getfileLog() { // return fileLog; // } // // public static void print(Object o){ // log.i(buildMessage(String.valueOf(o))); // } // public static void print(double x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(int x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(boolean x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(short x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(float x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(long x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char[] x){ // log.i(buildMessage(String.valueOf(x))); // } // // public static void print(Object ...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void i(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void e(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void w(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void d(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // // public static void i(String str){ // log.i(buildMessage(str)); // } // public static void w(String str){ // log.w(buildMessage(str)); // } // public static void d(String str){ // log.d(buildMessage(str)); // } // public static void e(String str){ // log.e(buildMessage(str)); // } // // public static void i(String str,Throwable tr){ // log.i(buildMessage(str), tr); // } // public static void w(String str,Throwable tr){ // log.w(buildMessage(str), tr); // } // public static void d(String str,Throwable tr){ // log.d(buildMessage(str), tr); // } // public static void e(String str,Throwable tr){ // log.e(buildMessage(str), tr); // } // // private static String buildMessage(String log){ // StackTraceElement caller = new Throwable().fillInStackTrace() // .getStackTrace()[2]; // StringBuilder builder=new StringBuilder(); // builder.append(caller.toString()); // builder.append(System.getProperty("line.separator")); // builder.append(log); // return builder.toString(); // } // // //****************权限申请用*********************** // public static FileLog apply(AppCompatActivity appCompatActivity){ // fileLog.apply(appCompatActivity); // return fileLog; // } // // public static FileLog apply(Fragment fragment){ // fileLog.apply(fragment); // return fileLog; // } // // //******************华丽的分割线************************ // }
import android.app.Activity; import android.app.Application; import android.os.Bundle; import android.util.Log; import ggx.com.libzilla.core.log.AppLog;
package com.zilla.andzilla; /** * Created by jerry.guan on 5/12/2017. */ public class TestLifeCycle implements Application.ActivityLifecycleCallbacks{ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// Path: libzilla/src/main/java/ggx/com/libzilla/core/log/AppLog.java // public class AppLog { // // private static AbsLog log; // private static FileLog fileLog; // // private AppLog(){} // static { // log=new AbsLog(); // fileLog=new FileLog(log); // } // // //配置Debug开关 // public static void setDebug(boolean debug) { // AppLog.log.setDebug(debug); // } // // public static AbsLog getLog() { // return log; // } // // public static FileLog getfileLog() { // return fileLog; // } // // public static void print(Object o){ // log.i(buildMessage(String.valueOf(o))); // } // public static void print(double x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(int x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(boolean x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(short x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(float x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(long x){ // log.i(buildMessage(String.valueOf(x))); // } // public static void print(char[] x){ // log.i(buildMessage(String.valueOf(x))); // } // // public static void print(Object ...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void i(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.i(buildMessage(sb.toString())); // } // public static void e(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void w(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // public static void d(Object...obj){ // StringBuilder sb=new StringBuilder(); // for (Object o:obj){ // sb.append(String.valueOf(o)); // } // log.e(buildMessage(sb.toString())); // } // // public static void i(String str){ // log.i(buildMessage(str)); // } // public static void w(String str){ // log.w(buildMessage(str)); // } // public static void d(String str){ // log.d(buildMessage(str)); // } // public static void e(String str){ // log.e(buildMessage(str)); // } // // public static void i(String str,Throwable tr){ // log.i(buildMessage(str), tr); // } // public static void w(String str,Throwable tr){ // log.w(buildMessage(str), tr); // } // public static void d(String str,Throwable tr){ // log.d(buildMessage(str), tr); // } // public static void e(String str,Throwable tr){ // log.e(buildMessage(str), tr); // } // // private static String buildMessage(String log){ // StackTraceElement caller = new Throwable().fillInStackTrace() // .getStackTrace()[2]; // StringBuilder builder=new StringBuilder(); // builder.append(caller.toString()); // builder.append(System.getProperty("line.separator")); // builder.append(log); // return builder.toString(); // } // // //****************权限申请用*********************** // public static FileLog apply(AppCompatActivity appCompatActivity){ // fileLog.apply(appCompatActivity); // return fileLog; // } // // public static FileLog apply(Fragment fragment){ // fileLog.apply(fragment); // return fileLog; // } // // //******************华丽的分割线************************ // } // Path: app/src/main/java/com/zilla/andzilla/TestLifeCycle.java import android.app.Activity; import android.app.Application; import android.os.Bundle; import android.util.Log; import ggx.com.libzilla.core.log.AppLog; package com.zilla.andzilla; /** * Created by jerry.guan on 5/12/2017. */ public class TestLifeCycle implements Application.ActivityLifecycleCallbacks{ @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
AppLog.print("哈哈哈哈 oncreat测试成功");
onyxbits/Droidentify
src/com/floreysoft/jmte/message/InternalErrorHandler.java
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // }
import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token;
package com.floreysoft.jmte.message; public class InternalErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // } // Path: src/com/floreysoft/jmte/message/InternalErrorHandler.java import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token; package com.floreysoft.jmte.message; public class InternalErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
public void error(String messageKey, Token token,
onyxbits/Droidentify
src/com/floreysoft/jmte/message/AbstractErrorHandler.java
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // }
import java.util.Locale; import java.util.logging.Logger; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token;
package com.floreysoft.jmte.message; public abstract class AbstractErrorHandler implements ErrorHandler { protected final Logger logger = Logger .getLogger(getClass().getName()); protected Locale locale = new Locale("en"); @Override
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // } // Path: src/com/floreysoft/jmte/message/AbstractErrorHandler.java import java.util.Locale; import java.util.logging.Logger; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token; package com.floreysoft.jmte.message; public abstract class AbstractErrorHandler implements ErrorHandler { protected final Logger logger = Logger .getLogger(getClass().getName()); protected Locale locale = new Locale("en"); @Override
public void error(String messageKey, Token token) throws ParseException {
onyxbits/Droidentify
src/com/floreysoft/jmte/message/SilentErrorHandler.java
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // }
import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token;
package com.floreysoft.jmte.message; public class SilentErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // } // Path: src/com/floreysoft/jmte/message/SilentErrorHandler.java import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token; package com.floreysoft.jmte.message; public class SilentErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
public void error(String messageKey, Token token, Map<String, Object> parameters) throws ParseException {
onyxbits/Droidentify
src/com/floreysoft/jmte/ProcessListener.java
// Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // }
import com.floreysoft.jmte.token.Token;
package com.floreysoft.jmte; /** * Callback for execution steps of the engine. Reports in interpreted mode only. * */ public interface ProcessListener { public static enum Action { /** * Expression being executed. */ EVAL, /** * Expression being skipped. */ SKIP, /** * End of control structure. */ END } /** * Reports a step executed by the engine * * @param context * current context during template evaluation * @param token * the token that is handled * @param action * the action that is executed on the action */
// Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // } // Path: src/com/floreysoft/jmte/ProcessListener.java import com.floreysoft.jmte.token.Token; package com.floreysoft.jmte; /** * Callback for execution steps of the engine. Reports in interpreted mode only. * */ public interface ProcessListener { public static enum Action { /** * Expression being executed. */ EVAL, /** * Expression being skipped. */ SKIP, /** * End of control structure. */ END } /** * Reports a step executed by the engine * * @param context * current context during template evaluation * @param token * the token that is handled * @param action * the action that is executed on the action */
void log(TemplateContext context, Token token, Action action);
onyxbits/Droidentify
src/com/floreysoft/jmte/template/Template.java
// Path: src/com/floreysoft/jmte/ProcessListener.java // public interface ProcessListener { // public static enum Action { // /** // * Expression being executed. // */ // EVAL, // /** // * Expression being skipped. // */ // SKIP, // /** // * End of control structure. // */ // END // } // // /** // * Reports a step executed by the engine // * // * @param context // * current context during template evaluation // * @param token // * the token that is handled // * @param action // * the action that is executed on the action // */ // void log(TemplateContext context, Token token, Action action); // }
import java.util.Locale; import java.util.Map; import java.util.Set; import com.floreysoft.jmte.ModelAdaptor; import com.floreysoft.jmte.ProcessListener;
package com.floreysoft.jmte.template; public interface Template { /** * Transforms a template into an expanded output using the given model. * * @param model * the model used to evaluate expressions inside the template * @param locale * the locale used to render this template * @param modelAdaptor * adaptor used for this transformation to look up values from * model * @return the expanded output */ public String transform(Map<String, Object> model, Locale locale,
// Path: src/com/floreysoft/jmte/ProcessListener.java // public interface ProcessListener { // public static enum Action { // /** // * Expression being executed. // */ // EVAL, // /** // * Expression being skipped. // */ // SKIP, // /** // * End of control structure. // */ // END // } // // /** // * Reports a step executed by the engine // * // * @param context // * current context during template evaluation // * @param token // * the token that is handled // * @param action // * the action that is executed on the action // */ // void log(TemplateContext context, Token token, Action action); // } // Path: src/com/floreysoft/jmte/template/Template.java import java.util.Locale; import java.util.Map; import java.util.Set; import com.floreysoft.jmte.ModelAdaptor; import com.floreysoft.jmte.ProcessListener; package com.floreysoft.jmte.template; public interface Template { /** * Transforms a template into an expanded output using the given model. * * @param model * the model used to evaluate expressions inside the template * @param locale * the locale used to render this template * @param modelAdaptor * adaptor used for this transformation to look up values from * model * @return the expanded output */ public String transform(Map<String, Object> model, Locale locale,
ModelAdaptor modelAdaptor, ProcessListener processListener);
onyxbits/Droidentify
src/com/floreysoft/jmte/token/StringToken.java
// Path: src/com/floreysoft/jmte/NamedRenderer.java // public interface NamedRenderer { // /** // * Renders an object of a type supported by the renderer. // * // * @param o // * the object to render // * @param format // * anything that tells the renderer how to do its work // * @param locale // * the locale used in transformation // * @return the rendered object // */ // public String render(Object o, String format, Locale locale); // // /** // * Gets the name of the renderer. // */ // public String getName(); // // /** // * Gives information about what can be passed as a format parameter to the // * {@link #render(Object, String)} method. // */ // public RenderFormatInfo getFormatInfo(); // // /** // * Returns which classes are support by this renderer, i.e. which ones you // * can pass to the {@link #render(Object, String)} method. // */ // public Class<?>[] getSupportedClasses(); // // }
import java.util.List; import com.floreysoft.jmte.NamedRenderer; import com.floreysoft.jmte.Renderer; import com.floreysoft.jmte.TemplateContext; import com.floreysoft.jmte.encoder.Encoder; import com.floreysoft.jmte.renderer.RawRenderer;
this.prefix = null; this.suffix = null; this.rendererName = null; this.parameters = null; } public String getPrefix() { return prefix; } public String getSuffix() { return suffix; } public String getDefaultValue() { return defaultValue; } @SuppressWarnings("unchecked") @Override public Object evaluate(TemplateContext context) { boolean rawRendering = false; final Object value = evaluatePlain(context); final String renderedResult; if (value == null || value.equals("")) { renderedResult = defaultValue != null ? defaultValue : ""; } else { String namedRendererResult = null; if (rendererName != null && !rendererName.equals("")) {
// Path: src/com/floreysoft/jmte/NamedRenderer.java // public interface NamedRenderer { // /** // * Renders an object of a type supported by the renderer. // * // * @param o // * the object to render // * @param format // * anything that tells the renderer how to do its work // * @param locale // * the locale used in transformation // * @return the rendered object // */ // public String render(Object o, String format, Locale locale); // // /** // * Gets the name of the renderer. // */ // public String getName(); // // /** // * Gives information about what can be passed as a format parameter to the // * {@link #render(Object, String)} method. // */ // public RenderFormatInfo getFormatInfo(); // // /** // * Returns which classes are support by this renderer, i.e. which ones you // * can pass to the {@link #render(Object, String)} method. // */ // public Class<?>[] getSupportedClasses(); // // } // Path: src/com/floreysoft/jmte/token/StringToken.java import java.util.List; import com.floreysoft.jmte.NamedRenderer; import com.floreysoft.jmte.Renderer; import com.floreysoft.jmte.TemplateContext; import com.floreysoft.jmte.encoder.Encoder; import com.floreysoft.jmte.renderer.RawRenderer; this.prefix = null; this.suffix = null; this.rendererName = null; this.parameters = null; } public String getPrefix() { return prefix; } public String getSuffix() { return suffix; } public String getDefaultValue() { return defaultValue; } @SuppressWarnings("unchecked") @Override public Object evaluate(TemplateContext context) { boolean rawRendering = false; final Object value = evaluatePlain(context); final String renderedResult; if (value == null || value.equals("")) { renderedResult = defaultValue != null ? defaultValue : ""; } else { String namedRendererResult = null; if (rendererName != null && !rendererName.equals("")) {
final NamedRenderer rendererForName = context
onyxbits/Droidentify
src/com/floreysoft/jmte/message/DefaultErrorHandler.java
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // }
import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token;
package com.floreysoft.jmte.message; public class DefaultErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
// Path: src/com/floreysoft/jmte/ErrorHandler.java // public interface ErrorHandler { // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // * @param parameters // * additional parameters to be filled into message or // * <code>null</<code> if you do not have additional parameters // */ // public void error(String messageKey, Token token, // Map<String, Object> parameters) throws ParseException; // // /** // * Handles an error while interpreting a template in an appropriate way. // * This might contain logging the error or even throwing an exception. // * // * @param messageKey // * key for the error message // * @param token // * the token this error occurred on // */ // public void error(String messageKey, Token token) throws ParseException; // // } // // Path: src/com/floreysoft/jmte/token/Token.java // public interface Token extends Cloneable { // // /** // * Returns the text of the token. // * // * @return the text // */ // public String getText(); // // public int getLine(); // // public int getColumn(); // // public String getSourceName(); // // public Object evaluate(TemplateContext context); // // public int getTokenIndex(); // // public String emit(); // } // Path: src/com/floreysoft/jmte/message/DefaultErrorHandler.java import java.util.Map; import com.floreysoft.jmte.ErrorHandler; import com.floreysoft.jmte.token.Token; package com.floreysoft.jmte.message; public class DefaultErrorHandler extends AbstractErrorHandler implements ErrorHandler { /** * {@inheritDoc} */ @Override
public void error(String messageKey, Token token,
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/CfgFile.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.util.HashMap; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class CfgFile implements Verifiable { static final QName QNAME = new QName(Config.NS, "file"); static final QName QN_FOLDER = new QName(Config.NS, "folder"); static final QName ATTR_HREF = new QName("href"); private final File source;
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/CfgFile.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.util.HashMap; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class CfgFile implements Verifiable { static final QName QNAME = new QName(Config.NS, "file"); static final QName QN_FOLDER = new QName(Config.NS, "folder"); static final QName ATTR_HREF = new QName("href"); private final File source;
private final HashMap<QName, ParameterValue> params;
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/CfgFile.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.util.HashMap; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class CfgFile implements Verifiable { static final QName QNAME = new QName(Config.NS, "file"); static final QName QN_FOLDER = new QName(Config.NS, "folder"); static final QName ATTR_HREF = new QName("href"); private final File source; private final HashMap<QName, ParameterValue> params; public CfgFile(File source) { super(); this.source=source; params = new HashMap<>(); } public void addParameter(ParameterValue param) { if(param==null) return; params.put(param.getKey(), param); } public File getSource() { return source; } public HashMap<QName,ParameterValue> getParams() { return params; } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/CfgFile.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.util.HashMap; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class CfgFile implements Verifiable { static final QName QNAME = new QName(Config.NS, "file"); static final QName QN_FOLDER = new QName(Config.NS, "folder"); static final QName ATTR_HREF = new QName("href"); private final File source; private final HashMap<QName, ParameterValue> params; public CfgFile(File source) { super(); this.source=source; params = new HashMap<>(); } public void addParameter(ParameterValue param) { if(param==null) return; params.put(param.getKey(), param); } public File getSource() { return source; } public HashMap<QName,ParameterValue> getParams() { return params; } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Tee.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.ArrayList; import java.util.List; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author Christophe Marchand */ public class Tee implements Verifiable { static final QName QNAME = new QName(Config.NS, "tee"); static final QName PIPE = new QName(Config.NS, "pipe"); private List<Pipe> pipes = new ArrayList<>(); public Tee() { super(); } public List<Pipe> getPipes() { return pipes; } public void addPipe(Pipe pipe) { pipes.add(pipe); } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Tee.java import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.ArrayList; import java.util.List; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author Christophe Marchand */ public class Tee implements Verifiable { static final QName QNAME = new QName(Config.NS, "tee"); static final QName PIPE = new QName(Config.NS, "pipe"); private List<Pipe> pipes = new ArrayList<>(); public Tee() { super(); } public List<Pipe> getPipes() { return pipes; } public void addPipe(Pipe pipe) { pipes.add(pipe); } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Config.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.List; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class Config implements Verifiable { public static final int MAX_DOCUMENT_CACHE_SIZE = 1; static final QName ATTR_DOCUMENT_CACHE_SIZE = new QName("documentCacheSize"); public static final String NS = "http://efl.fr/chaine/saxon-pipe/config"; static final QName PARAMS_CHILD = new QName(NS, "params"); private Pipe pipe;
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Config.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.List; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class Config implements Verifiable { public static final int MAX_DOCUMENT_CACHE_SIZE = 1; static final QName ATTR_DOCUMENT_CACHE_SIZE = new QName("documentCacheSize"); public static final String NS = "http://efl.fr/chaine/saxon-pipe/config"; static final QName PARAMS_CHILD = new QName(NS, "params"); private Pipe pipe;
private final HashMap<QName,ParameterValue> params;
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Config.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.List; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
params = new HashMap<>(); this.currentDir = new File(currentDir); } public Pipe getPipe() { return pipe; } void setPipe(Pipe pipe) { this.pipe = pipe; } public HashMap<QName,ParameterValue> getParams() { return params; } public void addParameter(ParameterValue p) { if(p!=null) { params.put(p.getKey(),p); } } public Sources getSources() { return sources; } void setSources(Sources sources) { this.sources = sources; } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Config.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.List; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; params = new HashMap<>(); this.currentDir = new File(currentDir); } public Pipe getPipe() { return pipe; } void setPipe(Pipe pipe) { this.pipe = pipe; } public HashMap<QName,ParameterValue> getParams() { return params; } public void addParameter(ParameterValue p) { if(p!=null) { params.put(p.getKey(),p); } } public Sources getSources() { return sources; } void setSources(Sources sources) { this.sources = sources; } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Pipe.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.sf.saxon.s9api.QName;
this(); this.parentTee=parent; } public int getMultithreadMaxSourceSize() { return multithreadMaxSourceSize; } public void setMultithreadMaxSourceSize(int multithreadMaxSourceSize) { this.multithreadMaxSourceSize = multithreadMaxSourceSize; } public int getNbThreads() { return nbThreads; } public void setNbThreads(int nbThreads) { this.nbThreads = nbThreads; } public Iterator<ParametrableStep> getXslts() { return steps.iterator(); } /** * Adds an xslt to the pipe * @param xsl The xsl to add * @throws fr.efl.chaine.xslt.InvalidSyntaxException If this xsl is added in a invalid location * @throws IllegalStateException If a <tt>&lt;tee&gt;</tt> or a <tt>&lt;output&gt;</tt> has already been added */
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Pipe.java import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.sf.saxon.s9api.QName; this(); this.parentTee=parent; } public int getMultithreadMaxSourceSize() { return multithreadMaxSourceSize; } public void setMultithreadMaxSourceSize(int multithreadMaxSourceSize) { this.multithreadMaxSourceSize = multithreadMaxSourceSize; } public int getNbThreads() { return nbThreads; } public void setNbThreads(int nbThreads) { this.nbThreads = nbThreads; } public Iterator<ParametrableStep> getXslts() { return steps.iterator(); } /** * Adds an xslt to the pipe * @param xsl The xsl to add * @throws fr.efl.chaine.xslt.InvalidSyntaxException If this xsl is added in a invalid location * @throws IllegalStateException If a <tt>&lt;tee&gt;</tt> or a <tt>&lt;output&gt;</tt> has already been added */
public void addXslt(ParametrableStep xsl) throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Listener.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import java.io.Serializable; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * A listener to listen to new files to process * @author cmarchand */ public class Listener implements Verifiable, Serializable { public static final int DEFAULT_PORT=8888; public static final transient QName QName = new QName(Config.NS, "listener"); public static final transient QName ATTR_PORT = new QName("port"); public static final transient QName ATTR_STOP = new QName("stopKeyword"); private final int port; private final String stopKeyword; private JavaStep javastep; public Listener(final int port, final String stopKeyword) { super(); this.port=port; this.stopKeyword=stopKeyword; } public Listener(final String stopKeyword) { this(DEFAULT_PORT, stopKeyword); } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Listener.java import fr.efl.chaine.xslt.InvalidSyntaxException; import java.io.Serializable; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * A listener to listen to new files to process * @author cmarchand */ public class Listener implements Verifiable, Serializable { public static final int DEFAULT_PORT=8888; public static final transient QName QName = new QName(Config.NS, "listener"); public static final transient QName ATTR_PORT = new QName("port"); public static final transient QName ATTR_STOP = new QName("stopKeyword"); private final int port; private final String stopKeyword; private JavaStep javastep; public Listener(final int port, final String stopKeyword) { super(); this.port=port; this.stopKeyword=stopKeyword; } public Listener(final String stopKeyword) { this(DEFAULT_PORT, stopKeyword); } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Namespaces.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.HashMap; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * A class used to keep namespaces definitions. * @author cmarchand */ public class Namespaces implements Verifiable { private final HashMap<String,String> mapping; public static final transient QName QNAME = new QName(Config.NS, "namespaces"); public static final transient QName QN_MAPPING = new QName(Config.NS, "mapping"); public static final transient QName ATTR_PREFIX = new QName("prefix"); public static final transient QName ATTR_URI= new QName("uri"); public Namespaces() { super(); this.mapping = new HashMap<>(); } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Namespaces.java import fr.efl.chaine.xslt.InvalidSyntaxException; import java.util.HashMap; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * A class used to keep namespaces definitions. * @author cmarchand */ public class Namespaces implements Verifiable { private final HashMap<String,String> mapping; public static final transient QName QNAME = new QName(Config.NS, "namespaces"); public static final transient QName QN_MAPPING = new QName(Config.NS, "mapping"); public static final transient QName ATTR_PREFIX = new QName("prefix"); public static final transient QName ATTR_URI= new QName("uri"); public Namespaces() { super(); this.mapping = new HashMap<>(); } @Override
public void verify() throws InvalidSyntaxException { }
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/ChooseStep.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author cmarchand */ public class ChooseStep implements ParametrableStep { private final List<WhenEntry> conditions; public static final QName QNAME = new QName(Config.NS, "choose"); public ChooseStep() { super(); conditions = new ArrayList<>(); } /** * Always return null, a step may not have parameters. * @return {@code null} */ @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/ChooseStep.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author cmarchand */ public class ChooseStep implements ParametrableStep { private final List<WhenEntry> conditions; public static final QName QNAME = new QName(Config.NS, "choose"); public ChooseStep() { super(); conditions = new ArrayList<>(); } /** * Always return null, a step may not have parameters. * @return {@code null} */ @Override
public Collection<ParameterValue> getParams() {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/ChooseStep.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName;
public Collection<ParameterValue> getParams() { return null; } public List<WhenEntry> getConditions() { return conditions; } public void addWhen(WhenEntry when) { conditions.add(when); } /** * Does nothing, a ChooseStep may not have parameters * @param param Ignored */ @Override public void addParameter(ParameterValue param) { } @Override public String toString(String prefix) { StringBuilder sb = new StringBuilder(); sb.append(prefix).append("choose\n"); String _p=prefix+" "; for(WhenEntry when:conditions) { sb.append(when.toString(_p)); } return sb.toString(); } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/ChooseStep.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName; public Collection<ParameterValue> getParams() { return null; } public List<WhenEntry> getConditions() { return conditions; } public void addWhen(WhenEntry when) { conditions.add(when); } /** * Does nothing, a ChooseStep may not have parameters * @param param Ignored */ @Override public void addParameter(ParameterValue param) { } @Override public String toString(String prefix) { StringBuilder sb = new StringBuilder(); sb.append(prefix).append("choose\n"); String _p=prefix+" "; for(WhenEntry when:conditions) { sb.append(when.toString(_p)); } return sb.toString(); } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/top/marchand/xml/gaulois/impl/DefaultSaxonConfigurationFactory.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/SaxonConfigurationFactory.java // public abstract class SaxonConfigurationFactory { // // /** // * Returns the Configuration. Many calls to this method <strong>must</strong> // * return the same instance of <tt>Configuration</tt>. // * // * @return The Configuration to use // */ // public abstract Configuration getConfiguration(); // // } // // Path: gaulois-pipe/src/main/java/top/marchand/xml/gaulois/resolve/GauloisSAXParserFactory.java // public class GauloisSAXParserFactory extends SAXParserFactory { // private final SAXParserFactory innerFactory; // ThreadLocal<EntityResolver2> thEntityResolver; // // public GauloisSAXParserFactory() { // innerFactory = new SAXParserFactoryImpl() { // @Override // public SAXParser newSAXParser() throws ParserConfigurationException { // return new GauloisSAXParser(super.newSAXParser()); // } // }; // } // // @Override // public SAXParser newSAXParser() throws ParserConfigurationException, SAXException { // return innerFactory.newSAXParser(); // } // // @Override // public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { // innerFactory.setFeature(name, value); // } // // @Override // public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { // return innerFactory.getFeature(name); // } // // class GauloisSAXParser extends SAXParser { // private ThreadLocal<EntityResolver2> thEntityResolver; // // private final SAXParser innerParser; // public GauloisSAXParser(SAXParser innerParser) { // super(); // this.innerParser=innerParser; // } // // @Override // public Parser getParser() throws SAXException { // return innerParser.getParser(); // } // // @Override // public XMLReader getXMLReader() throws SAXException { // XMLReader reader = innerParser.getXMLReader(); // if(thEntityResolver!=null && thEntityResolver.get()!=null) { // reader.setEntityResolver(thEntityResolver.get()); // } // return reader; // } // // @Override // public boolean isNamespaceAware() { // return innerParser.isNamespaceAware(); // } // // @Override // public boolean isValidating() { // return innerParser.isValidating(); // } // // @Override // public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { // innerParser.setProperty(name, value); // } // // @Override // public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { // return innerParser.getProperty(name); // } // } // // }
import fr.efl.chaine.xslt.SaxonConfigurationFactory; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.util.Enumeration; import javax.xml.transform.stream.StreamSource; import net.sf.saxon.Configuration; import net.sf.saxon.lib.ExtensionFunctionDefinition; import net.sf.saxon.s9api.DocumentBuilder; import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.SaxonApiException; import net.sf.saxon.s9api.XPathCompiler; import net.sf.saxon.s9api.XPathSelector; import net.sf.saxon.s9api.XdmNode; import net.sf.saxon.s9api.XdmSequenceIterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import top.marchand.xml.gaulois.resolve.GauloisSAXParserFactory;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package top.marchand.xml.gaulois.impl; /** * A default SaxonConfigurationFactory that loads xpath extension functions into configuration. * * You should provide a xml file with this structure : * * <pre> * &lt;gaulois-service&gt; * &lt;saxon&gt; * &lt;extensions&gt; * &lt;function&gt;fully.qualified.classname.that.extends.net.sf.saxon.lib.ExtensionFunctionDefinition&lt;/functiongt; * &lt;functiongt;another.fully.qualified.classname&gt; * &lt;/extensions&gt; * &lt;/saxon&gt; * &lt;/gaulois-service&gt; * </pre> * @author cmarchand */ public class DefaultSaxonConfigurationFactory extends SaxonConfigurationFactory { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSaxonConfigurationFactory.class); protected Configuration configuration; public DefaultSaxonConfigurationFactory() { super(); __initConfiguration(); } /** * To be overriden, if required */ protected void createConfigurationObject() { configuration = Configuration.newConfiguration(); } @Override public Configuration getConfiguration() { return configuration; } private void __initConfiguration() { // default construct createConfigurationObject(); LOGGER.debug("configuration is a "+configuration.getClass().getName()); // issue 39
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/SaxonConfigurationFactory.java // public abstract class SaxonConfigurationFactory { // // /** // * Returns the Configuration. Many calls to this method <strong>must</strong> // * return the same instance of <tt>Configuration</tt>. // * // * @return The Configuration to use // */ // public abstract Configuration getConfiguration(); // // } // // Path: gaulois-pipe/src/main/java/top/marchand/xml/gaulois/resolve/GauloisSAXParserFactory.java // public class GauloisSAXParserFactory extends SAXParserFactory { // private final SAXParserFactory innerFactory; // ThreadLocal<EntityResolver2> thEntityResolver; // // public GauloisSAXParserFactory() { // innerFactory = new SAXParserFactoryImpl() { // @Override // public SAXParser newSAXParser() throws ParserConfigurationException { // return new GauloisSAXParser(super.newSAXParser()); // } // }; // } // // @Override // public SAXParser newSAXParser() throws ParserConfigurationException, SAXException { // return innerFactory.newSAXParser(); // } // // @Override // public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { // innerFactory.setFeature(name, value); // } // // @Override // public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { // return innerFactory.getFeature(name); // } // // class GauloisSAXParser extends SAXParser { // private ThreadLocal<EntityResolver2> thEntityResolver; // // private final SAXParser innerParser; // public GauloisSAXParser(SAXParser innerParser) { // super(); // this.innerParser=innerParser; // } // // @Override // public Parser getParser() throws SAXException { // return innerParser.getParser(); // } // // @Override // public XMLReader getXMLReader() throws SAXException { // XMLReader reader = innerParser.getXMLReader(); // if(thEntityResolver!=null && thEntityResolver.get()!=null) { // reader.setEntityResolver(thEntityResolver.get()); // } // return reader; // } // // @Override // public boolean isNamespaceAware() { // return innerParser.isNamespaceAware(); // } // // @Override // public boolean isValidating() { // return innerParser.isValidating(); // } // // @Override // public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { // innerParser.setProperty(name, value); // } // // @Override // public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { // return innerParser.getProperty(name); // } // } // // } // Path: gaulois-pipe/src/main/java/top/marchand/xml/gaulois/impl/DefaultSaxonConfigurationFactory.java import fr.efl.chaine.xslt.SaxonConfigurationFactory; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.util.Enumeration; import javax.xml.transform.stream.StreamSource; import net.sf.saxon.Configuration; import net.sf.saxon.lib.ExtensionFunctionDefinition; import net.sf.saxon.s9api.DocumentBuilder; import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.SaxonApiException; import net.sf.saxon.s9api.XPathCompiler; import net.sf.saxon.s9api.XPathSelector; import net.sf.saxon.s9api.XdmNode; import net.sf.saxon.s9api.XdmSequenceIterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import top.marchand.xml.gaulois.resolve.GauloisSAXParserFactory; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package top.marchand.xml.gaulois.impl; /** * A default SaxonConfigurationFactory that loads xpath extension functions into configuration. * * You should provide a xml file with this structure : * * <pre> * &lt;gaulois-service&gt; * &lt;saxon&gt; * &lt;extensions&gt; * &lt;function&gt;fully.qualified.classname.that.extends.net.sf.saxon.lib.ExtensionFunctionDefinition&lt;/functiongt; * &lt;functiongt;another.fully.qualified.classname&gt; * &lt;/extensions&gt; * &lt;/saxon&gt; * &lt;/gaulois-service&gt; * </pre> * @author cmarchand */ public class DefaultSaxonConfigurationFactory extends SaxonConfigurationFactory { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSaxonConfigurationFactory.class); protected Configuration configuration; public DefaultSaxonConfigurationFactory() { super(); __initConfiguration(); } /** * To be overriden, if required */ protected void createConfigurationObject() { configuration = Configuration.newConfiguration(); } @Override public Configuration getConfiguration() { return configuration; } private void __initConfiguration() { // default construct createConfigurationObject(); LOGGER.debug("configuration is a "+configuration.getClass().getName()); // issue 39
configuration.setSourceParserClass(GauloisSAXParserFactory.class.getName());
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Sources.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // }
import net.sf.saxon.s9api.QName; import fr.efl.chaine.xslt.InvalidSyntaxException; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class Sources implements Verifiable { private static final Logger LOGGER = LoggerFactory.getLogger(Sources.class); static final QName QNAME = new QName(Config.NS, "sources"); static final QName ATTR_ORDERBY = new QName("orderBy"); static final QName ATTR_SORT = new QName("sort"); private final String orderBy, sort; private final List<CfgFile> files; private long maxFileSize = 0l; private Map<File,Integer> hrefCount; private Listener listener;
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Sources.java import net.sf.saxon.s9api.QName; import fr.efl.chaine.xslt.InvalidSyntaxException; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author ext-cmarchand */ public class Sources implements Verifiable { private static final Logger LOGGER = LoggerFactory.getLogger(Sources.class); static final QName QNAME = new QName(Config.NS, "sources"); static final QName ATTR_ORDERBY = new QName("orderBy"); static final QName ATTR_SORT = new QName("sort"); private final String orderBy, sort; private final List<CfgFile> files; private long maxFileSize = 0l; private Map<File,Integer> hrefCount; private Listener listener;
public Sources(String orderBy, String sort) throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Output.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import java.io.File; import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.regex.Matcher; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.Serializer; import net.sf.saxon.s9api.XdmAtomicValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
* Returns <tt>true</tt> if the output should not be written anywhere * @return {@code true} if this output should produce nothing */ public boolean isNullOutput() { return nullOutput; } /** * Returns a copy of outputProperties * @return A new copy of output properties */ public Properties getOutputProperties() { Properties ret = new Properties(); for(Object key: outputProperties.keySet()) { String sKey = key.toString(); ret.setProperty(sKey,outputProperties.getProperty(sKey)); } return ret; } public String getOutputProperty(final String key) { return outputProperties.getProperty(key); } /** * Renvoie le fichier destination * @param sourceFile Le fichier source traité * @param parameters Parameters to give. Should be used only to parse the escapes * @return The file to create * @throws InvalidSyntaxException If this output has no been correctly defined * @throws java.net.URISyntaxException If the constructed URI is no valid */
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/Output.java import java.io.File; import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.regex.Matcher; import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.Serializer; import net.sf.saxon.s9api.XdmAtomicValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; * Returns <tt>true</tt> if the output should not be written anywhere * @return {@code true} if this output should produce nothing */ public boolean isNullOutput() { return nullOutput; } /** * Returns a copy of outputProperties * @return A new copy of output properties */ public Properties getOutputProperties() { Properties ret = new Properties(); for(Object key: outputProperties.keySet()) { String sKey = key.toString(); ret.setProperty(sKey,outputProperties.getProperty(sKey)); } return ret; } public String getOutputProperty(final String key) { return outputProperties.getProperty(key); } /** * Renvoie le fichier destination * @param sourceFile Le fichier source traité * @param parameters Parameters to give. Should be used only to parse the escapes * @return The file to create * @throws InvalidSyntaxException If this output has no been correctly defined * @throws java.net.URISyntaxException If the constructed URI is no valid */
public File getDestinationFile(File sourceFile, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException, URISyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/WhenEntry.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author cmarchand */ public class WhenEntry implements ParametrableStep { public static final QName QNAME = new QName(Config.NS, "when"); public static final QName QN_OTHERWISE = new QName(Config.NS, "otherwise"); public static final QName ATTR_TEST = new QName("test"); private String test; private final List<ParametrableStep> steps; public WhenEntry() { steps = new ArrayList<>(); } public WhenEntry(final String test) { this(); this.test=test; } public String getTest() { return test; } public List<ParametrableStep> getSteps() { return steps; } public void addStep(ParametrableStep step) { steps.add(step); } /** * Always return null, a When can not have parameters. * @return {@code null} */ @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/WhenEntry.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.config; /** * * @author cmarchand */ public class WhenEntry implements ParametrableStep { public static final QName QNAME = new QName(Config.NS, "when"); public static final QName QN_OTHERWISE = new QName(Config.NS, "otherwise"); public static final QName ATTR_TEST = new QName("test"); private String test; private final List<ParametrableStep> steps; public WhenEntry() { steps = new ArrayList<>(); } public WhenEntry(final String test) { this(); this.test=test; } public String getTest() { return test; } public List<ParametrableStep> getSteps() { return steps; } public void addStep(ParametrableStep step) { steps.add(step); } /** * Always return null, a When can not have parameters. * @return {@code null} */ @Override
public Collection<ParameterValue> getParams() {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/WhenEntry.java
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // }
import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName;
} /** * Always return null, a When can not have parameters. * @return {@code null} */ @Override public Collection<ParameterValue> getParams() { return null; } /** * Does nothing, a When can not have parameters. * @param param Ignored */ @Override public void addParameter(ParameterValue param) { } @Override public String toString(String prefix) { StringBuilder sb = new StringBuilder(); sb.append(prefix).append("when test=\"").append(test).append("\"\n"); String _p = prefix+" "; for(ParametrableStep step:steps) { step.toString(_p); } return sb.toString(); } @Override
// Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/InvalidSyntaxException.java // public class InvalidSyntaxException extends Exception { // // public InvalidSyntaxException() { // } // // public InvalidSyntaxException(String message) { // super(message); // } // // public InvalidSyntaxException(String message, Throwable cause) { // super(message, cause); // } // // public InvalidSyntaxException(Throwable cause) { // super(cause); // } // // public InvalidSyntaxException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // // } // // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java // public class ParameterValue { // // /** // * the parameter key. // * Since issue#15, it is a QName // */ // private final QName key; // /** // * the parameter value. // */ // private Object value; // /** // * This parameter datatype. If not specified, it's xs:string // */ // private Datatype datatype; // private boolean abstractParam; // // /** // * Default constructor. // * // * @param key the parameter key // * @param value the parameter value // * @param datatype the parameter datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Object value, Datatype datatype) { // this.key = key; // setValue(value); // setDatatype(datatype); // } // // /** // * Constructs an abstract Parameter // * @param key The param key // * @param datatype The param datatype // */ // @SuppressWarnings("OverridableMethodCallInConstructor") // public ParameterValue(QName key, Datatype datatype) { // this.key = key; // setDatatype(datatype); // abstractParam = true; // } // // /** // * @return the parameter key // */ // public QName getKey() { // return key; // } // // /** // * @return the parameter value // */ // public Object getValue() { // return value; // } // // public void setValue(Object value) { // if(value instanceof String) { // this.value=value; // abstractParam = false; // } else if(value instanceof XdmValue) { // this.value=value; // abstractParam = false; // } else if(value==null) { // this.value=value; // abstractParam = false; // } else { // throw new IllegalArgumentException("Only String or XdmValue are acceptable values for parameters"); // } // } // // @Override // public String toString() { // return "[" + getKey() + "=" + (abstractParam ? "<abstract>" : getValue()) + "]"; // } // // public Datatype getDatatype() { // return datatype; // } // // public void setDatatype(Datatype datatype) { // this.datatype = datatype; // } // // public boolean isAbstract() { // return abstractParam; // } // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/config/WhenEntry.java import fr.efl.chaine.xslt.InvalidSyntaxException; import fr.efl.chaine.xslt.utils.ParameterValue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sf.saxon.s9api.QName; } /** * Always return null, a When can not have parameters. * @return {@code null} */ @Override public Collection<ParameterValue> getParams() { return null; } /** * Does nothing, a When can not have parameters. * @param param Ignored */ @Override public void addParameter(ParameterValue param) { } @Override public String toString(String prefix) { StringBuilder sb = new StringBuilder(); sb.append(prefix).append("when test=\"").append(test).append("\"\n"); String _p = prefix+" "; for(ParametrableStep step:steps) { step.toString(_p); } return sb.toString(); } @Override
public void verify() throws InvalidSyntaxException {
cmarchand/gaulois-pipe
gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java
// Path: gaulois-pipe/src/main/java/top/marchand/xml/gaulois/config/typing/Datatype.java // public interface Datatype { // // /** // * Returns true if this datatype is an atomic datatype // * @return if this datatype represents and atomic value // */ // boolean isAtomic(); // // /** // * Returns true if sequences are allowed // * @return if multiple values are allowed (sequence with more than 1 item) // */ // boolean allowsMultiple(); // // /** // * Return true if empty sequence is allowed. // * @return if empty is allowed, if empty-sequence aloowed // */ // boolean allowsEmpty(); // // /** // * Convert <tt>input</tt> as this datatype // * @param input The input value to convert // * @param configuration The saxon Configuration to rely on // * @return The corresponding XdmValue // * @throws net.sf.saxon.type.ValidationException If <tt>input</tt>is not castable into this datatype // */ // XdmValue convert(String input, Configuration configuration) throws ValidationException; // // }
import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmValue; import top.marchand.xml.gaulois.config.typing.Datatype;
/** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.utils; /** * A parameter value in saxon pipe. */ public class ParameterValue { /** * the parameter key. * Since issue#15, it is a QName */ private final QName key; /** * the parameter value. */ private Object value; /** * This parameter datatype. If not specified, it's xs:string */
// Path: gaulois-pipe/src/main/java/top/marchand/xml/gaulois/config/typing/Datatype.java // public interface Datatype { // // /** // * Returns true if this datatype is an atomic datatype // * @return if this datatype represents and atomic value // */ // boolean isAtomic(); // // /** // * Returns true if sequences are allowed // * @return if multiple values are allowed (sequence with more than 1 item) // */ // boolean allowsMultiple(); // // /** // * Return true if empty sequence is allowed. // * @return if empty is allowed, if empty-sequence aloowed // */ // boolean allowsEmpty(); // // /** // * Convert <tt>input</tt> as this datatype // * @param input The input value to convert // * @param configuration The saxon Configuration to rely on // * @return The corresponding XdmValue // * @throws net.sf.saxon.type.ValidationException If <tt>input</tt>is not castable into this datatype // */ // XdmValue convert(String input, Configuration configuration) throws ValidationException; // // } // Path: gaulois-pipe/src/main/java/fr/efl/chaine/xslt/utils/ParameterValue.java import net.sf.saxon.s9api.QName; import net.sf.saxon.s9api.XdmValue; import top.marchand.xml.gaulois.config.typing.Datatype; /** * This Source Code Form is subject to the terms of * the Mozilla Public License, v. 2.0. If a copy of * the MPL was not distributed with this file, You * can obtain one at https://mozilla.org/MPL/2.0/. */ package fr.efl.chaine.xslt.utils; /** * A parameter value in saxon pipe. */ public class ParameterValue { /** * the parameter key. * Since issue#15, it is a QName */ private final QName key; /** * the parameter value. */ private Object value; /** * This parameter datatype. If not specified, it's xs:string */
private Datatype datatype;
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
if (interceptor != null) { SQLException interceptedEx = interceptor.interceptException(sqlEx, conn); if (interceptedEx != null) { return interceptedEx; } } return sqlEx; } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor, null); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) { try { SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; if (interceptor != null) { SQLException interceptedEx = interceptor.interceptException(sqlEx, conn); if (interceptedEx != null) { return interceptedEx; } } return sqlEx; } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor, null); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) { try { SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) {
sqlEx = new MySQLTransientConnectionException(
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor, null); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) { try { SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) { sqlEx = new MySQLTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) { return createSQLException(message, sqlState, vendorErrorCode, false, interceptor, null); } public static SQLException createSQLException(String message, String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor, Connection conn) { try { SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) { sqlEx = new MySQLTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) {
sqlEx = new MySQLNonTransientConnectionException(
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) { sqlEx = new MySQLTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) { sqlEx = new MySQLNonTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; SQLException sqlEx = null; if (sqlState != null) { if (sqlState.startsWith("08")) { if (isTransient) { if (!Util.isJdbc4()) { sqlEx = new MySQLTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) { sqlEx = new MySQLNonTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) {
sqlEx = new MySQLDataException(message, sqlState,
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) { sqlEx = new MySQLNonTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) { sqlEx = new MySQLDataException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (!Util.isJdbc4()) { sqlEx = new MySQLNonTransientConnectionException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) { sqlEx = new MySQLDataException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) {
sqlEx = new MySQLIntegrityConstraintViolationException(
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
} } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) { sqlEx = new MySQLDataException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) { sqlEx = new MySQLIntegrityConstraintViolationException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("42")) { if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; } } else if (sqlState.startsWith("22")) { if (!Util.isJdbc4()) { sqlEx = new MySQLDataException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) { sqlEx = new MySQLIntegrityConstraintViolationException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("42")) { if (!Util.isJdbc4()) {
sqlEx = new MySQLSyntaxErrorException(message, sqlState,
spullara/mysql-connector-java
src/main/java/com/mysql/jdbc/SQLError.java
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // }
import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException;
Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) { sqlEx = new MySQLIntegrityConstraintViolationException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("42")) { if (!Util.isJdbc4()) { sqlEx = new MySQLSyntaxErrorException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("40")) { if (!Util.isJdbc4()) {
// Path: src/main/java/com/mysql/jdbc/exceptions/MySQLDataException.java // public class MySQLDataException extends MySQLNonTransientException { // // public MySQLDataException() { // super(); // } // // public MySQLDataException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLDataException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLDataException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java // public class MySQLIntegrityConstraintViolationException extends // MySQLNonTransientException { // // public MySQLIntegrityConstraintViolationException() { // super(); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLIntegrityConstraintViolationException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLIntegrityConstraintViolationException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java // public class MySQLNonTransientConnectionException extends // MySQLNonTransientException { // // public MySQLNonTransientConnectionException() { // super(); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLNonTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLNonTransientConnectionException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java // public class MySQLSyntaxErrorException extends MySQLNonTransientException { // // public MySQLSyntaxErrorException() { // super(); // } // // public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLSyntaxErrorException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLSyntaxErrorException(String reason) { // super(reason); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java // public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker { // // public MySQLTransactionRollbackException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransactionRollbackException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransactionRollbackException(String reason) { // super(reason); // } // // public MySQLTransactionRollbackException() { // super(); // } // } // // Path: src/main/java/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java // public class MySQLTransientConnectionException extends MySQLTransientException { // // public MySQLTransientConnectionException(String reason, String SQLState, // int vendorCode) { // super(reason, SQLState, vendorCode); // } // // public MySQLTransientConnectionException(String reason, String SQLState) { // super(reason, SQLState); // } // // public MySQLTransientConnectionException(String reason) { // super(reason); // } // // public MySQLTransientConnectionException() { // super(); // } // } // Path: src/main/java/com/mysql/jdbc/SQLError.java import java.sql.SQLWarning; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import com.mysql.jdbc.exceptions.MySQLDataException; import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException; import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException; import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException; import com.mysql.jdbc.exceptions.MySQLTransientConnectionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.BindException; import java.sql.DataTruncation; import java.sql.SQLException; Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("23")) { if (!Util.isJdbc4()) { sqlEx = new MySQLIntegrityConstraintViolationException( message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util .getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("42")) { if (!Util.isJdbc4()) { sqlEx = new MySQLSyntaxErrorException(message, sqlState, vendorErrorCode); } else { sqlEx = (SQLException) Util.getInstance( "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException", new Class[] { String.class, String.class, Integer.TYPE }, new Object[] { message, sqlState, Integer.valueOf(vendorErrorCode) }, interceptor); } } else if (sqlState.startsWith("40")) { if (!Util.isJdbc4()) {
sqlEx = new MySQLTransactionRollbackException(message,
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ExportAdapter.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/main/AppItemViewHolder.java // public class AppItemViewHolder extends RecyclerView.ViewHolder { // // private ImageView imgIcon; // TextView tvName; // // public AppItemViewHolder(View itemView) { // super(itemView); // imgIcon = itemView.findViewById(R.id.app_icon); // tvName = itemView.findViewById(R.id.app_name); // } // // // public void bindData(AppInfo appInfo) { // tvName.setText(appInfo.appName); // LocalImageLoader.load(imgIcon, appInfo); // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // }
import androidx.annotation.NonNull; import androidx.collection.SparseArrayCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.CompoundButton; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.main.AppItemViewHolder; import com.zzzmode.appopsx.ui.model.AppInfo; import java.util.List;
package com.zzzmode.appopsx.ui.main.backup; /** * 导出 * Created by zl on 2017/5/7. */ class ExportAdapter extends RecyclerView.Adapter<ExportAdapter.ExportViewHolder> implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
// Path: app/src/main/java/com/zzzmode/appopsx/ui/main/AppItemViewHolder.java // public class AppItemViewHolder extends RecyclerView.ViewHolder { // // private ImageView imgIcon; // TextView tvName; // // public AppItemViewHolder(View itemView) { // super(itemView); // imgIcon = itemView.findViewById(R.id.app_icon); // tvName = itemView.findViewById(R.id.app_name); // } // // // public void bindData(AppInfo appInfo) { // tvName.setText(appInfo.appName); // LocalImageLoader.load(imgIcon, appInfo); // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ExportAdapter.java import androidx.annotation.NonNull; import androidx.collection.SparseArrayCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.CompoundButton; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.main.AppItemViewHolder; import com.zzzmode.appopsx.ui.model.AppInfo; import java.util.List; package com.zzzmode.appopsx.ui.main.backup; /** * 导出 * Created by zl on 2017/5/7. */ class ExportAdapter extends RecyclerView.Adapter<ExportAdapter.ExportViewHolder> implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private List<AppInfo> appInfos;
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ExportAdapter.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/main/AppItemViewHolder.java // public class AppItemViewHolder extends RecyclerView.ViewHolder { // // private ImageView imgIcon; // TextView tvName; // // public AppItemViewHolder(View itemView) { // super(itemView); // imgIcon = itemView.findViewById(R.id.app_icon); // tvName = itemView.findViewById(R.id.app_name); // } // // // public void bindData(AppInfo appInfo) { // tvName.setText(appInfo.appName); // LocalImageLoader.load(imgIcon, appInfo); // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // }
import androidx.annotation.NonNull; import androidx.collection.SparseArrayCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.CompoundButton; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.main.AppItemViewHolder; import com.zzzmode.appopsx.ui.model.AppInfo; import java.util.List;
private void handleCheck(ExportViewHolder holder, boolean change) { int pos = holder.getAdapterPosition(); if (holder.checkBox.isChecked()) { mCheckedApps.delete(pos); } else { mCheckedApps.put(pos, appInfos.get(pos)); } if (change) { holder.checkBox.setOnCheckedChangeListener(null); holder.checkBox.setChecked(isChecked(pos)); holder.checkBox.setOnCheckedChangeListener(this); } } private boolean isChecked(int pos) { return !(mCheckedApps.indexOfKey(pos) < 0); } @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Object tag = buttonView.getTag(); if (tag instanceof ExportViewHolder) { ExportViewHolder holder = (ExportViewHolder) tag; handleCheck(holder, false); } }
// Path: app/src/main/java/com/zzzmode/appopsx/ui/main/AppItemViewHolder.java // public class AppItemViewHolder extends RecyclerView.ViewHolder { // // private ImageView imgIcon; // TextView tvName; // // public AppItemViewHolder(View itemView) { // super(itemView); // imgIcon = itemView.findViewById(R.id.app_icon); // tvName = itemView.findViewById(R.id.app_name); // } // // // public void bindData(AppInfo appInfo) { // tvName.setText(appInfo.appName); // LocalImageLoader.load(imgIcon, appInfo); // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ExportAdapter.java import androidx.annotation.NonNull; import androidx.collection.SparseArrayCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.CompoundButton; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.main.AppItemViewHolder; import com.zzzmode.appopsx.ui.model.AppInfo; import java.util.List; private void handleCheck(ExportViewHolder holder, boolean change) { int pos = holder.getAdapterPosition(); if (holder.checkBox.isChecked()) { mCheckedApps.delete(pos); } else { mCheckedApps.put(pos, appInfos.get(pos)); } if (change) { holder.checkBox.setOnCheckedChangeListener(null); holder.checkBox.setChecked(isChecked(pos)); holder.checkBox.setOnCheckedChangeListener(this); } } private boolean isChecked(int pos) { return !(mCheckedApps.indexOfKey(pos) < 0); } @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Object tag = buttonView.getTag(); if (tag instanceof ExportViewHolder) { ExportViewHolder holder = (ExportViewHolder) tag; handleCheck(holder, false); } }
static class ExportViewHolder extends AppItemViewHolder {
8enet/AppOpsX
opsxpro/src/main/java/com/zzzmode/appopsx/ServerStatusChangeReceiver.java
// Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/Actions.java // public final class Actions { // // public static final String ACTION_SERVER_STARTED="com.zzzmode.appopsx.action.SERVER_STARTED"; // public static final String ACTION_SERVER_CONNECTED="com.zzzmode.appopsx.action.SERVER_CONNECTED"; // public static final String ACTION_SERVER_DISCONNECTED="com.zzzmode.appopsx.action.SERVER_DISCONNECTED"; // public static final String ACTION_SERVER_STOPED="com.zzzmode.appopsx.action.SERVER_STOPED"; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import com.zzzmode.appopsx.common.Actions;
package com.zzzmode.appopsx; /** * Created by zl on 2017/10/12. */ public class ServerStatusChangeReceiver extends BroadcastReceiver { private static final String TAG = "ServerStatusChangeRecei"; @Override public void onReceive(Context context, Intent intent) { String token = intent.getStringExtra("token"); if(SConfig.getLocalToken().equals(token)) { String action = intent.getAction(); Log.e(TAG, "onReceive --> " + action + " " + token + " " + intent .getStringExtra("type"));
// Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/Actions.java // public final class Actions { // // public static final String ACTION_SERVER_STARTED="com.zzzmode.appopsx.action.SERVER_STARTED"; // public static final String ACTION_SERVER_CONNECTED="com.zzzmode.appopsx.action.SERVER_CONNECTED"; // public static final String ACTION_SERVER_DISCONNECTED="com.zzzmode.appopsx.action.SERVER_DISCONNECTED"; // public static final String ACTION_SERVER_STOPED="com.zzzmode.appopsx.action.SERVER_STOPED"; // } // Path: opsxpro/src/main/java/com/zzzmode/appopsx/ServerStatusChangeReceiver.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import com.zzzmode.appopsx.common.Actions; package com.zzzmode.appopsx; /** * Created by zl on 2017/10/12. */ public class ServerStatusChangeReceiver extends BroadcastReceiver { private static final String TAG = "ServerStatusChangeRecei"; @Override public void onReceive(Context context, Intent intent) { String token = intent.getStringExtra("token"); if(SConfig.getLocalToken().equals(token)) { String action = intent.getAction(); Log.e(TAG, "onReceive --> " + action + " " + token + " " + intent .getStringExtra("type"));
if (Actions.ACTION_SERVER_STARTED.equals(action)) {
8enet/AppOpsX
opsxlib/src/main/java/com/zzzmode/appopsx/common/ClassCaller.java
// Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/BaseCaller.java // public static final int TYPE_CLASS=3;
import static com.zzzmode.appopsx.common.BaseCaller.TYPE_CLASS; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays;
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.packageName); dest.writeString(this.className); dest.writeStringArray(this.sParamsType); dest.writeArray(this.params); } protected ClassCaller(Parcel in) { this.packageName = in.readString(); this.className = in.readString(); this.sParamsType = in.createStringArray(); this.params = in.readArray(Object[].class.getClassLoader()); } public static final Parcelable.Creator<ClassCaller> CREATOR = new Parcelable.Creator<ClassCaller>() { @Override public ClassCaller createFromParcel(Parcel source) { return new ClassCaller(source); } @Override public ClassCaller[] newArray(int size) { return new ClassCaller[size]; } }; @Override public int getType() {
// Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/BaseCaller.java // public static final int TYPE_CLASS=3; // Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/ClassCaller.java import static com.zzzmode.appopsx.common.BaseCaller.TYPE_CLASS; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays; @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.packageName); dest.writeString(this.className); dest.writeStringArray(this.sParamsType); dest.writeArray(this.params); } protected ClassCaller(Parcel in) { this.packageName = in.readString(); this.className = in.readString(); this.sParamsType = in.createStringArray(); this.params = in.readArray(Object[].class.getClassLoader()); } public static final Parcelable.Creator<ClassCaller> CREATOR = new Parcelable.Creator<ClassCaller>() { @Override public ClassCaller createFromParcel(Parcel source) { return new ClassCaller(source); } @Override public ClassCaller[] newArray(int size) { return new ClassCaller[size]; } }; @Override public int getType() {
return TYPE_CLASS;
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/permission/IPermView.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/OpEntryInfo.java // public class OpEntryInfo { // // private static Integer sMaxLength = null; // // public OpEntry opEntry; // public String opName; // public String opPermsName; // public String opPermsLab; // public String opPermsDesc; // public int mode; // public int icon; // public String groupName; // // public OpEntryInfo(OpEntry opEntry) { // if (opEntry != null) { // this.opEntry = opEntry; // this.mode = opEntry.getMode(); // String[] sOpNames = FixCompat.sOpNames(); // if (sMaxLength == null && sOpNames != null) { // sMaxLength = sOpNames.length; // } // // if (opEntry.getOp() < sMaxLength) { // String[] sOpPerms = FixCompat.sOpPerms(); // // if (sOpNames != null) { // this.opName = sOpNames[opEntry.getOp()]; // } // if (sOpPerms != null) { // this.opPermsName = sOpPerms[opEntry.getOp()]; // } // // // // } // } // } // // public boolean isAllowed() { // return this.mode == AppOpsManager.MODE_ALLOWED; // } // // public void changeStatus() { // if (isAllowed()) { // this.mode = AppOpsManager.MODE_IGNORED; // } else { // this.mode = AppOpsManager.MODE_ALLOWED; // } // } // // @Override // public String toString() { // return "OpEntryInfo{" + // ", opName='" + opName + '\'' + // ", opPermsName='" + opPermsName + '\'' + // ", opPermsLab='" + opPermsLab + '\'' + // ", mode=" + mode + // '}'; // } // }
import com.zzzmode.appopsx.ui.model.OpEntryInfo; import java.util.List;
package com.zzzmode.appopsx.ui.permission; /** * Created by zl on 2017/5/1. */ interface IPermView { void showProgress(boolean show); void showError(CharSequence text);
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/OpEntryInfo.java // public class OpEntryInfo { // // private static Integer sMaxLength = null; // // public OpEntry opEntry; // public String opName; // public String opPermsName; // public String opPermsLab; // public String opPermsDesc; // public int mode; // public int icon; // public String groupName; // // public OpEntryInfo(OpEntry opEntry) { // if (opEntry != null) { // this.opEntry = opEntry; // this.mode = opEntry.getMode(); // String[] sOpNames = FixCompat.sOpNames(); // if (sMaxLength == null && sOpNames != null) { // sMaxLength = sOpNames.length; // } // // if (opEntry.getOp() < sMaxLength) { // String[] sOpPerms = FixCompat.sOpPerms(); // // if (sOpNames != null) { // this.opName = sOpNames[opEntry.getOp()]; // } // if (sOpPerms != null) { // this.opPermsName = sOpPerms[opEntry.getOp()]; // } // // // // } // } // } // // public boolean isAllowed() { // return this.mode == AppOpsManager.MODE_ALLOWED; // } // // public void changeStatus() { // if (isAllowed()) { // this.mode = AppOpsManager.MODE_IGNORED; // } else { // this.mode = AppOpsManager.MODE_ALLOWED; // } // } // // @Override // public String toString() { // return "OpEntryInfo{" + // ", opName='" + opName + '\'' + // ", opPermsName='" + opPermsName + '\'' + // ", opPermsLab='" + opPermsLab + '\'' + // ", mode=" + mode + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/permission/IPermView.java import com.zzzmode.appopsx.ui.model.OpEntryInfo; import java.util.List; package com.zzzmode.appopsx.ui.permission; /** * Created by zl on 2017/5/1. */ interface IPermView { void showProgress(boolean show); void showError(CharSequence text);
void showPerms(List<OpEntryInfo> opEntryInfos);
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/SearchHandler.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/widget/CommonDivderDecorator.java // public class CommonDivderDecorator extends DividerItemDecoration { // // private static Drawable sDefDrawable; // // public CommonDivderDecorator(Context context, int orientation) { // super(context, orientation); // } // // public CommonDivderDecorator(Context context) { // super(context, VERTICAL); // // Drawable divider = ContextCompat.getDrawable(context, R.drawable.list_divider_h); // setDrawable(divider); // } // }
import android.graphics.Color; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.view.View; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.github.promeg.pinyinhelper.Pinyin; import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo; import com.zzzmode.appopsx.ui.widget.CommonDivderDecorator; import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.ObservableOnSubscribe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.observers.ResourceObserver; import io.reactivex.schedulers.Schedulers; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern;
package com.zzzmode.appopsx.ui.main; /** * Created by zl on 2017/1/23. */ class SearchHandler { private List<AppInfo> mBaseData; private RecyclerView recyclerView; private SearchResultAdapter mAdapter; void setBaseData(List<AppInfo> baseData) { this.mBaseData = baseData; } void initView(View container) { this.recyclerView = container.findViewById(R.id.search_result_recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/widget/CommonDivderDecorator.java // public class CommonDivderDecorator extends DividerItemDecoration { // // private static Drawable sDefDrawable; // // public CommonDivderDecorator(Context context, int orientation) { // super(context, orientation); // } // // public CommonDivderDecorator(Context context) { // super(context, VERTICAL); // // Drawable divider = ContextCompat.getDrawable(context, R.drawable.list_divider_h); // setDrawable(divider); // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/SearchHandler.java import android.graphics.Color; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.view.View; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.github.promeg.pinyinhelper.Pinyin; import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo; import com.zzzmode.appopsx.ui.widget.CommonDivderDecorator; import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.ObservableOnSubscribe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.observers.ResourceObserver; import io.reactivex.schedulers.Schedulers; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; package com.zzzmode.appopsx.ui.main; /** * Created by zl on 2017/1/23. */ class SearchHandler { private List<AppInfo> mBaseData; private RecyclerView recyclerView; private SearchResultAdapter mAdapter; void setBaseData(List<AppInfo> baseData) { this.mBaseData = baseData; } void initView(View container) { this.recyclerView = container.findViewById(R.id.search_result_recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
recyclerView.addItemDecoration(new CommonDivderDecorator(recyclerView.getContext()));
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/backup/BaseConfigFragment.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/widget/CommonDivderDecorator.java // public class CommonDivderDecorator extends DividerItemDecoration { // // private static Drawable sDefDrawable; // // public CommonDivderDecorator(Context context, int orientation) { // super(context, orientation); // } // // public CommonDivderDecorator(Context context) { // super(context, VERTICAL); // // Drawable divider = ContextCompat.getDrawable(context, R.drawable.list_divider_h); // setDrawable(divider); // } // }
import android.app.ProgressDialog; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.widget.CommonDivderDecorator;
package com.zzzmode.appopsx.ui.main.backup; /** * Created by zl on 2017/5/7. */ public class BaseConfigFragment extends Fragment implements IConfigView { RecyclerView recyclerView; @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); recyclerView = view.findViewById(R.id.recyclerView); if (recyclerView != null) { recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Path: app/src/main/java/com/zzzmode/appopsx/ui/widget/CommonDivderDecorator.java // public class CommonDivderDecorator extends DividerItemDecoration { // // private static Drawable sDefDrawable; // // public CommonDivderDecorator(Context context, int orientation) { // super(context, orientation); // } // // public CommonDivderDecorator(Context context) { // super(context, VERTICAL); // // Drawable divider = ContextCompat.getDrawable(context, R.drawable.list_divider_h); // setDrawable(divider); // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/backup/BaseConfigFragment.java import android.app.ProgressDialog; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.widget.CommonDivderDecorator; package com.zzzmode.appopsx.ui.main.backup; /** * Created by zl on 2017/5/7. */ public class BaseConfigFragment extends Fragment implements IConfigView { RecyclerView recyclerView; @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); recyclerView = view.findViewById(R.id.recyclerView); if (recyclerView != null) { recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.addItemDecoration(new CommonDivderDecorator(getContext()));
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/core/Users.java
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // }
import android.content.pm.UserInfo; import java.util.ArrayList; import java.util.List;
package com.zzzmode.appopsx.ui.core; public class Users { private static Users sUsers; public static Users getInstance(){ if(sUsers == null){ synchronized (Users.class){ if(sUsers == null){ sUsers = new Users(); } } } return sUsers; }
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/core/Users.java import android.content.pm.UserInfo; import java.util.ArrayList; import java.util.List; package com.zzzmode.appopsx.ui.core; public class Users { private static Users sUsers; public static Users getInstance(){ if(sUsers == null){ synchronized (Users.class){ if(sUsers == null){ sUsers = new Users(); } } } return sUsers; }
private List<UserInfo> userInfos;
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/core/LocalImageLoader.java
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // }
import android.app.ActivityManager; import android.content.Context; import android.content.pm.UserInfo; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.collection.LruCache; import android.widget.ImageView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo;
package com.zzzmode.appopsx.ui.core; /** * Created by zl on 2017/4/18. */ public class LocalImageLoader { private static LruCache<String, Drawable> sLruCache = null; private static void init(Context context) { if (sLruCache == null) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); int maxSize = Math.round(am.getMemoryClass() * 1024 * 1024 * 0.3f); sLruCache = new LruCache<String, Drawable>(maxSize) { @Override protected int sizeOf(String key, Drawable drawable) { if (drawable != null) { if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap().getAllocationByteCount(); } else { return drawable.getIntrinsicWidth() * drawable.getIntrinsicHeight() * 2; } } return super.sizeOf(key, drawable); } @Override protected void entryRemoved(boolean evicted, String key, Drawable oldValue, Drawable newValue) { super.entryRemoved(evicted, key, oldValue, newValue); } }; } }
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/core/LocalImageLoader.java import android.app.ActivityManager; import android.content.Context; import android.content.pm.UserInfo; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.collection.LruCache; import android.widget.ImageView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo; package com.zzzmode.appopsx.ui.core; /** * Created by zl on 2017/4/18. */ public class LocalImageLoader { private static LruCache<String, Drawable> sLruCache = null; private static void init(Context context) { if (sLruCache == null) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); int maxSize = Math.round(am.getMemoryClass() * 1024 * 1024 * 0.3f); sLruCache = new LruCache<String, Drawable>(maxSize) { @Override protected int sizeOf(String key, Drawable drawable) { if (drawable != null) { if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap().getAllocationByteCount(); } else { return drawable.getIntrinsicWidth() * drawable.getIntrinsicHeight() * 2; } } return super.sizeOf(key, drawable); } @Override protected void entryRemoved(boolean evicted, String key, Drawable oldValue, Drawable newValue) { super.entryRemoved(evicted, key, oldValue, newValue); } }; } }
public static void load(ImageView view, AppInfo appInfo) {
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/core/LocalImageLoader.java
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // }
import android.app.ActivityManager; import android.content.Context; import android.content.pm.UserInfo; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.collection.LruCache; import android.widget.ImageView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo;
Drawable newValue) { super.entryRemoved(evicted, key, oldValue, newValue); } }; } } public static void load(ImageView view, AppInfo appInfo) { Drawable drawable = getDrawable(view.getContext(), appInfo); if (drawable != null) { view.setImageDrawable(drawable); } else { view.setImageResource(R.mipmap.ic_launcher); } } public static Drawable getDrawable(Context context, AppInfo appInfo) { init(context); Drawable drawable = sLruCache.get(appInfo.packageName); if (drawable == null && appInfo.applicationInfo != null) { if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) { drawable = appInfo.applicationInfo.loadUnbadgedIcon(context.getPackageManager()); }else { drawable = appInfo.applicationInfo.loadIcon(context.getPackageManager()); }
// Path: apicompat/src/main/java/android/content/pm/UserInfo.java // public class UserInfo { // public int id; // public int serialNumber; // public String name; // public String iconPath; // public int flags; // // // public boolean isPrimary() { // return false; // } // // public boolean isAdmin() { // return false; // } // // public boolean isManagedProfile() { // return false; // } // // // public UserHandle getUserHandle() { // return null; // } // } // // Path: app/src/main/java/com/zzzmode/appopsx/ui/model/AppInfo.java // public class AppInfo implements Parcelable { // // public String appName; // public String packageName; // public long time; // public long installTime; // public long updateTime; // public String pinyin; // public ApplicationInfo applicationInfo; // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // AppInfo appInfo = (AppInfo) o; // // return packageName != null ? packageName.equals(appInfo.packageName) // : appInfo.packageName == null; // // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(this.appName); // dest.writeString(this.packageName); // } // // public AppInfo() { // } // // protected AppInfo(Parcel in) { // this.appName = in.readString(); // this.packageName = in.readString(); // } // // public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() { // @Override // public AppInfo createFromParcel(Parcel source) { // return new AppInfo(source); // } // // @Override // public AppInfo[] newArray(int size) { // return new AppInfo[size]; // } // }; // // // @Override // public String toString() { // return "AppInfo{" + // "appName='" + appName + '\'' + // ", packageName='" + packageName + '\'' + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/core/LocalImageLoader.java import android.app.ActivityManager; import android.content.Context; import android.content.pm.UserInfo; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.collection.LruCache; import android.widget.ImageView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.model.AppInfo; Drawable newValue) { super.entryRemoved(evicted, key, oldValue, newValue); } }; } } public static void load(ImageView view, AppInfo appInfo) { Drawable drawable = getDrawable(view.getContext(), appInfo); if (drawable != null) { view.setImageDrawable(drawable); } else { view.setImageResource(R.mipmap.ic_launcher); } } public static Drawable getDrawable(Context context, AppInfo appInfo) { init(context); Drawable drawable = sLruCache.get(appInfo.packageName); if (drawable == null && appInfo.applicationInfo != null) { if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) { drawable = appInfo.applicationInfo.loadUnbadgedIcon(context.getPackageManager()); }else { drawable = appInfo.applicationInfo.loadIcon(context.getPackageManager()); }
UserInfo currentUser = Users.getInstance().getCurrentUser();
8enet/AppOpsX
opsxlib/src/main/java/com/zzzmode/appopsx/server/ApiCompat.java
// Path: apicompat/src/main/java/android/app/ActivityThread.java // public class ActivityThread { // // public static IPackageManager getPackageManager() { // return null; // } // // public static ActivityThread systemMain() { // return null; // } // // public static ActivityThread currentActivityThread() { // return null; // } // // // public static Application currentApplication() { // return null; // } // // public static String currentProcessName() { // return null; // } // // public ContextImpl getSystemContext() { // return null; // } // // public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { // // } // // // // } // // Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/FLog.java // public class FLog { // // public static boolean writeLog = false; // private static FileOutputStream fos; // private static AtomicInteger sBufferSize = new AtomicInteger(); // private static AtomicInteger sErrorCount = new AtomicInteger(); // // private static void openFile() { // try { // if (writeLog && fos == null && sErrorCount.get() < 5) { // File file = new File("/data/local/tmp/opsx.txt"); // fos = new FileOutputStream(file); // // fos.write("\n\n\n--------------------".getBytes()); // fos.write(new Date().toString().getBytes()); // fos.write("\n\n".getBytes()); // chown(file.getAbsolutePath(),2000,2000); // chmod(file.getAbsolutePath(),0755); // } // } catch (Exception e) { // e.printStackTrace(); // sErrorCount.incrementAndGet(); // fos = null; // } // } // // private static void chown(String path, int uid, int gid){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chown(path,uid,gid); // }else { // Runtime.getRuntime().exec("chown "+uid+":"+gid+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // private static void chmod(String path,int mode){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chmod(path, mode); // }else { // Runtime.getRuntime().exec("chmod "+mode+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(String log) { // if (writeLog) { // System.out.println(log); // } else { // Log.e("appopsx", "Flog --> " + log); // } // // try { // if (writeLog) { // openFile(); // if (fos != null) { // fos.write(log.getBytes()); // fos.write("\n".getBytes()); // // if (sBufferSize.incrementAndGet() > 10) { // fos.getFD().sync(); // fos.flush(); // sBufferSize.set(0); // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(Throwable e) { // log(Log.getStackTraceString(e)); // } // // public static void close() { // try { // if (writeLog && fos != null) { // fos.getFD().sync(); // fos.close(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // }
import android.app.ActivityThread; import android.content.Intent; import com.zzzmode.appopsx.common.FLog;
package com.zzzmode.appopsx.server; /** * Created by zl on 2017/10/12. */ class ApiCompat { static void sendBroadcast(Intent intent) { try {
// Path: apicompat/src/main/java/android/app/ActivityThread.java // public class ActivityThread { // // public static IPackageManager getPackageManager() { // return null; // } // // public static ActivityThread systemMain() { // return null; // } // // public static ActivityThread currentActivityThread() { // return null; // } // // // public static Application currentApplication() { // return null; // } // // public static String currentProcessName() { // return null; // } // // public ContextImpl getSystemContext() { // return null; // } // // public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { // // } // // // // } // // Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/FLog.java // public class FLog { // // public static boolean writeLog = false; // private static FileOutputStream fos; // private static AtomicInteger sBufferSize = new AtomicInteger(); // private static AtomicInteger sErrorCount = new AtomicInteger(); // // private static void openFile() { // try { // if (writeLog && fos == null && sErrorCount.get() < 5) { // File file = new File("/data/local/tmp/opsx.txt"); // fos = new FileOutputStream(file); // // fos.write("\n\n\n--------------------".getBytes()); // fos.write(new Date().toString().getBytes()); // fos.write("\n\n".getBytes()); // chown(file.getAbsolutePath(),2000,2000); // chmod(file.getAbsolutePath(),0755); // } // } catch (Exception e) { // e.printStackTrace(); // sErrorCount.incrementAndGet(); // fos = null; // } // } // // private static void chown(String path, int uid, int gid){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chown(path,uid,gid); // }else { // Runtime.getRuntime().exec("chown "+uid+":"+gid+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // private static void chmod(String path,int mode){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chmod(path, mode); // }else { // Runtime.getRuntime().exec("chmod "+mode+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(String log) { // if (writeLog) { // System.out.println(log); // } else { // Log.e("appopsx", "Flog --> " + log); // } // // try { // if (writeLog) { // openFile(); // if (fos != null) { // fos.write(log.getBytes()); // fos.write("\n".getBytes()); // // if (sBufferSize.incrementAndGet() > 10) { // fos.getFD().sync(); // fos.flush(); // sBufferSize.set(0); // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(Throwable e) { // log(Log.getStackTraceString(e)); // } // // public static void close() { // try { // if (writeLog && fos != null) { // fos.getFD().sync(); // fos.close(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // } // Path: opsxlib/src/main/java/com/zzzmode/appopsx/server/ApiCompat.java import android.app.ActivityThread; import android.content.Intent; import com.zzzmode.appopsx.common.FLog; package com.zzzmode.appopsx.server; /** * Created by zl on 2017/10/12. */ class ApiCompat { static void sendBroadcast(Intent intent) { try {
ActivityThread.currentApplication().sendBroadcast(intent);
8enet/AppOpsX
opsxlib/src/main/java/com/zzzmode/appopsx/server/ApiCompat.java
// Path: apicompat/src/main/java/android/app/ActivityThread.java // public class ActivityThread { // // public static IPackageManager getPackageManager() { // return null; // } // // public static ActivityThread systemMain() { // return null; // } // // public static ActivityThread currentActivityThread() { // return null; // } // // // public static Application currentApplication() { // return null; // } // // public static String currentProcessName() { // return null; // } // // public ContextImpl getSystemContext() { // return null; // } // // public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { // // } // // // // } // // Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/FLog.java // public class FLog { // // public static boolean writeLog = false; // private static FileOutputStream fos; // private static AtomicInteger sBufferSize = new AtomicInteger(); // private static AtomicInteger sErrorCount = new AtomicInteger(); // // private static void openFile() { // try { // if (writeLog && fos == null && sErrorCount.get() < 5) { // File file = new File("/data/local/tmp/opsx.txt"); // fos = new FileOutputStream(file); // // fos.write("\n\n\n--------------------".getBytes()); // fos.write(new Date().toString().getBytes()); // fos.write("\n\n".getBytes()); // chown(file.getAbsolutePath(),2000,2000); // chmod(file.getAbsolutePath(),0755); // } // } catch (Exception e) { // e.printStackTrace(); // sErrorCount.incrementAndGet(); // fos = null; // } // } // // private static void chown(String path, int uid, int gid){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chown(path,uid,gid); // }else { // Runtime.getRuntime().exec("chown "+uid+":"+gid+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // private static void chmod(String path,int mode){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chmod(path, mode); // }else { // Runtime.getRuntime().exec("chmod "+mode+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(String log) { // if (writeLog) { // System.out.println(log); // } else { // Log.e("appopsx", "Flog --> " + log); // } // // try { // if (writeLog) { // openFile(); // if (fos != null) { // fos.write(log.getBytes()); // fos.write("\n".getBytes()); // // if (sBufferSize.incrementAndGet() > 10) { // fos.getFD().sync(); // fos.flush(); // sBufferSize.set(0); // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(Throwable e) { // log(Log.getStackTraceString(e)); // } // // public static void close() { // try { // if (writeLog && fos != null) { // fos.getFD().sync(); // fos.close(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // }
import android.app.ActivityThread; import android.content.Intent; import com.zzzmode.appopsx.common.FLog;
package com.zzzmode.appopsx.server; /** * Created by zl on 2017/10/12. */ class ApiCompat { static void sendBroadcast(Intent intent) { try { ActivityThread.currentApplication().sendBroadcast(intent); } catch (Exception e) { e.printStackTrace();
// Path: apicompat/src/main/java/android/app/ActivityThread.java // public class ActivityThread { // // public static IPackageManager getPackageManager() { // return null; // } // // public static ActivityThread systemMain() { // return null; // } // // public static ActivityThread currentActivityThread() { // return null; // } // // // public static Application currentApplication() { // return null; // } // // public static String currentProcessName() { // return null; // } // // public ContextImpl getSystemContext() { // return null; // } // // public void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { // // } // // // // } // // Path: opsxlib/src/main/java/com/zzzmode/appopsx/common/FLog.java // public class FLog { // // public static boolean writeLog = false; // private static FileOutputStream fos; // private static AtomicInteger sBufferSize = new AtomicInteger(); // private static AtomicInteger sErrorCount = new AtomicInteger(); // // private static void openFile() { // try { // if (writeLog && fos == null && sErrorCount.get() < 5) { // File file = new File("/data/local/tmp/opsx.txt"); // fos = new FileOutputStream(file); // // fos.write("\n\n\n--------------------".getBytes()); // fos.write(new Date().toString().getBytes()); // fos.write("\n\n".getBytes()); // chown(file.getAbsolutePath(),2000,2000); // chmod(file.getAbsolutePath(),0755); // } // } catch (Exception e) { // e.printStackTrace(); // sErrorCount.incrementAndGet(); // fos = null; // } // } // // private static void chown(String path, int uid, int gid){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chown(path,uid,gid); // }else { // Runtime.getRuntime().exec("chown "+uid+":"+gid+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // private static void chmod(String path,int mode){ // try { // if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { // Os.chmod(path, mode); // }else { // Runtime.getRuntime().exec("chmod "+mode+" "+path).destroy(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(String log) { // if (writeLog) { // System.out.println(log); // } else { // Log.e("appopsx", "Flog --> " + log); // } // // try { // if (writeLog) { // openFile(); // if (fos != null) { // fos.write(log.getBytes()); // fos.write("\n".getBytes()); // // if (sBufferSize.incrementAndGet() > 10) { // fos.getFD().sync(); // fos.flush(); // sBufferSize.set(0); // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // public static void log(Throwable e) { // log(Log.getStackTraceString(e)); // } // // public static void close() { // try { // if (writeLog && fos != null) { // fos.getFD().sync(); // fos.close(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // // } // Path: opsxlib/src/main/java/com/zzzmode/appopsx/server/ApiCompat.java import android.app.ActivityThread; import android.content.Intent; import com.zzzmode.appopsx.common.FLog; package com.zzzmode.appopsx.server; /** * Created by zl on 2017/10/12. */ class ApiCompat { static void sendBroadcast(Intent intent) { try { ActivityThread.currentApplication().sendBroadcast(intent); } catch (Exception e) { e.printStackTrace();
FLog.log(e);
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/backup/RestoreModel.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/PreAppInfo.java // public class PreAppInfo { // // private String packageName; // private String ignoredOps; // private List<Integer> ops; // // public PreAppInfo(String packageName, String ignoredOps) { // this.packageName = packageName; // this.ignoredOps = ignoredOps; // } // // public PreAppInfo(String packageName) { // this.packageName = packageName; // } // // public void setIgnoredOps(String ignoredOps) { // this.ignoredOps = ignoredOps; // } // // public String getPackageName() { // return packageName; // } // // public String getIgnoredOps() { // return ignoredOps; // } // // public List<Integer> getOps() { // if (ops == null) { // ops = new ArrayList<>(); // if (!TextUtils.isEmpty(ignoredOps)) { // String[] split = ignoredOps.split(","); // for (String s : split) { // try { // ops.add(Integer.valueOf(s)); // } catch (NumberFormatException e) { // e.printStackTrace(); // } // } // } // } // return ops; // } // // // @Override // public String toString() { // return "PreAppInfo{" + // "packageName='" + packageName + '\'' + // ", ignoredOps='" + ignoredOps + '\'' + // '}'; // } // }
import com.zzzmode.appopsx.ui.model.PreAppInfo; import java.util.List;
package com.zzzmode.appopsx.ui.main.backup; /** * Created by zl on 2017/5/7. */ class RestoreModel { long createTime; int version; int size; long fileSize; String path; String fileName;
// Path: app/src/main/java/com/zzzmode/appopsx/ui/model/PreAppInfo.java // public class PreAppInfo { // // private String packageName; // private String ignoredOps; // private List<Integer> ops; // // public PreAppInfo(String packageName, String ignoredOps) { // this.packageName = packageName; // this.ignoredOps = ignoredOps; // } // // public PreAppInfo(String packageName) { // this.packageName = packageName; // } // // public void setIgnoredOps(String ignoredOps) { // this.ignoredOps = ignoredOps; // } // // public String getPackageName() { // return packageName; // } // // public String getIgnoredOps() { // return ignoredOps; // } // // public List<Integer> getOps() { // if (ops == null) { // ops = new ArrayList<>(); // if (!TextUtils.isEmpty(ignoredOps)) { // String[] split = ignoredOps.split(","); // for (String s : split) { // try { // ops.add(Integer.valueOf(s)); // } catch (NumberFormatException e) { // e.printStackTrace(); // } // } // } // } // return ops; // } // // // @Override // public String toString() { // return "PreAppInfo{" + // "packageName='" + packageName + '\'' + // ", ignoredOps='" + ignoredOps + '\'' + // '}'; // } // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/backup/RestoreModel.java import com.zzzmode.appopsx.ui.model.PreAppInfo; import java.util.List; package com.zzzmode.appopsx.ui.main.backup; /** * Created by zl on 2017/5/7. */ class RestoreModel { long createTime; int version; int size; long fileSize; String path; String fileName;
List<PreAppInfo> preAppInfos;
8enet/AppOpsX
app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ImportAdapter.java
// Path: app/src/main/java/com/zzzmode/appopsx/ui/util/Formatter.java // public class Formatter { // // private static final SimpleDateFormat sdfYMD = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", // Locale.getDefault()); // // public static String formatDate(long time) { // return sdfYMD.format(new Date(time)); // } // // // public static final String B = "B"; // public static final String KB = "KB"; // public static final String MB = "MB"; // public static final String GB = "GB"; // public static final String TB = "TB"; // public static final String PB = "PB"; // // // public static String formatFileSize(long number) { // float result = number; // String suffix = B; // if (result > 900) { // suffix = KB; // result = result / 1024; // } // if (result > 900) { // suffix = MB; // result = result / 1024; // } // if (result > 900) { // suffix = GB; // result = result / 1024; // } // if (result > 900) { // suffix = TB; // result = result / 1024; // } // if (result > 900) { // suffix = PB; // result = result / 1024; // } // String value; // if (result < 1) { // value = String.format("%.2f", result); // } else if (result < 10) { // value = String.format("%.2f", result); // } else if (result < 100) { // value = String.format("%.2f", result); // } else { // value = String.format("%.0f", result); // } // return value + suffix; // } // // // }
import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.recyclerview.widget.RecyclerView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.util.Formatter; import java.util.ArrayList; import java.util.List;
} else { Toast.makeText(context, "delete error", Toast.LENGTH_LONG).show(); } } }) .setNegativeButton(android.R.string.cancel, null) .create(); alertDialog.show(); } static class ViewHolder extends RecyclerView.ViewHolder { TextView tvName; TextView tvTime; TextView tvBackCount; TextView tvFileSize; View delete; ViewHolder(View itemView) { super(itemView); tvName = itemView.findViewById(R.id.title); tvTime = itemView.findViewById(R.id.tv_time); tvBackCount = itemView.findViewById(R.id.tv_back_count); tvFileSize = itemView.findViewById(R.id.tv_file_len); delete = itemView.findViewById(R.id.fl_delete); } void bindData(RestoreModel model) { tvName.setText(model.fileName);
// Path: app/src/main/java/com/zzzmode/appopsx/ui/util/Formatter.java // public class Formatter { // // private static final SimpleDateFormat sdfYMD = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", // Locale.getDefault()); // // public static String formatDate(long time) { // return sdfYMD.format(new Date(time)); // } // // // public static final String B = "B"; // public static final String KB = "KB"; // public static final String MB = "MB"; // public static final String GB = "GB"; // public static final String TB = "TB"; // public static final String PB = "PB"; // // // public static String formatFileSize(long number) { // float result = number; // String suffix = B; // if (result > 900) { // suffix = KB; // result = result / 1024; // } // if (result > 900) { // suffix = MB; // result = result / 1024; // } // if (result > 900) { // suffix = GB; // result = result / 1024; // } // if (result > 900) { // suffix = TB; // result = result / 1024; // } // if (result > 900) { // suffix = PB; // result = result / 1024; // } // String value; // if (result < 1) { // value = String.format("%.2f", result); // } else if (result < 10) { // value = String.format("%.2f", result); // } else if (result < 100) { // value = String.format("%.2f", result); // } else { // value = String.format("%.0f", result); // } // return value + suffix; // } // // // } // Path: app/src/main/java/com/zzzmode/appopsx/ui/main/backup/ImportAdapter.java import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.recyclerview.widget.RecyclerView; import com.zzzmode.appopsx.R; import com.zzzmode.appopsx.ui.util.Formatter; import java.util.ArrayList; import java.util.List; } else { Toast.makeText(context, "delete error", Toast.LENGTH_LONG).show(); } } }) .setNegativeButton(android.R.string.cancel, null) .create(); alertDialog.show(); } static class ViewHolder extends RecyclerView.ViewHolder { TextView tvName; TextView tvTime; TextView tvBackCount; TextView tvFileSize; View delete; ViewHolder(View itemView) { super(itemView); tvName = itemView.findViewById(R.id.title); tvTime = itemView.findViewById(R.id.tv_time); tvBackCount = itemView.findViewById(R.id.tv_back_count); tvFileSize = itemView.findViewById(R.id.tv_file_len); delete = itemView.findViewById(R.id.fl_delete); } void bindData(RestoreModel model) { tvName.setText(model.fileName);
tvTime.setText(Formatter.formatDate(model.createTime));
8enet/AppOpsX
opsxpro/src/main/java/com/zzzmode/appopsx/AssetsUtils.java
// Path: opsxpro/src/main/java/com/zzzmode/appopsx/OpsxManager.java // public static class Config { // // public boolean allowBgRunning = false; // public String logFile; // public boolean printLog = false; // public boolean useAdb = false; // public boolean rootOverAdb = false; // public String adbHost = "127.0.0.1"; // public int adbPort = 5555; // Context context; // }
import android.content.Context; import android.content.res.AssetFileDescriptor; import android.os.Build; import android.text.TextUtils; import com.zzzmode.android.opsxpro.BuildConfig; import com.zzzmode.appopsx.OpsxManager.Config; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.SecureRandom;
int len = -1; fis = new FileInputStream(srcFile); while ((len = fis.read(buff)) != -1) { fos.write(buff, 0, len); } fos.flush(); fos.getFD().sync(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } try { if (fis != null) { fis.close(); } } catch (IOException e) { e.printStackTrace(); } } }
// Path: opsxpro/src/main/java/com/zzzmode/appopsx/OpsxManager.java // public static class Config { // // public boolean allowBgRunning = false; // public String logFile; // public boolean printLog = false; // public boolean useAdb = false; // public boolean rootOverAdb = false; // public String adbHost = "127.0.0.1"; // public int adbPort = 5555; // Context context; // } // Path: opsxpro/src/main/java/com/zzzmode/appopsx/AssetsUtils.java import android.content.Context; import android.content.res.AssetFileDescriptor; import android.os.Build; import android.text.TextUtils; import com.zzzmode.android.opsxpro.BuildConfig; import com.zzzmode.appopsx.OpsxManager.Config; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.SecureRandom; int len = -1; fis = new FileInputStream(srcFile); while ((len = fis.read(buff)) != -1) { fos.write(buff, 0, len); } fos.flush(); fos.getFD().sync(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } try { if (fis != null) { fis.close(); } } catch (IOException e) { e.printStackTrace(); } } }
static void writeScript(Config config){