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
|
|---|---|---|---|---|---|---|
justyoyo/Contrast
|
pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417.java
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeMatrix.java
// public final class BarcodeMatrix {
//
// private final BarcodeRow[] matrix;
// private int currentRow;
// private final int height;
// private final int width;
//
// /**
// * @param height the height of the matrix (Rows)
// * @param width the width of the matrix (Cols)
// */
// public BarcodeMatrix(int height, int width) {
// matrix = new BarcodeRow[height];
// //Initializes the array to the correct width
// for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) {
// matrix[i] = new BarcodeRow((width + 4) * 17 + 1);
// }
// this.width = width * 17;
// this.height = height;
// this.currentRow = -1;
// }
//
// public void set(int x, int y, byte value) {
// matrix[y].set(x, value);
// }
//
// /*
// void setMatrix(int x, int y, boolean black) {
// set(x, y, (byte) (black ? 1 : 0));
// }
// */
//
// public void startRow() {
// ++currentRow;
// }
//
// public BarcodeRow getCurrentRow() {
// return matrix[currentRow];
// }
//
// public byte[][] getMatrix() {
// return getScaledMatrix(1, 1);
// }
//
// /*
// public byte[][] getScaledMatrix(int scale) {
// return getScaledMatrix(scale, scale);
// }
// */
//
// public byte[][] getScaledMatrix(int xScale, int yScale) {
// byte[][] matrixOut = new byte[height * yScale][width * xScale];
// int yMax = height * yScale;
// for (int i = 0; i < yMax; i++) {
// matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
// }
// return matrixOut;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeRow.java
// public final class BarcodeRow {
//
// private final byte[] row;
// //A tacker for position in the bar
// private int currentLocation;
//
// /**
// * Creates a Barcode row of the width
// */
// BarcodeRow(int width) {
// this.row = new byte[width];
// currentLocation = 0;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param value Black if true, white if false;
// */
// void set(int x, byte value) {
// row[x] = value;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param black Black if true, white if false;
// */
// private void set(int x, boolean black) {
// row[x] = (byte) (black ? 1 : 0);
// }
//
// /**
// * @param black A boolean which is true if the bar black false if it is white
// * @param width How many spots wide the bar is.
// */
// public void addBar(boolean black, int width) {
// for (int ii = 0; ii < width; ii++) {
// set(currentLocation++, black);
// }
// }
//
// /*
// byte[] getRow() {
// return row;
// }
// */
//
// /**
// * This function scales the row
// *
// * @param scale How much you want the image to be scaled, must be greater than or equal to 1.
// * @return the scaled row
// */
// byte[] getScaledRow(int scale) {
// byte[] output = new byte[row.length * scale];
// for (int i = 0; i < output.length; i++) {
// output[i] = row[i / scale];
// }
// return output;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/Compaction.java
// public enum Compaction {
//
// AUTO,
// TEXT,
// BYTE,
// NUMERIC
//
// }
|
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.common.BarcodeMatrix;
import com.justyoyo.contrast.common.BarcodeRow;
import com.justyoyo.contrast.common.Compaction;
import java.nio.charset.Charset;
|
} else {
left = (30 * (y / 3)) + (c - 1);
right = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3);
}
int pattern = CODEWORD_TABLE[cluster][left];
encodeChar(pattern, 17, logic.getCurrentRow());
for (int x = 0; x < c; x++) {
pattern = CODEWORD_TABLE[cluster][fullCodewords.charAt(idx)];
encodeChar(pattern, 17, logic.getCurrentRow());
idx++;
}
if (compact) {
encodeChar(STOP_PATTERN, 1, logic.getCurrentRow()); // encodes stop line for compact pdf417
} else {
pattern = CODEWORD_TABLE[cluster][right];
encodeChar(pattern, 17, logic.getCurrentRow());
encodeChar(STOP_PATTERN, 18, logic.getCurrentRow());
}
}
}
/**
* @param msg message to encode
* @param errorCorrectionLevel PDF417 error correction level to use
* @throws if the contents cannot be encoded in this format
*/
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeMatrix.java
// public final class BarcodeMatrix {
//
// private final BarcodeRow[] matrix;
// private int currentRow;
// private final int height;
// private final int width;
//
// /**
// * @param height the height of the matrix (Rows)
// * @param width the width of the matrix (Cols)
// */
// public BarcodeMatrix(int height, int width) {
// matrix = new BarcodeRow[height];
// //Initializes the array to the correct width
// for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) {
// matrix[i] = new BarcodeRow((width + 4) * 17 + 1);
// }
// this.width = width * 17;
// this.height = height;
// this.currentRow = -1;
// }
//
// public void set(int x, int y, byte value) {
// matrix[y].set(x, value);
// }
//
// /*
// void setMatrix(int x, int y, boolean black) {
// set(x, y, (byte) (black ? 1 : 0));
// }
// */
//
// public void startRow() {
// ++currentRow;
// }
//
// public BarcodeRow getCurrentRow() {
// return matrix[currentRow];
// }
//
// public byte[][] getMatrix() {
// return getScaledMatrix(1, 1);
// }
//
// /*
// public byte[][] getScaledMatrix(int scale) {
// return getScaledMatrix(scale, scale);
// }
// */
//
// public byte[][] getScaledMatrix(int xScale, int yScale) {
// byte[][] matrixOut = new byte[height * yScale][width * xScale];
// int yMax = height * yScale;
// for (int i = 0; i < yMax; i++) {
// matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
// }
// return matrixOut;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/BarcodeRow.java
// public final class BarcodeRow {
//
// private final byte[] row;
// //A tacker for position in the bar
// private int currentLocation;
//
// /**
// * Creates a Barcode row of the width
// */
// BarcodeRow(int width) {
// this.row = new byte[width];
// currentLocation = 0;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param value Black if true, white if false;
// */
// void set(int x, byte value) {
// row[x] = value;
// }
//
// /**
// * Sets a specific location in the bar
// *
// * @param x The location in the bar
// * @param black Black if true, white if false;
// */
// private void set(int x, boolean black) {
// row[x] = (byte) (black ? 1 : 0);
// }
//
// /**
// * @param black A boolean which is true if the bar black false if it is white
// * @param width How many spots wide the bar is.
// */
// public void addBar(boolean black, int width) {
// for (int ii = 0; ii < width; ii++) {
// set(currentLocation++, black);
// }
// }
//
// /*
// byte[] getRow() {
// return row;
// }
// */
//
// /**
// * This function scales the row
// *
// * @param scale How much you want the image to be scaled, must be greater than or equal to 1.
// * @return the scaled row
// */
// byte[] getScaledRow(int scale) {
// byte[] output = new byte[row.length * scale];
// for (int i = 0; i < output.length; i++) {
// output[i] = row[i / scale];
// }
// return output;
// }
// }
//
// Path: core/src/main/java/com/justyoyo/contrast/common/Compaction.java
// public enum Compaction {
//
// AUTO,
// TEXT,
// BYTE,
// NUMERIC
//
// }
// Path: pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417.java
import com.justyoyo.contrast.WriterException;
import com.justyoyo.contrast.common.BarcodeMatrix;
import com.justyoyo.contrast.common.BarcodeRow;
import com.justyoyo.contrast.common.Compaction;
import java.nio.charset.Charset;
} else {
left = (30 * (y / 3)) + (c - 1);
right = (30 * (y / 3)) + (errorCorrectionLevel * 3) + ((r - 1) % 3);
}
int pattern = CODEWORD_TABLE[cluster][left];
encodeChar(pattern, 17, logic.getCurrentRow());
for (int x = 0; x < c; x++) {
pattern = CODEWORD_TABLE[cluster][fullCodewords.charAt(idx)];
encodeChar(pattern, 17, logic.getCurrentRow());
idx++;
}
if (compact) {
encodeChar(STOP_PATTERN, 1, logic.getCurrentRow()); // encodes stop line for compact pdf417
} else {
pattern = CODEWORD_TABLE[cluster][right];
encodeChar(pattern, 17, logic.getCurrentRow());
encodeChar(STOP_PATTERN, 18, logic.getCurrentRow());
}
}
}
/**
* @param msg message to encode
* @param errorCorrectionLevel PDF417 error correction level to use
* @throws if the contents cannot be encoded in this format
*/
|
public void generateBarcodeLogic(String msg, int errorCorrectionLevel) throws WriterException {
|
justyoyo/Contrast
|
core/src/main/java/com/justyoyo/contrast/common/CharacterSetECI.java
|
// Path: core/src/main/java/com/justyoyo/contrast/FormatException.java
// public final class FormatException extends ReaderException {
//
// private static final FormatException instance = new FormatException();
//
// private FormatException() {
// // do nothing
// }
//
// public static FormatException getFormatInstance() {
// return instance;
// }
//
// }
|
import com.justyoyo.contrast.FormatException;
import java.util.HashMap;
import java.util.Map;
|
}
}
private final int[] values;
private final String[] otherEncodingNames;
CharacterSetECI(int value) {
this(new int[] {value});
}
CharacterSetECI(int value, String... otherEncodingNames) {
this.values = new int[] {value};
this.otherEncodingNames = otherEncodingNames;
}
CharacterSetECI(int[] values, String... otherEncodingNames) {
this.values = values;
this.otherEncodingNames = otherEncodingNames;
}
public int getValue() {
return values[0];
}
/**
* @param value character set ECI value
* @return CharacterSetECI representing ECI of given value, or null if it is legal but
* unsupported
* @throws IllegalArgumentException if ECI value is invalid
*/
|
// Path: core/src/main/java/com/justyoyo/contrast/FormatException.java
// public final class FormatException extends ReaderException {
//
// private static final FormatException instance = new FormatException();
//
// private FormatException() {
// // do nothing
// }
//
// public static FormatException getFormatInstance() {
// return instance;
// }
//
// }
// Path: core/src/main/java/com/justyoyo/contrast/common/CharacterSetECI.java
import com.justyoyo.contrast.FormatException;
import java.util.HashMap;
import java.util.Map;
}
}
private final int[] values;
private final String[] otherEncodingNames;
CharacterSetECI(int value) {
this(new int[] {value});
}
CharacterSetECI(int value, String... otherEncodingNames) {
this.values = new int[] {value};
this.otherEncodingNames = otherEncodingNames;
}
CharacterSetECI(int[] values, String... otherEncodingNames) {
this.values = values;
this.otherEncodingNames = otherEncodingNames;
}
public int getValue() {
return values[0];
}
/**
* @param value character set ECI value
* @return CharacterSetECI representing ECI of given value, or null if it is legal but
* unsupported
* @throws IllegalArgumentException if ECI value is invalid
*/
|
public static CharacterSetECI getCharacterSetECIByValue(int value) throws FormatException {
|
justyoyo/Contrast
|
pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417ErrorCorrection.java
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
|
import com.justyoyo.contrast.WriterException;
|
752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596,
284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407,
164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768,
223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675,
410, 389, 244, 31, 121, 303, 263}};
private PDF417ErrorCorrection() {
}
/**
* Determines the number of error correction codewords for a specified error correction
* level.
*
* @param errorCorrectionLevel the error correction level (0-8)
* @return the number of codewords generated for error correction
*/
static int getErrorCorrectionCodewordCount(int errorCorrectionLevel) {
if (errorCorrectionLevel < 0 || errorCorrectionLevel > 8) {
throw new IllegalArgumentException("Error correction level must be between 0 and 8!");
}
return 1 << (errorCorrectionLevel + 1);
}
/**
* Returns the recommended minimum error correction level as described in annex E of
* ISO/IEC 15438:2001(E).
*
* @param n the number of data codewords
* @return the recommended minimum error correction level
*/
|
// Path: core/src/main/java/com/justyoyo/contrast/WriterException.java
// public final class WriterException extends Exception {
//
// public WriterException() {
// }
//
// public WriterException(String message) {
// super(message);
// }
//
// public WriterException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: pdf417/src/main/java/com/justyoyo/contrast/pdf417/PDF417ErrorCorrection.java
import com.justyoyo.contrast.WriterException;
752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596,
284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407,
164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768,
223, 849, 647, 63, 310, 863, 251, 366, 304, 282, 738, 675,
410, 389, 244, 31, 121, 303, 263}};
private PDF417ErrorCorrection() {
}
/**
* Determines the number of error correction codewords for a specified error correction
* level.
*
* @param errorCorrectionLevel the error correction level (0-8)
* @return the number of codewords generated for error correction
*/
static int getErrorCorrectionCodewordCount(int errorCorrectionLevel) {
if (errorCorrectionLevel < 0 || errorCorrectionLevel > 8) {
throw new IllegalArgumentException("Error correction level must be between 0 and 8!");
}
return 1 << (errorCorrectionLevel + 1);
}
/**
* Returns the recommended minimum error correction level as described in annex E of
* ISO/IEC 15438:2001(E).
*
* @param n the number of data codewords
* @return the recommended minimum error correction level
*/
|
static int getRecommendedMinimumErrorCorrectionLevel(int n) throws WriterException {
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/BufferSourceTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class BufferSourceTest {
@Test
public void testBufferSourceEmpty() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/BufferSourceTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class BufferSourceTest {
@Test
public void testBufferSourceEmpty() {
|
BufferSource bs = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/FullWaveRectifierTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class FullWaveRectifierTest {
@Test
public void testFullWaveRectifier() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/FullWaveRectifierTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class FullWaveRectifierTest {
@Test
public void testFullWaveRectifier() {
|
BufferSource bs = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/ImpulseSourceTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class ImpulseSourceTest {
@Test
public void testOutput() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/ImpulseSourceTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class ImpulseSourceTest {
@Test
public void testOutput() {
|
ImpulseSource is = new ImpulseSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/FirFilterTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
|
Assert.assertEquals(2, ff.taps());
c.add(1.0);
ff = new FirFilter(c);
Assert.assertEquals(3, ff.taps());
}
@Test
public void testOut() {
List<Double> c = new ArrayList<Double>();
c.add(0.0);
c.add(1.0);
FirFilter ff = new FirFilter(c);
for (int i = 0; i < 441000; i++) {
Assert.assertEquals(0.0, ff.output(), 0.0001);
}
}
@Test
public void testImpulseResponse() {
List<Double> c = new ArrayList<Double>();
c.add(0.0);
c.add(0.1);
c.add(1.0);
c.add(-0.1);
c.add(-1.0);
FirFilter ff = new FirFilter(c);
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/FirFilterTest.java
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
Assert.assertEquals(2, ff.taps());
c.add(1.0);
ff = new FirFilter(c);
Assert.assertEquals(3, ff.taps());
}
@Test
public void testOut() {
List<Double> c = new ArrayList<Double>();
c.add(0.0);
c.add(1.0);
FirFilter ff = new FirFilter(c);
for (int i = 0; i < 441000; i++) {
Assert.assertEquals(0.0, ff.output(), 0.0001);
}
}
@Test
public void testImpulseResponse() {
List<Double> c = new ArrayList<Double>();
c.add(0.0);
c.add(0.1);
c.add(1.0);
c.add(-0.1);
c.add(-1.0);
FirFilter ff = new FirFilter(c);
|
ff.setInput(new ImpulseSource());
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/SummerTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SummerTest {
@Test
public void testSummer() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/SummerTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SummerTest {
@Test
public void testSummer() {
|
BufferSource a = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/EnvelopeDetectorTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
|
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.SineSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class EnvelopeDetectorTest {
@Test
public void testEnvelopeDetector() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/EnvelopeDetectorTest.java
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.SineSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class EnvelopeDetectorTest {
@Test
public void testEnvelopeDetector() {
|
SineSource lo = new SineSource(44100, 1000);
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/NullSourceTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/NullSource.java
// public class NullSource implements SignalBlock {
// public double output() {
// return 0.0;
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.NullSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class NullSourceTest {
@Test
public void testOutput() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/NullSource.java
// public class NullSource implements SignalBlock {
// public double output() {
// return 0.0;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/NullSourceTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.NullSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class NullSourceTest {
@Test
public void testOutput() {
|
NullSource ns = new NullSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/ByteArraySourceTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ByteArraySource.java
// public class ByteArraySource implements SignalBlock {
// byte[] input;
// int highIndex;
// int lowIndex;
//
// public ByteArraySource(byte[] b, int h, int l) {
// input = b;
// highIndex = h;
// lowIndex = l;
// }
//
// public void setHighIndex(int i) {
// highIndex = i;
// }
//
// public void setLowIndex(int i) {
// lowIndex = i;
// }
//
// public double output() {
// short s = (short) ((input[highIndex] << 8) | (input[lowIndex] & 0xFF));
// double d = s / Short.MAX_VALUE;
//
// return d;
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ByteArraySource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class ByteArraySourceTest {
@Test
public void testOutput() {
byte[] b = new byte[4];
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ByteArraySource.java
// public class ByteArraySource implements SignalBlock {
// byte[] input;
// int highIndex;
// int lowIndex;
//
// public ByteArraySource(byte[] b, int h, int l) {
// input = b;
// highIndex = h;
// lowIndex = l;
// }
//
// public void setHighIndex(int i) {
// highIndex = i;
// }
//
// public void setLowIndex(int i) {
// lowIndex = i;
// }
//
// public double output() {
// short s = (short) ((input[highIndex] << 8) | (input[lowIndex] & 0xFF));
// double d = s / Short.MAX_VALUE;
//
// return d;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/ByteArraySourceTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ByteArraySource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class ByteArraySourceTest {
@Test
public void testOutput() {
byte[] b = new byte[4];
|
ByteArraySource bas = new ByteArraySource(b, 0, 1);
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/FilterFactoryTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
|
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
|
Assert.assertEquals(1.0, c.get(0), 0.0001);
Assert.assertEquals(2.0, c.get(1), 0.0001);
Assert.assertEquals(0.12345, c.get(2), 0.0001);
Assert.assertEquals(-0.5, c.get(3), 0.0001);
Assert.assertEquals(-1.0, c.get(4), 0.0001);
}
@Test
public void testLoadFirFromFileBadData() {
try {
FilterFactory.loadFirFromFile("/firTestBadData.txt");
Assert.fail("Did not throw exception.");
} catch (IOException e) {
}
}
@Test
public void testLoadFirFromFileBadFilename() throws IOException {
try {
FilterFactory.loadFirFromFile("/thisFileDoesNotExist.txt");
Assert.fail("Did not throw exception.");
} catch (FileNotFoundException e) {
}
}
@Test
public void testLoadFirFromFile() throws IOException {
FirFilter ff = FilterFactory.loadFirFromFile("/firTest.txt");
Assert.assertNotNull(ff);
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/ImpulseSource.java
// public class ImpulseSource implements SignalBlock {
// private boolean first;
//
// public ImpulseSource() {
// first = true;
// }
//
// public double output() {
// if (first) {
// first = false;
// return 1.0;
// } else {
// return 0.0;
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/FilterFactoryTest.java
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.ImpulseSource;
Assert.assertEquals(1.0, c.get(0), 0.0001);
Assert.assertEquals(2.0, c.get(1), 0.0001);
Assert.assertEquals(0.12345, c.get(2), 0.0001);
Assert.assertEquals(-0.5, c.get(3), 0.0001);
Assert.assertEquals(-1.0, c.get(4), 0.0001);
}
@Test
public void testLoadFirFromFileBadData() {
try {
FilterFactory.loadFirFromFile("/firTestBadData.txt");
Assert.fail("Did not throw exception.");
} catch (IOException e) {
}
}
@Test
public void testLoadFirFromFileBadFilename() throws IOException {
try {
FilterFactory.loadFirFromFile("/thisFileDoesNotExist.txt");
Assert.fail("Did not throw exception.");
} catch (FileNotFoundException e) {
}
}
@Test
public void testLoadFirFromFile() throws IOException {
FirFilter ff = FilterFactory.loadFirFromFile("/firTest.txt");
Assert.assertNotNull(ff);
|
ff.setInput(new ImpulseSource());
|
kms/sdr101-java
|
src/main/java/org/picofarad/sdr101/blocks/FirFilter.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/NullSource.java
// public class NullSource implements SignalBlock {
// public double output() {
// return 0.0;
// }
// }
|
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import org.picofarad.sdr101.blocks.sources.NullSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class FirFilter implements SignalBlock {
private Double[] coefficients;
private Deque<Double> buffer;
private SignalBlock input;
public FirFilter(List<Double> f) {
buffer = new ArrayDeque<Double>();
coefficients = f.toArray(new Double[0]);
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/NullSource.java
// public class NullSource implements SignalBlock {
// public double output() {
// return 0.0;
// }
// }
// Path: src/main/java/org/picofarad/sdr101/blocks/FirFilter.java
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import org.picofarad.sdr101.blocks.sources.NullSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class FirFilter implements SignalBlock {
private Double[] coefficients;
private Deque<Double> buffer;
private SignalBlock input;
public FirFilter(List<Double> f) {
buffer = new ArrayDeque<Double>();
coefficients = f.toArray(new Double[0]);
|
setInput(new NullSource());
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/MixerTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class MixerTest {
@Test
public void testMixer() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/MixerTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class MixerTest {
@Test
public void testMixer() {
|
BufferSource a = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/SplitterTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SplitterTest {
@Test
public void testOneWaySplitter() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/SplitterTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SplitterTest {
@Test
public void testOneWaySplitter() {
|
BufferSource bs = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/InvertedSummerTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class InvertedSummerTest {
@Test
public void testInvertedSummer() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/InvertedSummerTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class InvertedSummerTest {
@Test
public void testInvertedSummer() {
|
BufferSource a = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/CumulativeAverageFilterTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
//
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
import org.picofarad.sdr101.blocks.sources.SineSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class CumulativeAverageFilterTest {
@Test
public void testCumulativeAverageFilterSimple() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
//
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/CumulativeAverageFilterTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
import org.picofarad.sdr101.blocks.sources.SineSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class CumulativeAverageFilterTest {
@Test
public void testCumulativeAverageFilterSimple() {
|
BufferSource bs = new BufferSource();
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/CumulativeAverageFilterTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
//
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
import org.picofarad.sdr101.blocks.sources.SineSource;
|
bs.add(1.0);
bs.add(0.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
CumulativeAverageFilter maf = new CumulativeAverageFilter(bs, 2);
Assert.assertEquals(0.0, maf.output(), 0.001);
Assert.assertEquals(0.5, maf.output(), 0.001);
Assert.assertEquals(0.25, maf.output(), 0.001);
Assert.assertEquals(0.625, maf.output(), 0.001);
Assert.assertEquals(0.8125, maf.output(), 0.001);
maf.output();
maf.output();
maf.output();
maf.output();
maf.output();
maf.output();
Assert.assertEquals(1.0, maf.output(), 0.1);
}
@Test
public void testCumulativeAverageFilterSinus() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/BufferSource.java
// public class BufferSource implements SignalBlock {
// private Deque<Double> buffer;
//
// public BufferSource() {
// buffer = new ArrayDeque<Double>();
// }
//
// public void add(double d) {
// buffer.offer(d);
// }
//
// public double output() {
// if (buffer.isEmpty()) {
// return 0.0;
// } else {
// return buffer.remove();
// }
// }
// }
//
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/CumulativeAverageFilterTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.BufferSource;
import org.picofarad.sdr101.blocks.sources.SineSource;
bs.add(1.0);
bs.add(0.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
bs.add(1.0);
CumulativeAverageFilter maf = new CumulativeAverageFilter(bs, 2);
Assert.assertEquals(0.0, maf.output(), 0.001);
Assert.assertEquals(0.5, maf.output(), 0.001);
Assert.assertEquals(0.25, maf.output(), 0.001);
Assert.assertEquals(0.625, maf.output(), 0.001);
Assert.assertEquals(0.8125, maf.output(), 0.001);
maf.output();
maf.output();
maf.output();
maf.output();
maf.output();
maf.output();
Assert.assertEquals(1.0, maf.output(), 0.1);
}
@Test
public void testCumulativeAverageFilterSinus() {
|
SineSource lo = new SineSource(44100, 1000);
|
kms/sdr101-java
|
src/test/java/org/picofarad/sdr101/blocks/SineSourceTest.java
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.SineSource;
|
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SineSourceTest {
@Test
public void testOutputAt2Hz() {
|
// Path: src/main/java/org/picofarad/sdr101/blocks/sources/SineSource.java
// public class SineSource implements SignalBlock {
// private int sampleRate;
// private double frequency;
// private Double newFrequency;
// private double phaseOffset;
// private int sampleNumber;
//
// public SineSource(int sr, double f) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = 0.0;
// sampleNumber = 0;
// }
//
// public SineSource(int sr, double f, double p) {
// sampleRate = sr;
// frequency = f;
// phaseOffset = p;
// sampleNumber = 0;
// }
//
// public void setFrequency(double f) {
// newFrequency = f;
// }
//
// public double output() {
// double r;
// double position = (double) sampleNumber / sampleRate;
// double offset = (phaseOffset / 360) / frequency;
//
// r = Math.sin(2 * Math.PI * (position + offset) * frequency);
//
// sampleNumber++;
// if (sampleNumber == sampleRate) {
// sampleNumber = 0;
// if (newFrequency != null) {
// frequency = newFrequency;
// newFrequency = null;
// }
// }
//
// return r;
// }
// }
// Path: src/test/java/org/picofarad/sdr101/blocks/SineSourceTest.java
import org.junit.Assert;
import org.junit.Test;
import org.picofarad.sdr101.blocks.sources.SineSource;
/* sdr101-java
* Simple software-defined radio for Java.
*
* (c) Karl-Martin Skontorp <kms@skontorp.net> ~ http://22pf.org/
* Licensed under the GNU GPL 2.0 or later.
*/
package org.picofarad.sdr101.blocks;
public class SineSourceTest {
@Test
public void testOutputAt2Hz() {
|
SineSource lo = new SineSource(8, 2);
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/json/LoggedRollupListener.java
|
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
|
import java.util.List;
import java.util.Map;
import com.cscotta.deschutes.example.requests.RequestEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
|
package com.cscotta.deschutes.json;
public class LoggedRollupListener implements OutputListener<RequestEvent> {
private final ObjectMapper jackson = new Json().objectMapper;
private static final Logger log = LoggerFactory.getLogger(LoggedRollupListener.class);
@Override
|
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
// Path: src/main/java/com/cscotta/deschutes/json/LoggedRollupListener.java
import java.util.List;
import java.util.Map;
import com.cscotta.deschutes.example.requests.RequestEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
package com.cscotta.deschutes.json;
public class LoggedRollupListener implements OutputListener<RequestEvent> {
private final ObjectMapper jackson = new Json().objectMapper;
private static final Logger log = LoggerFactory.getLogger(LoggedRollupListener.class);
@Override
|
public void update(List<Long> remove, Map<Long, Map<String, ConcurrentRollup<RequestEvent>>> insert) {
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/example/requests/WebsocketRollupListener.java
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/websockets/OLAPWebSocket.java
// public class OLAPWebSocket implements WebSocket, WebSocket.OnTextMessage {
//
// private static final Logger log = LoggerFactory.getLogger(OLAPWebSocket.class);
//
// public Connection connection;
// private Set<OLAPWebSocket> users;
//
// public OLAPWebSocket(Set<OLAPWebSocket> users) {
// this.users = users;
// }
//
// @Override
// public void onOpen(Connection connection) {
// log.info("Connection opened: " + connection.toString());
// this.connection = connection;
// users.add(this);
// }
//
// @Override
// public void onClose(int closeCode, String message) {
// log.info("Connection closed: " + connection.toString());
// users.remove(this);
// }
//
// @Override
// public void onMessage(String data) {
// log.info("Message received from : " + connection.toString() + ": " + data);
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
|
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.example.app.websockets.OLAPWebSocket;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
package com.cscotta.deschutes.example.requests;
public class WebsocketRollupListener implements OutputListener<RequestEvent> {
private final Set<OLAPWebSocket> users;
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/websockets/OLAPWebSocket.java
// public class OLAPWebSocket implements WebSocket, WebSocket.OnTextMessage {
//
// private static final Logger log = LoggerFactory.getLogger(OLAPWebSocket.class);
//
// public Connection connection;
// private Set<OLAPWebSocket> users;
//
// public OLAPWebSocket(Set<OLAPWebSocket> users) {
// this.users = users;
// }
//
// @Override
// public void onOpen(Connection connection) {
// log.info("Connection opened: " + connection.toString());
// this.connection = connection;
// users.add(this);
// }
//
// @Override
// public void onClose(int closeCode, String message) {
// log.info("Connection closed: " + connection.toString());
// users.remove(this);
// }
//
// @Override
// public void onMessage(String data) {
// log.info("Message received from : " + connection.toString() + ": " + data);
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
// Path: src/main/java/com/cscotta/deschutes/example/requests/WebsocketRollupListener.java
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.example.app.websockets.OLAPWebSocket;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
package com.cscotta.deschutes.example.requests;
public class WebsocketRollupListener implements OutputListener<RequestEvent> {
private final Set<OLAPWebSocket> users;
|
private final ObjectMapper jackson = new Json().objectMapper;
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/example/requests/WebsocketRollupListener.java
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/websockets/OLAPWebSocket.java
// public class OLAPWebSocket implements WebSocket, WebSocket.OnTextMessage {
//
// private static final Logger log = LoggerFactory.getLogger(OLAPWebSocket.class);
//
// public Connection connection;
// private Set<OLAPWebSocket> users;
//
// public OLAPWebSocket(Set<OLAPWebSocket> users) {
// this.users = users;
// }
//
// @Override
// public void onOpen(Connection connection) {
// log.info("Connection opened: " + connection.toString());
// this.connection = connection;
// users.add(this);
// }
//
// @Override
// public void onClose(int closeCode, String message) {
// log.info("Connection closed: " + connection.toString());
// users.remove(this);
// }
//
// @Override
// public void onMessage(String data) {
// log.info("Message received from : " + connection.toString() + ": " + data);
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
|
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.example.app.websockets.OLAPWebSocket;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
package com.cscotta.deschutes.example.requests;
public class WebsocketRollupListener implements OutputListener<RequestEvent> {
private final Set<OLAPWebSocket> users;
private final ObjectMapper jackson = new Json().objectMapper;
private static final Logger log = LoggerFactory.getLogger(WebsocketRollupListener.class);
public WebsocketRollupListener(Set<OLAPWebSocket> users) {
this.users = users;
}
@Override
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/OutputListener.java
// public interface OutputListener<Input> {
//
// public void update(List<Long> remove,
// Map<Long, Map<String, ConcurrentRollup<Input>>> insert);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/websockets/OLAPWebSocket.java
// public class OLAPWebSocket implements WebSocket, WebSocket.OnTextMessage {
//
// private static final Logger log = LoggerFactory.getLogger(OLAPWebSocket.class);
//
// public Connection connection;
// private Set<OLAPWebSocket> users;
//
// public OLAPWebSocket(Set<OLAPWebSocket> users) {
// this.users = users;
// }
//
// @Override
// public void onOpen(Connection connection) {
// log.info("Connection opened: " + connection.toString());
// this.connection = connection;
// users.add(this);
// }
//
// @Override
// public void onClose(int closeCode, String message) {
// log.info("Connection closed: " + connection.toString());
// users.remove(this);
// }
//
// @Override
// public void onMessage(String data) {
// log.info("Message received from : " + connection.toString() + ": " + data);
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/json/Json.java
// public class Json {
// public final ObjectMapper objectMapper = new ObjectMapper();
//
// public Json() {
// SimpleModule olapMods = new SimpleModule("olapMods", new Version(1,0,0,null));
// olapMods.addSerializer(new HistogramSnapshotSerializer());
// objectMapper.registerModule(olapMods);
// }
//
// }
// Path: src/main/java/com/cscotta/deschutes/example/requests/WebsocketRollupListener.java
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.OutputListener;
import com.cscotta.deschutes.example.app.websockets.OLAPWebSocket;
import com.cscotta.deschutes.json.Json;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
package com.cscotta.deschutes.example.requests;
public class WebsocketRollupListener implements OutputListener<RequestEvent> {
private final Set<OLAPWebSocket> users;
private final ObjectMapper jackson = new Json().objectMapper;
private static final Logger log = LoggerFactory.getLogger(WebsocketRollupListener.class);
public WebsocketRollupListener(Set<OLAPWebSocket> users) {
this.users = users;
}
@Override
|
public void update(List<Long> remove, Map<Long, Map<String, ConcurrentRollup<RequestEvent>>> insert) {
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/input/CyclingProtobufPreReader.java
|
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java
// public interface EventWrapper<RawInput, WrappedInput> {
//
// public WrappedInput wrap(RawInput raw);
//
// }
|
import com.cscotta.deschutes.api.EventWrapper;
import com.google.protobuf.Parser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
|
package com.cscotta.deschutes.input;
public class CyclingProtobufPreReader<ProtoType, Input> implements Iterable<Input> {
final Parser<ProtoType> parser;
final InputStream inputStream;
|
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java
// public interface EventWrapper<RawInput, WrappedInput> {
//
// public WrappedInput wrap(RawInput raw);
//
// }
// Path: src/main/java/com/cscotta/deschutes/input/CyclingProtobufPreReader.java
import com.cscotta.deschutes.api.EventWrapper;
import com.google.protobuf.Parser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
package com.cscotta.deschutes.input;
public class CyclingProtobufPreReader<ProtoType, Input> implements Iterable<Input> {
final Parser<ProtoType> parser;
final InputStream inputStream;
|
final EventWrapper<ProtoType, Input> eventWrapper;
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java
// public interface RollupFactory<T> {
//
// public ConcurrentRollup<T> buildRollup(long timestamp);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java
// public class RequestRollup implements ConcurrentRollup<RequestEvent> {
//
// private final long timestamp;
//
// public RequestRollup(long timestamp) {
// this.timestamp = timestamp;
// }
//
// private final AtomicLong requestCount = new AtomicLong(0);
// private final AtomicLong totalRequestBytes = new AtomicLong(0);
// private final AtomicLong totalResponseBytes = new AtomicLong(0);
//
// private final Histogram requestBytesHisto = new Histogram(new UniformReservoir());
// private final Histogram responseBytesHisto = new Histogram(new UniformReservoir());
//
// private final Histogram handshakeUsec = new Histogram(new UniformReservoir());
// private final Histogram usecToFirstByte = new Histogram(new UniformReservoir());
// private final Histogram usecTotal = new Histogram(new UniformReservoir());
//
//
// public long getRequestCount() { return requestCount.get(); }
// public long getTotalRequestBytes() { return totalRequestBytes.get(); }
// public long getTotalResponseBytes() { return totalResponseBytes.get(); }
//
// public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); }
// public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); }
//
// public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); }
// public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); }
// public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); }
//
// @Override
// public void rollup(RequestEvent request) {
// requestCount.incrementAndGet();
// totalRequestBytes.addAndGet(request.getRequestBytes());
// totalResponseBytes.addAndGet(request.getResponseBytes());
// requestBytesHisto.update(request.getRequestBytes());
// responseBytesHisto.update(request.getResponseBytes());
// handshakeUsec.update(request.getHandshakeUsec());
// usecToFirstByte.update(request.getUsecToFirstByte());
// usecTotal.update(request.getUsecTotal());
// }
//
// @Override
// public long getTimestamp() {
// return this.timestamp;
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
|
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.RollupFactory;
import com.cscotta.deschutes.example.requests.RequestRollup;
import com.cscotta.deschutes.example.requests.RequestEvent;
|
package com.cscotta.deschutes.example.requests;
public class RequestRollups {
public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() {
@Override
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java
// public interface RollupFactory<T> {
//
// public ConcurrentRollup<T> buildRollup(long timestamp);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java
// public class RequestRollup implements ConcurrentRollup<RequestEvent> {
//
// private final long timestamp;
//
// public RequestRollup(long timestamp) {
// this.timestamp = timestamp;
// }
//
// private final AtomicLong requestCount = new AtomicLong(0);
// private final AtomicLong totalRequestBytes = new AtomicLong(0);
// private final AtomicLong totalResponseBytes = new AtomicLong(0);
//
// private final Histogram requestBytesHisto = new Histogram(new UniformReservoir());
// private final Histogram responseBytesHisto = new Histogram(new UniformReservoir());
//
// private final Histogram handshakeUsec = new Histogram(new UniformReservoir());
// private final Histogram usecToFirstByte = new Histogram(new UniformReservoir());
// private final Histogram usecTotal = new Histogram(new UniformReservoir());
//
//
// public long getRequestCount() { return requestCount.get(); }
// public long getTotalRequestBytes() { return totalRequestBytes.get(); }
// public long getTotalResponseBytes() { return totalResponseBytes.get(); }
//
// public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); }
// public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); }
//
// public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); }
// public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); }
// public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); }
//
// @Override
// public void rollup(RequestEvent request) {
// requestCount.incrementAndGet();
// totalRequestBytes.addAndGet(request.getRequestBytes());
// totalResponseBytes.addAndGet(request.getResponseBytes());
// requestBytesHisto.update(request.getRequestBytes());
// responseBytesHisto.update(request.getResponseBytes());
// handshakeUsec.update(request.getHandshakeUsec());
// usecToFirstByte.update(request.getUsecToFirstByte());
// usecTotal.update(request.getUsecTotal());
// }
//
// @Override
// public long getTimestamp() {
// return this.timestamp;
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.RollupFactory;
import com.cscotta.deschutes.example.requests.RequestRollup;
import com.cscotta.deschutes.example.requests.RequestEvent;
package com.cscotta.deschutes.example.requests;
public class RequestRollups {
public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() {
@Override
|
public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java
// public interface RollupFactory<T> {
//
// public ConcurrentRollup<T> buildRollup(long timestamp);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java
// public class RequestRollup implements ConcurrentRollup<RequestEvent> {
//
// private final long timestamp;
//
// public RequestRollup(long timestamp) {
// this.timestamp = timestamp;
// }
//
// private final AtomicLong requestCount = new AtomicLong(0);
// private final AtomicLong totalRequestBytes = new AtomicLong(0);
// private final AtomicLong totalResponseBytes = new AtomicLong(0);
//
// private final Histogram requestBytesHisto = new Histogram(new UniformReservoir());
// private final Histogram responseBytesHisto = new Histogram(new UniformReservoir());
//
// private final Histogram handshakeUsec = new Histogram(new UniformReservoir());
// private final Histogram usecToFirstByte = new Histogram(new UniformReservoir());
// private final Histogram usecTotal = new Histogram(new UniformReservoir());
//
//
// public long getRequestCount() { return requestCount.get(); }
// public long getTotalRequestBytes() { return totalRequestBytes.get(); }
// public long getTotalResponseBytes() { return totalResponseBytes.get(); }
//
// public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); }
// public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); }
//
// public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); }
// public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); }
// public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); }
//
// @Override
// public void rollup(RequestEvent request) {
// requestCount.incrementAndGet();
// totalRequestBytes.addAndGet(request.getRequestBytes());
// totalResponseBytes.addAndGet(request.getResponseBytes());
// requestBytesHisto.update(request.getRequestBytes());
// responseBytesHisto.update(request.getResponseBytes());
// handshakeUsec.update(request.getHandshakeUsec());
// usecToFirstByte.update(request.getUsecToFirstByte());
// usecTotal.update(request.getUsecTotal());
// }
//
// @Override
// public long getTimestamp() {
// return this.timestamp;
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
|
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.RollupFactory;
import com.cscotta.deschutes.example.requests.RequestRollup;
import com.cscotta.deschutes.example.requests.RequestEvent;
|
package com.cscotta.deschutes.example.requests;
public class RequestRollups {
public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() {
@Override
public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
|
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java
// public interface ConcurrentRollup<Input> extends Event {
//
// /**
// * <p>Rollup method called as events are received by a stream for
// * aggregation.</p>
// *
// * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain
// * the aggregations desired (sums, averages, histograms, and so on), and expose
// * them for downstream {@link OutputListener}s to access as output. See the
// * {@link ConcurrentRollup} documentation above for a sample implementation.</p>
// *
// * @param input An event received by a stream to be rolled up.
// */
// public abstract void rollup(Input input);
//
// public long getTimestamp();
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java
// public interface RollupFactory<T> {
//
// public ConcurrentRollup<T> buildRollup(long timestamp);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java
// public class RequestRollup implements ConcurrentRollup<RequestEvent> {
//
// private final long timestamp;
//
// public RequestRollup(long timestamp) {
// this.timestamp = timestamp;
// }
//
// private final AtomicLong requestCount = new AtomicLong(0);
// private final AtomicLong totalRequestBytes = new AtomicLong(0);
// private final AtomicLong totalResponseBytes = new AtomicLong(0);
//
// private final Histogram requestBytesHisto = new Histogram(new UniformReservoir());
// private final Histogram responseBytesHisto = new Histogram(new UniformReservoir());
//
// private final Histogram handshakeUsec = new Histogram(new UniformReservoir());
// private final Histogram usecToFirstByte = new Histogram(new UniformReservoir());
// private final Histogram usecTotal = new Histogram(new UniformReservoir());
//
//
// public long getRequestCount() { return requestCount.get(); }
// public long getTotalRequestBytes() { return totalRequestBytes.get(); }
// public long getTotalResponseBytes() { return totalResponseBytes.get(); }
//
// public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); }
// public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); }
//
// public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); }
// public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); }
// public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); }
//
// @Override
// public void rollup(RequestEvent request) {
// requestCount.incrementAndGet();
// totalRequestBytes.addAndGet(request.getRequestBytes());
// totalResponseBytes.addAndGet(request.getResponseBytes());
// requestBytesHisto.update(request.getRequestBytes());
// responseBytesHisto.update(request.getResponseBytes());
// handshakeUsec.update(request.getHandshakeUsec());
// usecToFirstByte.update(request.getUsecToFirstByte());
// usecTotal.update(request.getUsecTotal());
// }
//
// @Override
// public long getTimestamp() {
// return this.timestamp;
// }
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java
// public class RequestEvent implements Event {
//
// private final Request request;
//
// public RequestEvent(Request request) {
// this.request = request;
// }
//
// @Override
// public long getTimestamp() {
// return request.getTimestamp();
// }
//
// public int getUserId() {
// return request.getUserId();
// }
//
// public int getClientIp() {
// return request.getClientIp();
// }
//
// public int getServerIp() {
// return request.getServerIp();
// }
//
// public OperationType getOperationType() {
// return request.getOperationType();
// }
//
// public Protocol getProtocol() {
// return request.getProtocol();
// }
//
// public int getResponseCode() {
// return request.getResponseCode();
// }
//
// public String getUri() {
// return request.getUri();
// }
//
// public int getRequestBytes() {
// return request.getRequestBytes();
// }
//
// public int getResponseBytes() {
// return request.getResponseBytes();
// }
//
// public long getHandshakeUsec() {
// return request.getHandshakeUsec();
// }
//
// public long getUsecToFirstByte() {
// return request.getUsecToFirstByte();
// }
//
// public long getUsecTotal() {
// return request.getUsecTotal();
// }
//
// public String getUserAgent() {
// return request.getUserAgent();
// }
//
// public String getLocale() {
// return request.getLocale();
// }
//
// public String getReferrer() {
// return request.getReferrer();
// }
//
// @Override
// public String toString() {
// return request.toString();
// }
//
// }
// Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
import com.cscotta.deschutes.api.ConcurrentRollup;
import com.cscotta.deschutes.api.RollupFactory;
import com.cscotta.deschutes.example.requests.RequestRollup;
import com.cscotta.deschutes.example.requests.RequestEvent;
package com.cscotta.deschutes.example.requests;
public class RequestRollups {
public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() {
@Override
public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
|
return new RequestRollup(timestamp);
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/aggregation/Stream.java
|
// Path: src/main/java/com/cscotta/deschutes/api/Event.java
// public interface Event {
//
// /**
// * Retrieve the timestamp of an event, represented as a long in
// * milliseconds since epoch.
// *
// * @return The timestamp of this event, represented as a long in
// * milliseconds since epoch.
// */
// public long getTimestamp();
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java
// public interface StreamAggregator<Input extends Event> {
//
// public void observe(Input event);
//
// public StreamAggregator<Input> addListener(OutputListener<Input> listener);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/App.java
// public class App extends Service<Config> {
//
// public static final MetricRegistry metrics = new MetricRegistry();
// private static final Logger log = LoggerFactory.getLogger(App.class);
// private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
// ConsoleReporter reporter;
//
// public static void main(String[] args) throws Exception {
// new App().run(args);
// }
//
// @Override
// public void initialize(Bootstrap<Config> bootstrap) {
// bootstrap.setName("app");
// }
//
// @Override
// public void run(Config config, Environment env) throws Exception {
// WebsocketApi websocketApi = new WebsocketApi();
// env.addServlet(websocketApi, "/websocket");
//
// // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream.
// final Iterable<RequestEvent> reader;
// if (config.getDataSource().equals("generated")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new ProtobufReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// } else if (config.getDataSource().equals("preloaded")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new CyclingProtobufPreReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize();
// } else {
// reader = new SyntheticProtobufs(1000, 1000);
// }
//
// // Report metrics to the console.
// reporter = ConsoleReporter.forRegistry(metrics).
// convertRatesTo(TimeUnit.SECONDS).
// convertDurationsTo(TimeUnit.MILLISECONDS).
// build();
// reporter.start(30, TimeUnit.SECONDS);
//
// // Initialize websocket output
// OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users);
//
// // Prepare our stream
// final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads());
//
// // Add aggregator(s) to stream - nonblocking or lock-striped for now.
// if (config.getAggregatorType().equals("nonblocking")) {
// log.info("Launching non-blocking stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
//
// } else if (config.getAggregatorType().equals("lock_striped")) {
// log.info("Launching lock-striped stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
// } else {
// log.error("Unknown stream type specified.");
// }
//
// stream.launch();
//
// // Optionally terminate program after x seconds for benchmarking purposes.
// if (config.getRunFor() > 0) {
// log.info("Scheduling termination of program in " + config.getRunFor() + " seconds...");
// stpe.schedule(new Runnable() {
// @Override
// public void run() {
// log.info("Terminating program. Final results: ");
// reporter.report();
// System.exit(0);
// }
// }, config.getRunFor(), TimeUnit.SECONDS);
// }
// }
// }
|
import com.codahale.metrics.Meter;
import com.cscotta.deschutes.api.Event;
import com.cscotta.deschutes.api.StreamAggregator;
import com.cscotta.deschutes.example.app.App;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
|
package com.cscotta.deschutes.aggregation;
public class Stream<Input extends Event> {
private final Iterable<Input> source;
|
// Path: src/main/java/com/cscotta/deschutes/api/Event.java
// public interface Event {
//
// /**
// * Retrieve the timestamp of an event, represented as a long in
// * milliseconds since epoch.
// *
// * @return The timestamp of this event, represented as a long in
// * milliseconds since epoch.
// */
// public long getTimestamp();
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java
// public interface StreamAggregator<Input extends Event> {
//
// public void observe(Input event);
//
// public StreamAggregator<Input> addListener(OutputListener<Input> listener);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/App.java
// public class App extends Service<Config> {
//
// public static final MetricRegistry metrics = new MetricRegistry();
// private static final Logger log = LoggerFactory.getLogger(App.class);
// private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
// ConsoleReporter reporter;
//
// public static void main(String[] args) throws Exception {
// new App().run(args);
// }
//
// @Override
// public void initialize(Bootstrap<Config> bootstrap) {
// bootstrap.setName("app");
// }
//
// @Override
// public void run(Config config, Environment env) throws Exception {
// WebsocketApi websocketApi = new WebsocketApi();
// env.addServlet(websocketApi, "/websocket");
//
// // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream.
// final Iterable<RequestEvent> reader;
// if (config.getDataSource().equals("generated")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new ProtobufReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// } else if (config.getDataSource().equals("preloaded")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new CyclingProtobufPreReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize();
// } else {
// reader = new SyntheticProtobufs(1000, 1000);
// }
//
// // Report metrics to the console.
// reporter = ConsoleReporter.forRegistry(metrics).
// convertRatesTo(TimeUnit.SECONDS).
// convertDurationsTo(TimeUnit.MILLISECONDS).
// build();
// reporter.start(30, TimeUnit.SECONDS);
//
// // Initialize websocket output
// OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users);
//
// // Prepare our stream
// final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads());
//
// // Add aggregator(s) to stream - nonblocking or lock-striped for now.
// if (config.getAggregatorType().equals("nonblocking")) {
// log.info("Launching non-blocking stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
//
// } else if (config.getAggregatorType().equals("lock_striped")) {
// log.info("Launching lock-striped stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
// } else {
// log.error("Unknown stream type specified.");
// }
//
// stream.launch();
//
// // Optionally terminate program after x seconds for benchmarking purposes.
// if (config.getRunFor() > 0) {
// log.info("Scheduling termination of program in " + config.getRunFor() + " seconds...");
// stpe.schedule(new Runnable() {
// @Override
// public void run() {
// log.info("Terminating program. Final results: ");
// reporter.report();
// System.exit(0);
// }
// }, config.getRunFor(), TimeUnit.SECONDS);
// }
// }
// }
// Path: src/main/java/com/cscotta/deschutes/aggregation/Stream.java
import com.codahale.metrics.Meter;
import com.cscotta.deschutes.api.Event;
import com.cscotta.deschutes.api.StreamAggregator;
import com.cscotta.deschutes.example.app.App;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
package com.cscotta.deschutes.aggregation;
public class Stream<Input extends Event> {
private final Iterable<Input> source;
|
private final Meter meter = App.metrics.meter("event_rate");
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/aggregation/Stream.java
|
// Path: src/main/java/com/cscotta/deschutes/api/Event.java
// public interface Event {
//
// /**
// * Retrieve the timestamp of an event, represented as a long in
// * milliseconds since epoch.
// *
// * @return The timestamp of this event, represented as a long in
// * milliseconds since epoch.
// */
// public long getTimestamp();
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java
// public interface StreamAggregator<Input extends Event> {
//
// public void observe(Input event);
//
// public StreamAggregator<Input> addListener(OutputListener<Input> listener);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/App.java
// public class App extends Service<Config> {
//
// public static final MetricRegistry metrics = new MetricRegistry();
// private static final Logger log = LoggerFactory.getLogger(App.class);
// private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
// ConsoleReporter reporter;
//
// public static void main(String[] args) throws Exception {
// new App().run(args);
// }
//
// @Override
// public void initialize(Bootstrap<Config> bootstrap) {
// bootstrap.setName("app");
// }
//
// @Override
// public void run(Config config, Environment env) throws Exception {
// WebsocketApi websocketApi = new WebsocketApi();
// env.addServlet(websocketApi, "/websocket");
//
// // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream.
// final Iterable<RequestEvent> reader;
// if (config.getDataSource().equals("generated")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new ProtobufReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// } else if (config.getDataSource().equals("preloaded")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new CyclingProtobufPreReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize();
// } else {
// reader = new SyntheticProtobufs(1000, 1000);
// }
//
// // Report metrics to the console.
// reporter = ConsoleReporter.forRegistry(metrics).
// convertRatesTo(TimeUnit.SECONDS).
// convertDurationsTo(TimeUnit.MILLISECONDS).
// build();
// reporter.start(30, TimeUnit.SECONDS);
//
// // Initialize websocket output
// OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users);
//
// // Prepare our stream
// final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads());
//
// // Add aggregator(s) to stream - nonblocking or lock-striped for now.
// if (config.getAggregatorType().equals("nonblocking")) {
// log.info("Launching non-blocking stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
//
// } else if (config.getAggregatorType().equals("lock_striped")) {
// log.info("Launching lock-striped stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
// } else {
// log.error("Unknown stream type specified.");
// }
//
// stream.launch();
//
// // Optionally terminate program after x seconds for benchmarking purposes.
// if (config.getRunFor() > 0) {
// log.info("Scheduling termination of program in " + config.getRunFor() + " seconds...");
// stpe.schedule(new Runnable() {
// @Override
// public void run() {
// log.info("Terminating program. Final results: ");
// reporter.report();
// System.exit(0);
// }
// }, config.getRunFor(), TimeUnit.SECONDS);
// }
// }
// }
|
import com.codahale.metrics.Meter;
import com.cscotta.deschutes.api.Event;
import com.cscotta.deschutes.api.StreamAggregator;
import com.cscotta.deschutes.example.app.App;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
|
package com.cscotta.deschutes.aggregation;
public class Stream<Input extends Event> {
private final Iterable<Input> source;
private final Meter meter = App.metrics.meter("event_rate");
private final int processorThreads;
private static final Logger log = LoggerFactory.getLogger(Stream.class);
|
// Path: src/main/java/com/cscotta/deschutes/api/Event.java
// public interface Event {
//
// /**
// * Retrieve the timestamp of an event, represented as a long in
// * milliseconds since epoch.
// *
// * @return The timestamp of this event, represented as a long in
// * milliseconds since epoch.
// */
// public long getTimestamp();
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java
// public interface StreamAggregator<Input extends Event> {
//
// public void observe(Input event);
//
// public StreamAggregator<Input> addListener(OutputListener<Input> listener);
//
// }
//
// Path: src/main/java/com/cscotta/deschutes/example/app/App.java
// public class App extends Service<Config> {
//
// public static final MetricRegistry metrics = new MetricRegistry();
// private static final Logger log = LoggerFactory.getLogger(App.class);
// private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
// ConsoleReporter reporter;
//
// public static void main(String[] args) throws Exception {
// new App().run(args);
// }
//
// @Override
// public void initialize(Bootstrap<Config> bootstrap) {
// bootstrap.setName("app");
// }
//
// @Override
// public void run(Config config, Environment env) throws Exception {
// WebsocketApi websocketApi = new WebsocketApi();
// env.addServlet(websocketApi, "/websocket");
//
// // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream.
// final Iterable<RequestEvent> reader;
// if (config.getDataSource().equals("generated")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new ProtobufReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// } else if (config.getDataSource().equals("preloaded")) {
// BufferedInputStream input = new BufferedInputStream(
// new FileInputStream(new File(config.getDataFile())), 1024 * 1024);
// reader = new CyclingProtobufPreReader<Request, RequestEvent>(
// Request.PARSER, new RequestEventWrapper(), input);
// ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize();
// } else {
// reader = new SyntheticProtobufs(1000, 1000);
// }
//
// // Report metrics to the console.
// reporter = ConsoleReporter.forRegistry(metrics).
// convertRatesTo(TimeUnit.SECONDS).
// convertDurationsTo(TimeUnit.MILLISECONDS).
// build();
// reporter.start(30, TimeUnit.SECONDS);
//
// // Initialize websocket output
// OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users);
//
// // Prepare our stream
// final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads());
//
// // Add aggregator(s) to stream - nonblocking or lock-striped for now.
// if (config.getAggregatorType().equals("nonblocking")) {
// log.info("Launching non-blocking stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
//
// } else if (config.getAggregatorType().equals("lock_striped")) {
// log.info("Launching lock-striped stream.");
// stream.addQuery(
// new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser)
// .addListener(new WebsocketRollupListener(websocketApi.users)));
// } else {
// log.error("Unknown stream type specified.");
// }
//
// stream.launch();
//
// // Optionally terminate program after x seconds for benchmarking purposes.
// if (config.getRunFor() > 0) {
// log.info("Scheduling termination of program in " + config.getRunFor() + " seconds...");
// stpe.schedule(new Runnable() {
// @Override
// public void run() {
// log.info("Terminating program. Final results: ");
// reporter.report();
// System.exit(0);
// }
// }, config.getRunFor(), TimeUnit.SECONDS);
// }
// }
// }
// Path: src/main/java/com/cscotta/deschutes/aggregation/Stream.java
import com.codahale.metrics.Meter;
import com.cscotta.deschutes.api.Event;
import com.cscotta.deschutes.api.StreamAggregator;
import com.cscotta.deschutes.example.app.App;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
package com.cscotta.deschutes.aggregation;
public class Stream<Input extends Event> {
private final Iterable<Input> source;
private final Meter meter = App.metrics.meter("event_rate");
private final int processorThreads;
private static final Logger log = LoggerFactory.getLogger(Stream.class);
|
private final List<StreamAggregator<Input>> queries = Lists.newCopyOnWriteArrayList();
|
cscotta/deschutes
|
src/main/java/com/cscotta/deschutes/input/ProtobufReader.java
|
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java
// public interface EventWrapper<RawInput, WrappedInput> {
//
// public WrappedInput wrap(RawInput raw);
//
// }
|
import com.cscotta.deschutes.api.EventWrapper;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Parser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.Iterator;
|
package com.cscotta.deschutes.input;
public class ProtobufReader<ProtoType, Input> implements Iterable<Input> {
final Parser<ProtoType> parser;
final InputStream inputStream;
|
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java
// public interface EventWrapper<RawInput, WrappedInput> {
//
// public WrappedInput wrap(RawInput raw);
//
// }
// Path: src/main/java/com/cscotta/deschutes/input/ProtobufReader.java
import com.cscotta.deschutes.api.EventWrapper;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Parser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.Iterator;
package com.cscotta.deschutes.input;
public class ProtobufReader<ProtoType, Input> implements Iterable<Input> {
final Parser<ProtoType> parser;
final InputStream inputStream;
|
final EventWrapper<ProtoType, Input> eventWrapper;
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/adapter/WrapperCircularPagerAdapter.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CircularViewPager.java
// public class CircularViewPager extends ViewPager {
//
// private WrapperCircularPagerAdapter wrapperCircularPagerAdapter;
//
// public CircularViewPager(Context context) {
// super(context);
// }
//
// public CircularViewPager(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public void setAdapter(PagerAdapter adapter) {
// if (!(adapter instanceof WrapperCircularPagerAdapter)) {
// throw new IllegalArgumentException("The CircularViewPager accepts only instances of WrapperCircularPagerAdapter. Please, use this class to wrap your Adapter.");
// }
// super.setAdapter(adapter);
// this.wrapperCircularPagerAdapter = (WrapperCircularPagerAdapter) adapter;
// this.wrapperCircularPagerAdapter.setCircularViewPager(this);
// // offset first element so that we can scroll to the left
// setCurrentItem(wrapperCircularPagerAdapter.getOffsetAmount(), false);
// }
//
//
// public void setCurrentVirtualItem(int virtualItem) {
// setCurrentVirtualItem(virtualItem, true);
// }
//
// public void setCurrentVirtualItem(int virtualItem, boolean smoothScroll){
// setCurrentVirtualItem(virtualItem, getCurrentItem(), smoothScroll);
// }
//
// public void setCurrentVirtualItem(int virtualItem, int currentItem, boolean smoothScroll){
// int currentVirtualItem = getCurrentVirtualItem();
//
// int leftDistance;
// int rightDistance;
// int size = wrapperCircularPagerAdapter.getVirtualCount();
//
// if(virtualItem < currentVirtualItem){
// leftDistance = currentVirtualItem - virtualItem;
//
// int stepsToArriveToFirstElement = size - currentVirtualItem;
// rightDistance = stepsToArriveToFirstElement + virtualItem;
// }
// else {
// rightDistance = virtualItem - currentVirtualItem;
//
// int lastIndex = size - 1;
// int stepsToArriveToLastElement = currentVirtualItem + 1;
// leftDistance = stepsToArriveToLastElement + (lastIndex - virtualItem);
// }
//
// if(leftDistance < rightDistance){
// setCurrentItem(currentItem - leftDistance, smoothScroll);
// }
// else {
// setCurrentItem(currentItem + rightDistance, smoothScroll);
// }
// }
//
// /**
// *
// * @return Current item or -1 if the ViewPager is empty.
// */
// public int getCurrentVirtualItem() {
// final int virtualCount = wrapperCircularPagerAdapter.getVirtualCount();
// if(virtualCount > 0) {
// return getCurrentItem() % virtualCount;
// }
// return -1;
// }
//
// public PagerAdapter getVirtualAdapter() {
// return wrapperCircularPagerAdapter != null ? wrapperCircularPagerAdapter.getAdapter() : null;
// }
// }
|
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import br.com.cybereagle.androidwidgets.view.CircularViewPager;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.adapter;
public class WrapperCircularPagerAdapter extends PagerAdapter {
private static final int DEFAULT_QUANTITY_OF_CYCLES = 100;
private PagerAdapter adapter;
private int quantityOfCycles;
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CircularViewPager.java
// public class CircularViewPager extends ViewPager {
//
// private WrapperCircularPagerAdapter wrapperCircularPagerAdapter;
//
// public CircularViewPager(Context context) {
// super(context);
// }
//
// public CircularViewPager(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public void setAdapter(PagerAdapter adapter) {
// if (!(adapter instanceof WrapperCircularPagerAdapter)) {
// throw new IllegalArgumentException("The CircularViewPager accepts only instances of WrapperCircularPagerAdapter. Please, use this class to wrap your Adapter.");
// }
// super.setAdapter(adapter);
// this.wrapperCircularPagerAdapter = (WrapperCircularPagerAdapter) adapter;
// this.wrapperCircularPagerAdapter.setCircularViewPager(this);
// // offset first element so that we can scroll to the left
// setCurrentItem(wrapperCircularPagerAdapter.getOffsetAmount(), false);
// }
//
//
// public void setCurrentVirtualItem(int virtualItem) {
// setCurrentVirtualItem(virtualItem, true);
// }
//
// public void setCurrentVirtualItem(int virtualItem, boolean smoothScroll){
// setCurrentVirtualItem(virtualItem, getCurrentItem(), smoothScroll);
// }
//
// public void setCurrentVirtualItem(int virtualItem, int currentItem, boolean smoothScroll){
// int currentVirtualItem = getCurrentVirtualItem();
//
// int leftDistance;
// int rightDistance;
// int size = wrapperCircularPagerAdapter.getVirtualCount();
//
// if(virtualItem < currentVirtualItem){
// leftDistance = currentVirtualItem - virtualItem;
//
// int stepsToArriveToFirstElement = size - currentVirtualItem;
// rightDistance = stepsToArriveToFirstElement + virtualItem;
// }
// else {
// rightDistance = virtualItem - currentVirtualItem;
//
// int lastIndex = size - 1;
// int stepsToArriveToLastElement = currentVirtualItem + 1;
// leftDistance = stepsToArriveToLastElement + (lastIndex - virtualItem);
// }
//
// if(leftDistance < rightDistance){
// setCurrentItem(currentItem - leftDistance, smoothScroll);
// }
// else {
// setCurrentItem(currentItem + rightDistance, smoothScroll);
// }
// }
//
// /**
// *
// * @return Current item or -1 if the ViewPager is empty.
// */
// public int getCurrentVirtualItem() {
// final int virtualCount = wrapperCircularPagerAdapter.getVirtualCount();
// if(virtualCount > 0) {
// return getCurrentItem() % virtualCount;
// }
// return -1;
// }
//
// public PagerAdapter getVirtualAdapter() {
// return wrapperCircularPagerAdapter != null ? wrapperCircularPagerAdapter.getAdapter() : null;
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/adapter/WrapperCircularPagerAdapter.java
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import br.com.cybereagle.androidwidgets.view.CircularViewPager;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.adapter;
public class WrapperCircularPagerAdapter extends PagerAdapter {
private static final int DEFAULT_QUANTITY_OF_CYCLES = 100;
private PagerAdapter adapter;
private int quantityOfCycles;
|
private CircularViewPager circularViewPager;
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareGridLayout.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.GridLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareGridLayout extends GridLayout {
public SquareGridLayout(Context context) {
super(context);
}
public SquareGridLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareGridLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareGridLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.GridLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareGridLayout extends GridLayout {
public SquareGridLayout(Context context) {
super(context);
}
public SquareGridLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareGridLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareFrameLayout.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
super(context);
}
public SquareFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareFrameLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
super(context);
}
public SquareFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/helper/UninterceptableViewPagerHelper.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/interfaces/UninterceptableViewPager.java
// public interface UninterceptableViewPager {
// boolean callRealOnInterceptTouchEvent(MotionEvent motionEvent);
// }
|
import android.support.v4.view.ViewPager;
import android.view.MotionEvent;
import br.com.cybereagle.androidwidgets.interfaces.UninterceptableViewPager;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.helper;
public class UninterceptableViewPagerHelper {
private ViewPager viewPager;
public UninterceptableViewPagerHelper(ViewPager viewPager) {
this.viewPager = viewPager;
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/interfaces/UninterceptableViewPager.java
// public interface UninterceptableViewPager {
// boolean callRealOnInterceptTouchEvent(MotionEvent motionEvent);
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/helper/UninterceptableViewPagerHelper.java
import android.support.v4.view.ViewPager;
import android.view.MotionEvent;
import br.com.cybereagle.androidwidgets.interfaces.UninterceptableViewPager;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.helper;
public class UninterceptableViewPagerHelper {
private ViewPager viewPager;
public UninterceptableViewPagerHelper(ViewPager viewPager) {
this.viewPager = viewPager;
|
if(!(viewPager instanceof UninterceptableViewPager)){
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareImageView.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareImageView.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareLinearLayout.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareLinearLayout extends LinearLayout {
public SquareLinearLayout(Context context) {
super(context);
}
public SquareLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareLinearLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareLinearLayout extends LinearLayout {
public SquareLinearLayout(Context context) {
super(context);
}
public SquareLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/PagerContainer.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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.
*
* Copyright (c) 2012 Wireless Designs, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package br.com.cybereagle.androidwidgets.view;
/**
* PagerContainer: A layout that displays a ViewPager with its children that are outside
* the typical pager bounds.
*
* To use this, wrap your ViewPager with it, set the ViewPager's width to be equal the width
* of its child, set the ViewPager's gravity to center and make this PagerContainer larger
* than the ViewPager. You should also set the offscreenPageLimit of the ViewPager in a way
* that it prepares more children that is really show, so that it loads the children before
* you reach the last children, that gives a poor effect.
*
*/
public class PagerContainer extends FrameLayout implements ViewPager.OnPageChangeListener {
protected ViewPager pager;
boolean needsRedraw = false;
protected Point center = new Point();
protected Point initialTouch = new Point();
public PagerContainer(Context context) {
super(context);
init();
}
public PagerContainer(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PagerContainer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
//Disable clipping of children so non-selected pages are visible
setClipChildren(false);
//Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
//You need to set this value here if using hardware acceleration in an
// application targeted at these releases.
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/PagerContainer.java
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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.
*
* Copyright (c) 2012 Wireless Designs, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package br.com.cybereagle.androidwidgets.view;
/**
* PagerContainer: A layout that displays a ViewPager with its children that are outside
* the typical pager bounds.
*
* To use this, wrap your ViewPager with it, set the ViewPager's width to be equal the width
* of its child, set the ViewPager's gravity to center and make this PagerContainer larger
* than the ViewPager. You should also set the offscreenPageLimit of the ViewPager in a way
* that it prepares more children that is really show, so that it loads the children before
* you reach the last children, that gives a poor effect.
*
*/
public class PagerContainer extends FrameLayout implements ViewPager.OnPageChangeListener {
protected ViewPager pager;
boolean needsRedraw = false;
protected Point center = new Point();
protected Point initialTouch = new Point();
public PagerContainer(Context context) {
super(context);
init();
}
public PagerContainer(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PagerContainer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
//Disable clipping of children so non-selected pages are visible
setClipChildren(false);
//Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
//You need to set this value here if using hardware acceleration in an
// application targeted at these releases.
|
ViewUtils.enableSoftwareLayer(this);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareRelativeLayout.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareRelativeLayout extends RelativeLayout {
public SquareRelativeLayout(Context context) {
super(context);
}
public SquareRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareRelativeLayout.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class SquareRelativeLayout extends RelativeLayout {
public SquareRelativeLayout(Context context) {
super(context);
}
public SquareRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
|
CyberEagle/AndroidWidgets
|
library/src/main/java/br/com/cybereagle/androidwidgets/view/CoverFlowPagerContainer.java
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
import java.util.ArrayList;
import java.util.List;
|
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class CoverFlowPagerContainer extends PagerContainer{
private static final int MAX_ROTATION_ANGLE = 60;
public CoverFlowPagerContainer(Context context) {
super(context);
}
public CoverFlowPagerContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CoverFlowPagerContainer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
private List<View> getViewPagerChildren(){
int childCount = pager.getChildCount();
List<View> children = new ArrayList<View>(childCount);
for(int i=0; i<childCount; i++){
children.add(pager.getChildAt(i));
}
return children;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
updateCoverFlow();
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
public void updateCoverFlow() {
int childCount = pager.getChildCount();
int[] xy = new int[2];
for(int i=0; i<childCount; i++){
View child = pager.getChildAt(i);
|
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java
// public class ViewUtils {
//
// public static final boolean IS_API_11_OR_ABOVE;
//
// static {
// IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11;
// }
//
// public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
// int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
// int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
// int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
// int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
//
// int size;
// if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){
// size = widthSize;
// }
// else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){
// size = heightSize;
// }
// else{
// size = widthSize < heightSize ? widthSize : heightSize;
// }
//
// return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableHardwareLayer(View view) {
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_HARDWARE);
// }
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static void enableSoftwareLayer(View view){
// if(!ViewUtils.IS_API_11_OR_ABOVE){
// return;
// }
//
// setLayer(view, View.LAYER_TYPE_SOFTWARE);
// }
//
// private static void setLayer(View view, int layer) {
// if(view.getLayerType() != layer){
// view.setLayerType(layer, null);
// }
// }
// }
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CoverFlowPagerContainer.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import br.com.cybereagle.androidwidgets.util.ViewUtils;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2013 Cyber Eagle
*
* 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 br.com.cybereagle.androidwidgets.view;
public class CoverFlowPagerContainer extends PagerContainer{
private static final int MAX_ROTATION_ANGLE = 60;
public CoverFlowPagerContainer(Context context) {
super(context);
}
public CoverFlowPagerContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CoverFlowPagerContainer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
private List<View> getViewPagerChildren(){
int childCount = pager.getChildCount();
List<View> children = new ArrayList<View>(childCount);
for(int i=0; i<childCount; i++){
children.add(pager.getChildAt(i));
}
return children;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
updateCoverFlow();
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
public void updateCoverFlow() {
int childCount = pager.getChildCount();
int[] xy = new int[2];
for(int i=0; i<childCount; i++){
View child = pager.getChildAt(i);
|
ViewUtils.enableHardwareLayer(child);
|
snowplow/snowplow-java-tracker
|
src/main/java/com/snowplowanalytics/snowplow/tracker/Subject.java
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Parameter.java
// public class Parameter {
// // General
// public static final String SCHEMA = "schema";
// public static final String DATA = "data";
// public static final String EVENT = "e";
// public static final String EID = "eid";
//
// public static final String TRUE_TIMESTAMP = "ttm";
//
// public static final String DEVICE_CREATED_TIMESTAMP = "dtm";
// public static final String DEVICE_SENT_TIMESTAMP = "stm";
//
// /** deprecated Indicate the specific timestamp to use. This is kept for compatibility with older versions. */
// @Deprecated
// public static final String TIMESTAMP = DEVICE_CREATED_TIMESTAMP;
// public static final String TRACKER_VERSION = "tv";
// public static final String APP_ID = "aid";
// public static final String NAMESPACE = "tna";
//
// public static final String UID = "uid";
// public static final String CONTEXT = "co";
// public static final String CONTEXT_ENCODED = "cx";
// public static final String UNSTRUCTURED = "ue_pr";
// public static final String UNSTRUCTURED_ENCODED = "ue_px";
//
// // Subject class
// public static final String PLATFORM = "p";
// public static final String RESOLUTION = "res";
// public static final String VIEWPORT = "vp";
// public static final String COLOR_DEPTH = "cd";
// public static final String TIMEZONE = "tz";
// public static final String LANGUAGE = "lang";
// public static final String IP_ADDRESS = "ip";
// public static final String USERAGENT = "ua";
// public static final String DOMAIN_UID = "duid";
// public static final String NETWORK_UID = "tnuid";
// public static final String SESSION_UID = "sid";
//
// // Page View
// public static final String PAGE_URL = "url";
// public static final String PAGE_TITLE = "page";
// public static final String PAGE_REFR = "refr";
//
// // Structured Event
// public static final String SE_CATEGORY = "se_ca";
// public static final String SE_ACTION = "se_ac";
// public static final String SE_LABEL = "se_la";
// public static final String SE_PROPERTY = "se_pr";
// public static final String SE_VALUE = "se_va";
//
// // Ecomm Transaction
// public static final String TR_ID = "tr_id";
// public static final String TR_TOTAL = "tr_tt";
// public static final String TR_AFFILIATION = "tr_af";
// public static final String TR_TAX = "tr_tx";
// public static final String TR_SHIPPING = "tr_sh";
// public static final String TR_CITY = "tr_ci";
// public static final String TR_STATE = "tr_st";
// public static final String TR_COUNTRY = "tr_co";
// public static final String TR_CURRENCY = "tr_cu";
//
// // Transaction Item
// public static final String TI_ITEM_ID = "ti_id";
// public static final String TI_ITEM_SKU = "ti_sk";
// public static final String TI_ITEM_NAME = "ti_nm";
// public static final String TI_ITEM_CATEGORY = "ti_ca";
// public static final String TI_ITEM_PRICE = "ti_pr";
// public static final String TI_ITEM_QUANTITY = "ti_qu";
// public static final String TI_ITEM_CURRENCY = "ti_cu";
//
// // Screen View
// public static final String SV_ID = "id";
// public static final String SV_NAME = "name";
//
// // User Timing
// public static final String UT_CATEGORY = "category";
// public static final String UT_VARIABLE = "variable";
// public static final String UT_TIMING = "timing";
// public static final String UT_LABEL = "label";
// }
|
import java.util.Map;
import com.snowplowanalytics.snowplow.tracker.constants.Parameter;
import java.util.HashMap;
|
this.domainUserId = domainUserId;
return this;
}
/**
* @param domainSessionId a domainSessionId string
* @return itself
*/
public SubjectBuilder domainSessionId(String domainSessionId) {
this.domainSessionId = domainSessionId;
return this;
}
/**
* Creates a new Subject
*
* @return a new Subject object
*/
public Subject build() {
return new Subject(this);
}
}
/**
* Sets the User ID
*
* @param userId a user id string
*/
public void setUserId(String userId) {
if (userId != null) {
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Parameter.java
// public class Parameter {
// // General
// public static final String SCHEMA = "schema";
// public static final String DATA = "data";
// public static final String EVENT = "e";
// public static final String EID = "eid";
//
// public static final String TRUE_TIMESTAMP = "ttm";
//
// public static final String DEVICE_CREATED_TIMESTAMP = "dtm";
// public static final String DEVICE_SENT_TIMESTAMP = "stm";
//
// /** deprecated Indicate the specific timestamp to use. This is kept for compatibility with older versions. */
// @Deprecated
// public static final String TIMESTAMP = DEVICE_CREATED_TIMESTAMP;
// public static final String TRACKER_VERSION = "tv";
// public static final String APP_ID = "aid";
// public static final String NAMESPACE = "tna";
//
// public static final String UID = "uid";
// public static final String CONTEXT = "co";
// public static final String CONTEXT_ENCODED = "cx";
// public static final String UNSTRUCTURED = "ue_pr";
// public static final String UNSTRUCTURED_ENCODED = "ue_px";
//
// // Subject class
// public static final String PLATFORM = "p";
// public static final String RESOLUTION = "res";
// public static final String VIEWPORT = "vp";
// public static final String COLOR_DEPTH = "cd";
// public static final String TIMEZONE = "tz";
// public static final String LANGUAGE = "lang";
// public static final String IP_ADDRESS = "ip";
// public static final String USERAGENT = "ua";
// public static final String DOMAIN_UID = "duid";
// public static final String NETWORK_UID = "tnuid";
// public static final String SESSION_UID = "sid";
//
// // Page View
// public static final String PAGE_URL = "url";
// public static final String PAGE_TITLE = "page";
// public static final String PAGE_REFR = "refr";
//
// // Structured Event
// public static final String SE_CATEGORY = "se_ca";
// public static final String SE_ACTION = "se_ac";
// public static final String SE_LABEL = "se_la";
// public static final String SE_PROPERTY = "se_pr";
// public static final String SE_VALUE = "se_va";
//
// // Ecomm Transaction
// public static final String TR_ID = "tr_id";
// public static final String TR_TOTAL = "tr_tt";
// public static final String TR_AFFILIATION = "tr_af";
// public static final String TR_TAX = "tr_tx";
// public static final String TR_SHIPPING = "tr_sh";
// public static final String TR_CITY = "tr_ci";
// public static final String TR_STATE = "tr_st";
// public static final String TR_COUNTRY = "tr_co";
// public static final String TR_CURRENCY = "tr_cu";
//
// // Transaction Item
// public static final String TI_ITEM_ID = "ti_id";
// public static final String TI_ITEM_SKU = "ti_sk";
// public static final String TI_ITEM_NAME = "ti_nm";
// public static final String TI_ITEM_CATEGORY = "ti_ca";
// public static final String TI_ITEM_PRICE = "ti_pr";
// public static final String TI_ITEM_QUANTITY = "ti_qu";
// public static final String TI_ITEM_CURRENCY = "ti_cu";
//
// // Screen View
// public static final String SV_ID = "id";
// public static final String SV_NAME = "name";
//
// // User Timing
// public static final String UT_CATEGORY = "category";
// public static final String UT_VARIABLE = "variable";
// public static final String UT_TIMING = "timing";
// public static final String UT_LABEL = "label";
// }
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/Subject.java
import java.util.Map;
import com.snowplowanalytics.snowplow.tracker.constants.Parameter;
import java.util.HashMap;
this.domainUserId = domainUserId;
return this;
}
/**
* @param domainSessionId a domainSessionId string
* @return itself
*/
public SubjectBuilder domainSessionId(String domainSessionId) {
this.domainSessionId = domainSessionId;
return this;
}
/**
* Creates a new Subject
*
* @return a new Subject object
*/
public Subject build() {
return new Subject(this);
}
}
/**
* Sets the User ID
*
* @param userId a user id string
*/
public void setUserId(String userId) {
if (userId != null) {
|
this.standardPairs.put(Parameter.UID, userId);
|
snowplow/snowplow-java-tracker
|
src/main/java/com/snowplowanalytics/snowplow/tracker/http/ApacheHttpClientAdapter.java
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
// public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
// public static final String PROTOCOL_VERSION = "tp2";
//
// public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
// public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
// public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
// public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
// public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
//
// public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
//
// public static final String EVENT_PAGE_VIEW = "pv";
// public static final String EVENT_STRUCTURED = "se";
// public static final String EVENT_UNSTRUCTURED = "ue";
// public static final String EVENT_ECOMM = "tr";
// public static final String EVENT_ECOMM_ITEM = "ti";
// }
|
import com.google.common.base.Preconditions;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.snowplowanalytics.snowplow.tracker.constants.Constants;
|
/**
* Attempts to send a group of payloads with a
* GET request to the configured endpoint.
*
* @param url the URL send
* @return the HttpResponse for the Request
*/
public int doGet(String url) {
try {
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
httpGet.releaseConnection();
return httpResponse.getStatusLine().getStatusCode();
} catch (Exception e) {
LOGGER.error("ApacheHttpClient GET Request failed: {}", e.getMessage());
return -1;
}
}
/**
* Attempts to send a group of payloads with a
* POST request to the configured endpoint.
*
* @param url the URL to send to
* @param payload the payload to send
* @return the HttpResponse for the Request
*/
public int doPost(String url, String payload) {
try {
HttpPost httpPost = new HttpPost(url);
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
// public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
// public static final String PROTOCOL_VERSION = "tp2";
//
// public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
// public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
// public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
// public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
// public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
//
// public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
//
// public static final String EVENT_PAGE_VIEW = "pv";
// public static final String EVENT_STRUCTURED = "se";
// public static final String EVENT_UNSTRUCTURED = "ue";
// public static final String EVENT_ECOMM = "tr";
// public static final String EVENT_ECOMM_ITEM = "ti";
// }
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/http/ApacheHttpClientAdapter.java
import com.google.common.base.Preconditions;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.snowplowanalytics.snowplow.tracker.constants.Constants;
/**
* Attempts to send a group of payloads with a
* GET request to the configured endpoint.
*
* @param url the URL send
* @return the HttpResponse for the Request
*/
public int doGet(String url) {
try {
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
httpGet.releaseConnection();
return httpResponse.getStatusLine().getStatusCode();
} catch (Exception e) {
LOGGER.error("ApacheHttpClient GET Request failed: {}", e.getMessage());
return -1;
}
}
/**
* Attempts to send a group of payloads with a
* POST request to the configured endpoint.
*
* @param url the URL to send to
* @param payload the payload to send
* @return the HttpResponse for the Request
*/
public int doPost(String url, String payload) {
try {
HttpPost httpPost = new HttpPost(url);
|
httpPost.addHeader("Content-Type", Constants.POST_CONTENT_TYPE);
|
snowplow/snowplow-java-tracker
|
src/main/java/com/snowplowanalytics/snowplow/tracker/http/OkHttpClientAdapter.java
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
// public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
// public static final String PROTOCOL_VERSION = "tp2";
//
// public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
// public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
// public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
// public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
// public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
//
// public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
//
// public static final String EVENT_PAGE_VIEW = "pv";
// public static final String EVENT_STRUCTURED = "se";
// public static final String EVENT_UNSTRUCTURED = "ue";
// public static final String EVENT_ECOMM = "tr";
// public static final String EVENT_ECOMM_ITEM = "ti";
// }
|
import com.snowplowanalytics.snowplow.tracker.constants.Constants;
import java.io.IOException;
import com.google.common.base.Preconditions;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.MediaType;
import okhttp3.Response;
import okhttp3.RequestBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.http;
// Java
// Google
// SquareUp
// Slf4j
// This library
/**
* A HttpClient built using OkHttp to send events via
* GET or POST requests.
*/
public class OkHttpClientAdapter extends AbstractHttpClientAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(OkHttpClientAdapter.class);
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Constants.java
// public class Constants {
// public static final String PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow";
// public static final String PROTOCOL_VERSION = "tp2";
//
// public static final String SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4";
// public static final String SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1";
// public static final String SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0";
// public static final String SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0";
// public static final String SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0";
//
// public static final String POST_CONTENT_TYPE = "application/json; charset=utf-8";
//
// public static final String EVENT_PAGE_VIEW = "pv";
// public static final String EVENT_STRUCTURED = "se";
// public static final String EVENT_UNSTRUCTURED = "ue";
// public static final String EVENT_ECOMM = "tr";
// public static final String EVENT_ECOMM_ITEM = "ti";
// }
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/http/OkHttpClientAdapter.java
import com.snowplowanalytics.snowplow.tracker.constants.Constants;
import java.io.IOException;
import com.google.common.base.Preconditions;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.MediaType;
import okhttp3.Response;
import okhttp3.RequestBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.http;
// Java
// Google
// SquareUp
// Slf4j
// This library
/**
* A HttpClient built using OkHttp to send events via
* GET or POST requests.
*/
public class OkHttpClientAdapter extends AbstractHttpClientAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(OkHttpClientAdapter.class);
|
private final MediaType JSON = MediaType.get(Constants.POST_CONTENT_TYPE);
|
snowplow/snowplow-java-tracker
|
src/main/java/com/snowplowanalytics/snowplow/tracker/payload/TrackerParameters.java
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/DevicePlatform.java
// public enum DevicePlatform {
// Web {
// public String toString() {
// return "web";
// }
// },
// Mobile {
// public String toString() {
// return "mob";
// }
// },
// Desktop {
// public String toString() {
// return "pc";
// }
// },
// ServerSideApp {
// public String toString() {
// return "srv";
// }
// },
// General {
// public String toString() {
// return "app";
// }
// },
// ConnectedTV {
// public String toString() {
// return "tv";
// }
// },
// GameConsole {
// public String toString() {
// return "cnsl";
// }
// },
// InternetOfThings {
// public String toString() {
// return "iot";
// }
// }
// }
|
import com.snowplowanalytics.snowplow.tracker.DevicePlatform;
|
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.payload;
/**
* A TrackerEvent which allows the TrackerPayload to be filled later. The
* payload will be filled by the Emitter in the Emitter thread, using the
* getTrackerPayload() method.
*/
public class TrackerParameters {
private final String trackerVersion;
private final String appId;
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/DevicePlatform.java
// public enum DevicePlatform {
// Web {
// public String toString() {
// return "web";
// }
// },
// Mobile {
// public String toString() {
// return "mob";
// }
// },
// Desktop {
// public String toString() {
// return "pc";
// }
// },
// ServerSideApp {
// public String toString() {
// return "srv";
// }
// },
// General {
// public String toString() {
// return "app";
// }
// },
// ConnectedTV {
// public String toString() {
// return "tv";
// }
// },
// GameConsole {
// public String toString() {
// return "cnsl";
// }
// },
// InternetOfThings {
// public String toString() {
// return "iot";
// }
// }
// }
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/payload/TrackerParameters.java
import com.snowplowanalytics.snowplow.tracker.DevicePlatform;
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.payload;
/**
* A TrackerEvent which allows the TrackerPayload to be filled later. The
* payload will be filled by the Emitter in the Emitter thread, using the
* getTrackerPayload() method.
*/
public class TrackerParameters {
private final String trackerVersion;
private final String appId;
|
private final DevicePlatform platform;
|
snowplow/snowplow-java-tracker
|
src/main/java/com/snowplowanalytics/snowplow/tracker/emitter/RequestCallback.java
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/events/Event.java
// public interface Event {
//
// /**
// * @return the events custom context
// */
// List<SelfDescribingJson> getContext();
//
// /**
// * @return the event's timestamp
// * Use {@link #getTrueTimestamp()} or {@link #getDeviceCreatedTimestamp()}
// */
// @Deprecated
// long getTimestamp();
//
// /**
// * @return the event's true timestamp
// */
// Long getTrueTimestamp();
//
// /**
// * @return the event's device created timestamp
// */
// long getDeviceCreatedTimestamp();
//
// /**
// * @return the event id
// */
// String getEventId();
//
// /**
// * @return the event subject
// */
// Subject getSubject();
//
// /**
// * @return the event payload
// */
// Payload getPayload();
// }
|
import com.snowplowanalytics.snowplow.tracker.events.Event;
import java.util.List;
|
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.emitter;
/**
* Provides a callback interface for reporting counts of successfully sent
* events and returning any failed events to be handled by the developer.
*/
public interface RequestCallback {
/**
* If all events are sent successfully then the count
* of sent events are returned.
*
* @param successCount the successful count
*/
void onSuccess(int successCount);
/**
* If all/some events failed then the count of successful
* events is returned along with all the failed Events.
*
* @param successCount the successful count
* @param failedEvents the list of failed events
*/
|
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/events/Event.java
// public interface Event {
//
// /**
// * @return the events custom context
// */
// List<SelfDescribingJson> getContext();
//
// /**
// * @return the event's timestamp
// * Use {@link #getTrueTimestamp()} or {@link #getDeviceCreatedTimestamp()}
// */
// @Deprecated
// long getTimestamp();
//
// /**
// * @return the event's true timestamp
// */
// Long getTrueTimestamp();
//
// /**
// * @return the event's device created timestamp
// */
// long getDeviceCreatedTimestamp();
//
// /**
// * @return the event id
// */
// String getEventId();
//
// /**
// * @return the event subject
// */
// Subject getSubject();
//
// /**
// * @return the event payload
// */
// Payload getPayload();
// }
// Path: src/main/java/com/snowplowanalytics/snowplow/tracker/emitter/RequestCallback.java
import com.snowplowanalytics.snowplow.tracker.events.Event;
import java.util.List;
/*
* Copyright (c) 2014-2021 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.tracker.emitter;
/**
* Provides a callback interface for reporting counts of successfully sent
* events and returning any failed events to be handled by the developer.
*/
public interface RequestCallback {
/**
* If all events are sent successfully then the count
* of sent events are returned.
*
* @param successCount the successful count
*/
void onSuccess(int successCount);
/**
* If all/some events failed then the count of successful
* events is returned along with all the failed Events.
*
* @param successCount the successful count
* @param failedEvents the list of failed events
*/
|
void onFailure(int successCount, List<Event> failedEvents);
|
chms/jdotxt
|
src/com/todotxt/todotxttouch/task/JdotxtTaskBagImpl.java
|
// Path: src/com/todotxt/todotxttouch/task/sorter/PredefinedSorters.java
// public class PredefinedSorters {
// public static final Sorter<Task> DEFAULT = PRIORITY.ascending().then(ID.ascending());
// public static final Sorter<Task> TEXT_ASC = TEXT.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_ASC = DATE.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_DESC = DATE.descending().then(ID.ascending());
// }
|
import com.todotxt.todotxttouch.task.sorter.PredefinedSorters;
import java.util.*;
|
localRepository.purge();
lastReload = null;
lastWrite = null;
lastChange = null;
}
@Override
public int size() {
return tasks.size();
}
@Override
public List<Task> getTasks() {
return getTasks(null, null);
}
@Override
public List<Task> getTasks(Filter<Task> filter, Comparator<Task> comparator) {
ArrayList<Task> localTasks = new ArrayList<Task>();
if (filter != null) {
for (Task t : tasks) {
if (filter.apply(t)) {
localTasks.add(t);
}
}
} else {
localTasks.addAll(tasks);
}
if (comparator == null) {
|
// Path: src/com/todotxt/todotxttouch/task/sorter/PredefinedSorters.java
// public class PredefinedSorters {
// public static final Sorter<Task> DEFAULT = PRIORITY.ascending().then(ID.ascending());
// public static final Sorter<Task> TEXT_ASC = TEXT.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_ASC = DATE.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_DESC = DATE.descending().then(ID.ascending());
// }
// Path: src/com/todotxt/todotxttouch/task/JdotxtTaskBagImpl.java
import com.todotxt.todotxttouch.task.sorter.PredefinedSorters;
import java.util.*;
localRepository.purge();
lastReload = null;
lastWrite = null;
lastChange = null;
}
@Override
public int size() {
return tasks.size();
}
@Override
public List<Task> getTasks() {
return getTasks(null, null);
}
@Override
public List<Task> getTasks(Filter<Task> filter, Comparator<Task> comparator) {
ArrayList<Task> localTasks = new ArrayList<Task>();
if (filter != null) {
for (Task t : tasks) {
if (filter.apply(t)) {
localTasks.add(t);
}
}
} else {
localTasks.addAll(tasks);
}
if (comparator == null) {
|
comparator = PredefinedSorters.DEFAULT;
|
chms/jdotxt
|
src/com/todotxt/todotxttouch/task/TaskBagImpl.java
|
// Path: src/com/todotxt/todotxttouch/task/sorter/PredefinedSorters.java
// public class PredefinedSorters {
// public static final Sorter<Task> DEFAULT = PRIORITY.ascending().then(ID.ascending());
// public static final Sorter<Task> TEXT_ASC = TEXT.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_ASC = DATE.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_DESC = DATE.descending().then(ID.ascending());
// }
|
import com.todotxt.todotxttouch.task.sorter.PredefinedSorters;
import java.util.*;
|
localRepository.purge();
lastReload = null;
lastWrite = null;
lastChange = null;
}
@Override
public int size() {
return tasks.size();
}
@Override
public List<Task> getTasks() {
return getTasks(null, null);
}
@Override
public List<Task> getTasks(Filter<Task> filter, Comparator<Task> comparator) {
ArrayList<Task> localTasks = new ArrayList<Task>();
if (filter != null) {
for (Task t : tasks) {
if (filter.apply(t)) {
localTasks.add(t);
}
}
} else {
localTasks.addAll(tasks);
}
if (comparator == null) {
|
// Path: src/com/todotxt/todotxttouch/task/sorter/PredefinedSorters.java
// public class PredefinedSorters {
// public static final Sorter<Task> DEFAULT = PRIORITY.ascending().then(ID.ascending());
// public static final Sorter<Task> TEXT_ASC = TEXT.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_ASC = DATE.ascending().then(ID.ascending());
// public static final Sorter<Task> DATE_DESC = DATE.descending().then(ID.ascending());
// }
// Path: src/com/todotxt/todotxttouch/task/TaskBagImpl.java
import com.todotxt.todotxttouch.task.sorter.PredefinedSorters;
import java.util.*;
localRepository.purge();
lastReload = null;
lastWrite = null;
lastChange = null;
}
@Override
public int size() {
return tasks.size();
}
@Override
public List<Task> getTasks() {
return getTasks(null, null);
}
@Override
public List<Task> getTasks(Filter<Task> filter, Comparator<Task> comparator) {
ArrayList<Task> localTasks = new ArrayList<Task>();
if (filter != null) {
for (Task t : tasks) {
if (filter.apply(t)) {
localTasks.add(t);
}
}
} else {
localTasks.addAll(tasks);
}
if (comparator == null) {
|
comparator = PredefinedSorters.DEFAULT;
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/client/Bot.java
|
// Path: src/main/java/de/vivistra/telegrambot/settings/BotSettings.java
// public class BotSettings {
//
// private static String apiUrl = "https://api.telegram.org/bot";
// private static String apiToken = "";
//
// public static String getApiUrlWithToken() {
// return apiUrl + apiToken + "/";
// }
//
// public static boolean isEmptyApiToken() {
// return apiToken.isEmpty();
// }
//
// public static void setApiUrl(String url) {
// apiUrl = url;
// }
//
// public static void setApiToken(String token) {
// apiToken = token;
// }
//
// }
|
import java.io.*;
import java.net.SocketException;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import de.vivistra.telegrambot.settings.BotSettings;
|
package de.vivistra.telegrambot.client;
/**
* This class connects to the Telegram API and posts querys.
*/
public class Bot {
private static final Logger LOG = LogManager.getLogger();
|
// Path: src/main/java/de/vivistra/telegrambot/settings/BotSettings.java
// public class BotSettings {
//
// private static String apiUrl = "https://api.telegram.org/bot";
// private static String apiToken = "";
//
// public static String getApiUrlWithToken() {
// return apiUrl + apiToken + "/";
// }
//
// public static boolean isEmptyApiToken() {
// return apiToken.isEmpty();
// }
//
// public static void setApiUrl(String url) {
// apiUrl = url;
// }
//
// public static void setApiToken(String token) {
// apiToken = token;
// }
//
// }
// Path: src/main/java/de/vivistra/telegrambot/client/Bot.java
import java.io.*;
import java.net.SocketException;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import de.vivistra.telegrambot.settings.BotSettings;
package de.vivistra.telegrambot.client;
/**
* This class connects to the Telegram API and posts querys.
*/
public class Bot {
private static final Logger LOG = LogManager.getLogger();
|
private static String API_URL_WITH_TOKEN = BotSettings.getApiUrlWithToken();
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/StickerMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/Sticker.java
// public class Sticker {
// // Unique identifier for this file
// String fileId;
// // Sticker width
// Integer width;
// // Sticker height
// Integer height;
// // Optional. Sticker thumbnail in .webp or .jpg format
// PhotoSize thumb;
// // Optional. File size
// Integer fileSize;
//
// /**
// * Creates a PhotoSize object
// *
// * @param fileId
// * @param width
// * @param height
// * @param fileSize
// */
// public Sticker(String fileId, Integer width, Integer height, PhotoSize thumb, Integer fileSize) {
// super();
// this.fileId = fileId;
// this.width = width;
// this.height = height;
// this.thumb = thumb;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a user or bot object from a JSON String
// *
// * @param userObject
// * @return User
// */
// public static Sticker fromJSON(JSONObject userObject) {
//
// String fileId = userObject.getString("file_id");
// Integer width = userObject.getInt("width");
// Integer height = userObject.getInt("height");
//
// // Optional
// PhotoSize thumb = PhotoSize.fromJSON(userObject.optJSONObject("thumb"));
// Integer fileSize = userObject.optInt("file_size");
//
// return new Sticker(fileId, width, height, thumb, fileSize);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Sticker sticker = (Sticker) o;
//
// return fileId.equals(sticker.fileId);
//
// }
//
// @Override
// public int hashCode() {
// return fileId.hashCode();
// }
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.Sticker;
|
package de.vivistra.telegrambot.model.message;
public class StickerMessage extends Message {
private static final String COMMAND = "sendSticker";
public static final String JSON_KEY = "sticker";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public StickerMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/Sticker.java
// public class Sticker {
// // Unique identifier for this file
// String fileId;
// // Sticker width
// Integer width;
// // Sticker height
// Integer height;
// // Optional. Sticker thumbnail in .webp or .jpg format
// PhotoSize thumb;
// // Optional. File size
// Integer fileSize;
//
// /**
// * Creates a PhotoSize object
// *
// * @param fileId
// * @param width
// * @param height
// * @param fileSize
// */
// public Sticker(String fileId, Integer width, Integer height, PhotoSize thumb, Integer fileSize) {
// super();
// this.fileId = fileId;
// this.width = width;
// this.height = height;
// this.thumb = thumb;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a user or bot object from a JSON String
// *
// * @param userObject
// * @return User
// */
// public static Sticker fromJSON(JSONObject userObject) {
//
// String fileId = userObject.getString("file_id");
// Integer width = userObject.getInt("width");
// Integer height = userObject.getInt("height");
//
// // Optional
// PhotoSize thumb = PhotoSize.fromJSON(userObject.optJSONObject("thumb"));
// Integer fileSize = userObject.optInt("file_size");
//
// return new Sticker(fileId, width, height, thumb, fileSize);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Sticker sticker = (Sticker) o;
//
// return fileId.equals(sticker.fileId);
//
// }
//
// @Override
// public int hashCode() {
// return fileId.hashCode();
// }
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/StickerMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.Sticker;
package de.vivistra.telegrambot.model.message;
public class StickerMessage extends Message {
private static final String COMMAND = "sendSticker";
public static final String JSON_KEY = "sticker";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public StickerMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
public StickerMessage(Long recipient, Sticker message) {
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/GroupChat.java
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
|
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
|
package de.vivistra.telegrambot.model;
/**
* This class represents a GroupChat
*/
public class GroupChat {
// Unique identifier for this group chat
private Long id;
// Group name
private String title;
/**
* Creates a GroupChat object
*
* @param id
* @param title
*/
public GroupChat(long id, String title) {
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
// Path: src/main/java/de/vivistra/telegrambot/model/GroupChat.java
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
package de.vivistra.telegrambot.model;
/**
* This class represents a GroupChat
*/
public class GroupChat {
// Unique identifier for this group chat
private Long id;
// Group name
private String title;
/**
* Creates a GroupChat object
*
* @param id
* @param title
*/
public GroupChat(long id, String title) {
|
Assert.notEmpty(title);
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/DocumentMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/Document.java
// public class Document {
// // Unique file identifier
// private String fileId;
// // Optional. Document thumbnail as defined by sender
// private PhotoSize thumb;
// // Optional. Original filename as defined by sender
// private String fileName;
// // Optional. MIME type of the file as defined by sender
// private String mimeType;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Document(String fileId, PhotoSize thumb, String fileName, String mimeType, Integer fileSize) {
// this.fileId = fileId;
// this.thumb = thumb;
// this.fileName = fileName;
// this.mimeType = mimeType;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Document fromJSON(JSONObject documentObject) {
//
// String fileId = documentObject.getString("file_id");
//
// // Optional
// JSONObject thumbJson = documentObject.optJSONObject("thumb");
// PhotoSize thumb = (thumbJson != null) ? PhotoSize.fromJSON(thumbJson) : null;
//
// String fileName = documentObject.optString("file_name");
// String mimeType = documentObject.optString("mime_type");
// Integer fileSize = documentObject.optInt("file_size");
//
// return new Document(fileId, thumb, fileName, mimeType, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileName == null) ? 0 : this.fileName.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.mimeType == null) ? 0 : this.mimeType.hashCode());
// result = prime * result + ((this.thumb == null) ? 0 : this.thumb.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Document)) {
// return false;
// }
// Document other = (Document) obj;
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileName == null) {
// if (other.fileName != null) {
// return false;
// }
// } else if (!this.fileName.equals(other.fileName)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.mimeType == null) {
// if (other.mimeType != null) {
// return false;
// }
// } else if (!this.mimeType.equals(other.mimeType)) {
// return false;
// }
// if (this.thumb == null) {
// if (other.thumb != null) {
// return false;
// }
// } else if (!this.thumb.equals(other.thumb)) {
// return false;
// }
// return true;
// }
//
// public String getFileId()
// {
// return fileId;
// }
//
// public void setFileId(String aFileId)
// {
// fileId = aFileId;
// }
//
// public String getFileName()
// {
// return fileName;
// }
//
// public void setFileName(String aFileName)
// {
// fileName = aFileName;
// }
//
// public String getMimeType()
// {
// return mimeType;
// }
//
// public void setMimeType(String aMimeType)
// {
// mimeType = aMimeType;
// }
//
// public Integer getFileSize()
// {
// return fileSize;
// }
//
// public void setFileSize(Integer aFileSize)
// {
// fileSize = aFileSize;
// }
//
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.Document;
|
package de.vivistra.telegrambot.model.message;
public class DocumentMessage extends Message {
private static final String COMMAND = "sendDocument";
public static final String JSON_KEY = "document";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public DocumentMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/Document.java
// public class Document {
// // Unique file identifier
// private String fileId;
// // Optional. Document thumbnail as defined by sender
// private PhotoSize thumb;
// // Optional. Original filename as defined by sender
// private String fileName;
// // Optional. MIME type of the file as defined by sender
// private String mimeType;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Document(String fileId, PhotoSize thumb, String fileName, String mimeType, Integer fileSize) {
// this.fileId = fileId;
// this.thumb = thumb;
// this.fileName = fileName;
// this.mimeType = mimeType;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Document fromJSON(JSONObject documentObject) {
//
// String fileId = documentObject.getString("file_id");
//
// // Optional
// JSONObject thumbJson = documentObject.optJSONObject("thumb");
// PhotoSize thumb = (thumbJson != null) ? PhotoSize.fromJSON(thumbJson) : null;
//
// String fileName = documentObject.optString("file_name");
// String mimeType = documentObject.optString("mime_type");
// Integer fileSize = documentObject.optInt("file_size");
//
// return new Document(fileId, thumb, fileName, mimeType, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileName == null) ? 0 : this.fileName.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.mimeType == null) ? 0 : this.mimeType.hashCode());
// result = prime * result + ((this.thumb == null) ? 0 : this.thumb.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Document)) {
// return false;
// }
// Document other = (Document) obj;
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileName == null) {
// if (other.fileName != null) {
// return false;
// }
// } else if (!this.fileName.equals(other.fileName)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.mimeType == null) {
// if (other.mimeType != null) {
// return false;
// }
// } else if (!this.mimeType.equals(other.mimeType)) {
// return false;
// }
// if (this.thumb == null) {
// if (other.thumb != null) {
// return false;
// }
// } else if (!this.thumb.equals(other.thumb)) {
// return false;
// }
// return true;
// }
//
// public String getFileId()
// {
// return fileId;
// }
//
// public void setFileId(String aFileId)
// {
// fileId = aFileId;
// }
//
// public String getFileName()
// {
// return fileName;
// }
//
// public void setFileName(String aFileName)
// {
// fileName = aFileName;
// }
//
// public String getMimeType()
// {
// return mimeType;
// }
//
// public void setMimeType(String aMimeType)
// {
// mimeType = aMimeType;
// }
//
// public Integer getFileSize()
// {
// return fileSize;
// }
//
// public void setFileSize(Integer aFileSize)
// {
// fileSize = aFileSize;
// }
//
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/DocumentMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.Document;
package de.vivistra.telegrambot.model.message;
public class DocumentMessage extends Message {
private static final String COMMAND = "sendDocument";
public static final String JSON_KEY = "document";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public DocumentMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message
*
* @param recipient
* @param message
*/
|
public DocumentMessage(Long recipient, Document message) {
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/ContactMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/Contact.java
// public class Contact {
// private String firstname;
// private String lastname;
// private String phone;
// private String mail;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Contact(String firstname, String lastname, String phone, String mail) {
// this.firstname= firstname;
// this.lastname= lastname;
// this.phone= phone;
// this.mail= mail;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Contact fromJSON(JSONObject documentObject) {
//
// String firstname = documentObject.getString("first_name");
// String lastname = "";//documentObject.getString("lastname");
// String phone = documentObject.getString("phone_number");
// String mail = "";//documentObject.getString("mail");
//
// return new Contact(firstname, lastname, phone, mail);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.firstname == null) ? 0 : this.firstname.hashCode());
// result = prime * result + ((this.lastname == null) ? 0 : this.lastname.hashCode());
// result = prime * result + ((this.phone == null) ? 0 : this.phone.hashCode());
// result = prime * result + ((this.mail == null) ? 0 : this.mail.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Contact)) {
// return false;
// }
// Contact other = (Contact) obj;
// if (this.firstname == null) {
// if (other.firstname!= null) {
// return false;
// }
// } else if (!this.firstname.equals(other.firstname)) {
// return false;
// }
// if (this.lastname == null) {
// if (other.lastname != null) {
// return false;
// }
// } else if (!this.lastname.equals(other.lastname)) {
// return false;
// }
// if (this.phone == null) {
// if (other.phone != null) {
// return false;
// }
// } else if (!this.phone.equals(other.phone)) {
// return false;
// }
// if (this.mail == null) {
// if (other.mail != null) {
// return false;
// }
// } else if (!this.mail.equals(other.mail)) {
// return false;
// }
// return true;
// }
//
// public String getFirstname()
// {
// return firstname;
// }
//
// public void setFirstname(String aFirstname)
// {
// firstname = aFirstname;
// }
//
// public String getLastname()
// {
// return lastname;
// }
//
// public void setLastname(String aLastname)
// {
// lastname = aLastname;
// }
//
// public String getPhone()
// {
// return phone;
// }
//
// public void setPhone(String aPhone)
// {
// phone = aPhone;
// }
//
// public String getMail()
// {
// return mail;
// }
//
// public void setMail(String aMail)
// {
// mail = aMail;
// }
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.Contact;
|
package de.vivistra.telegrambot.model.message;
public class ContactMessage extends Message {
private static final String COMMAND = "sendContact";
public static final String JSON_KEY = "contact";
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/Contact.java
// public class Contact {
// private String firstname;
// private String lastname;
// private String phone;
// private String mail;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Contact(String firstname, String lastname, String phone, String mail) {
// this.firstname= firstname;
// this.lastname= lastname;
// this.phone= phone;
// this.mail= mail;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Contact fromJSON(JSONObject documentObject) {
//
// String firstname = documentObject.getString("first_name");
// String lastname = "";//documentObject.getString("lastname");
// String phone = documentObject.getString("phone_number");
// String mail = "";//documentObject.getString("mail");
//
// return new Contact(firstname, lastname, phone, mail);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.firstname == null) ? 0 : this.firstname.hashCode());
// result = prime * result + ((this.lastname == null) ? 0 : this.lastname.hashCode());
// result = prime * result + ((this.phone == null) ? 0 : this.phone.hashCode());
// result = prime * result + ((this.mail == null) ? 0 : this.mail.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Contact)) {
// return false;
// }
// Contact other = (Contact) obj;
// if (this.firstname == null) {
// if (other.firstname!= null) {
// return false;
// }
// } else if (!this.firstname.equals(other.firstname)) {
// return false;
// }
// if (this.lastname == null) {
// if (other.lastname != null) {
// return false;
// }
// } else if (!this.lastname.equals(other.lastname)) {
// return false;
// }
// if (this.phone == null) {
// if (other.phone != null) {
// return false;
// }
// } else if (!this.phone.equals(other.phone)) {
// return false;
// }
// if (this.mail == null) {
// if (other.mail != null) {
// return false;
// }
// } else if (!this.mail.equals(other.mail)) {
// return false;
// }
// return true;
// }
//
// public String getFirstname()
// {
// return firstname;
// }
//
// public void setFirstname(String aFirstname)
// {
// firstname = aFirstname;
// }
//
// public String getLastname()
// {
// return lastname;
// }
//
// public void setLastname(String aLastname)
// {
// lastname = aLastname;
// }
//
// public String getPhone()
// {
// return phone;
// }
//
// public void setPhone(String aPhone)
// {
// phone = aPhone;
// }
//
// public String getMail()
// {
// return mail;
// }
//
// public void setMail(String aMail)
// {
// mail = aMail;
// }
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/ContactMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.Contact;
package de.vivistra.telegrambot.model.message;
public class ContactMessage extends Message {
private static final String COMMAND = "sendContact";
public static final String JSON_KEY = "contact";
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
public ContactMessage(Long recipient, Contact contact) {
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/User.java
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
//
// Path: src/main/java/de/vivistra/telegrambot/utils/Tester.java
// public class Tester {
// public static boolean isNull(Object value) {
// return (value == null);
// }
//
// public static boolean isEmpty(String value) {
//
// return (isNull(value) || value.isEmpty());
// }
// }
|
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
import de.vivistra.telegrambot.utils.Tester;
|
package de.vivistra.telegrambot.model;
/**
* This class represents a Telegram user or bot
*/
public class User {
// Unique identifier for this user or bot
private Long id;
// User's or bot's first name
private String firstName;
// Optional. User's or bot's last name
private String lastName;
// Optional. User's or bot's username
private String userName;
/**
* Constructor for a user or bot object
*
* @param id
* @param firstName
* @param lastName
* @param userName
*/
public User(Long id, String firstName, String lastName, String userName) {
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
//
// Path: src/main/java/de/vivistra/telegrambot/utils/Tester.java
// public class Tester {
// public static boolean isNull(Object value) {
// return (value == null);
// }
//
// public static boolean isEmpty(String value) {
//
// return (isNull(value) || value.isEmpty());
// }
// }
// Path: src/main/java/de/vivistra/telegrambot/model/User.java
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
import de.vivistra.telegrambot.utils.Tester;
package de.vivistra.telegrambot.model;
/**
* This class represents a Telegram user or bot
*/
public class User {
// Unique identifier for this user or bot
private Long id;
// User's or bot's first name
private String firstName;
// Optional. User's or bot's last name
private String lastName;
// Optional. User's or bot's username
private String userName;
/**
* Constructor for a user or bot object
*
* @param id
* @param firstName
* @param lastName
* @param userName
*/
public User(Long id, String firstName, String lastName, String userName) {
|
Assert.notNull(id);
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/User.java
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
//
// Path: src/main/java/de/vivistra/telegrambot/utils/Tester.java
// public class Tester {
// public static boolean isNull(Object value) {
// return (value == null);
// }
//
// public static boolean isEmpty(String value) {
//
// return (isNull(value) || value.isEmpty());
// }
// }
|
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
import de.vivistra.telegrambot.utils.Tester;
|
* Get users or bots first name
*
* @return
*/
public String getFirstName() {
return firstName;
}
/**
* Get users or bots last name
*
* @return
*/
public String getLastName() {
return lastName;
}
/**
* Get users or bots username
*
* @return
*/
public String getUserName() {
return userName;
}
/**
* The object as a String
*/
public String toString() {
|
// Path: src/main/java/de/vivistra/telegrambot/utils/Assert.java
// public class Assert {
// public static void notNull(Object value) {
//
// if (Tester.isNull(value)) {
// throw new IllegalArgumentException("Argument is NULL.");
// }
// }
//
// public static void notEmpty(String value) {
//
// if (Tester.isEmpty(value)) {
// throw new IllegalArgumentException("Argument is NULL or empty.");
// }
// }
//
// }
//
// Path: src/main/java/de/vivistra/telegrambot/utils/Tester.java
// public class Tester {
// public static boolean isNull(Object value) {
// return (value == null);
// }
//
// public static boolean isEmpty(String value) {
//
// return (isNull(value) || value.isEmpty());
// }
// }
// Path: src/main/java/de/vivistra/telegrambot/model/User.java
import org.json.JSONObject;
import de.vivistra.telegrambot.utils.Assert;
import de.vivistra.telegrambot.utils.Tester;
* Get users or bots first name
*
* @return
*/
public String getFirstName() {
return firstName;
}
/**
* Get users or bots last name
*
* @return
*/
public String getLastName() {
return lastName;
}
/**
* Get users or bots username
*
* @return
*/
public String getUserName() {
return userName;
}
/**
* The object as a String
*/
public String toString() {
|
return firstName + (!Tester.isEmpty(lastName) ? " " + lastName : "") + " ["
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/AudioMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/Audio.java
// public class Audio {
//
// // Unique file identifier
// private String fileId;
// // Duration of the audio in seconds as defined by sender
// private Integer duration;
// // Optional. MIME type of the file as defined by sender
// private String mimeType;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a audio object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Audio(String fileId, Integer duration, String mimeType, Integer fileSize) {
// this.fileId = fileId;
// this.duration = duration;
// this.mimeType = mimeType;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a audio object from a JSON String
// *
// * @param audioObject
// * @return Audio
// */
// public static Audio fromJSON(JSONObject audioObject) {
//
// String fileId = audioObject.getString("file_id");
// Integer duration = audioObject.getInt("duration");
//
// // Optional
// String mimeType = audioObject.optString("mime_type");
// Integer fileSize = audioObject.optInt("file_size");
//
// return new Audio(fileId, duration, mimeType, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.duration == null) ? 0 : this.duration.hashCode());
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.mimeType == null) ? 0 : this.mimeType.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Audio)) {
// return false;
// }
// Audio other = (Audio) obj;
// if (this.duration == null) {
// if (other.duration != null) {
// return false;
// }
// } else if (!this.duration.equals(other.duration)) {
// return false;
// }
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.mimeType == null) {
// if (other.mimeType != null) {
// return false;
// }
// } else if (!this.mimeType.equals(other.mimeType)) {
// return false;
// }
// return true;
// }
//
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.Audio;
|
package de.vivistra.telegrambot.model.message;
public class AudioMessage extends Message {
private static final String COMMAND = "sendAudio";
public static final String JSON_KEY = "audio";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public AudioMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/Audio.java
// public class Audio {
//
// // Unique file identifier
// private String fileId;
// // Duration of the audio in seconds as defined by sender
// private Integer duration;
// // Optional. MIME type of the file as defined by sender
// private String mimeType;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a audio object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Audio(String fileId, Integer duration, String mimeType, Integer fileSize) {
// this.fileId = fileId;
// this.duration = duration;
// this.mimeType = mimeType;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a audio object from a JSON String
// *
// * @param audioObject
// * @return Audio
// */
// public static Audio fromJSON(JSONObject audioObject) {
//
// String fileId = audioObject.getString("file_id");
// Integer duration = audioObject.getInt("duration");
//
// // Optional
// String mimeType = audioObject.optString("mime_type");
// Integer fileSize = audioObject.optInt("file_size");
//
// return new Audio(fileId, duration, mimeType, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.duration == null) ? 0 : this.duration.hashCode());
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.mimeType == null) ? 0 : this.mimeType.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Audio)) {
// return false;
// }
// Audio other = (Audio) obj;
// if (this.duration == null) {
// if (other.duration != null) {
// return false;
// }
// } else if (!this.duration.equals(other.duration)) {
// return false;
// }
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.mimeType == null) {
// if (other.mimeType != null) {
// return false;
// }
// } else if (!this.mimeType.equals(other.mimeType)) {
// return false;
// }
// return true;
// }
//
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/AudioMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.Audio;
package de.vivistra.telegrambot.model.message;
public class AudioMessage extends Message {
private static final String COMMAND = "sendAudio";
public static final String JSON_KEY = "audio";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public AudioMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message
*
* @param recipient
* @param message
*/
|
public AudioMessage(Long recipient, Audio message) {
|
marzn/telegrambot-japi
|
src/test/java/de/vivistra/telegrambot/client/TestBotRequest.java
|
// Path: src/main/java/de/vivistra/telegrambot/receiver/UpdateRequest.java
// public class UpdateRequest {
//
// private static final String COMMAND = "getUpdates";
// private static final Integer TIMEOUT = 60; // in seconds for long polling
// private static final Integer LIMIT = 100;
//
// private static final String KEY_MSG_UPDATE_OFFSET = "offset";
// private static final String KEY_MSG_UPDATE_LIMIT = "limit";
// private static final String KEY_MSG_UPDATE_TIMEOUT = "timeout";
//
// private final Integer offset;
//
// private MultipartEntityBuilder requestEntity = null;
//
// public UpdateRequest(Integer nextExpectedMsg) {
// this.offset = nextExpectedMsg;
//
// this.requestEntity = MultipartEntityBuilder.create();
// // New MIME type, data need to be UTF-8 encrypted
// ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);
//
// // Set timout, limit and offset
// requestEntity.addTextBody(KEY_MSG_UPDATE_TIMEOUT, TIMEOUT.toString(), contentType);
// requestEntity.addTextBody(KEY_MSG_UPDATE_LIMIT, LIMIT.toString(), contentType);
// requestEntity.addTextBody(KEY_MSG_UPDATE_OFFSET, offset.toString(), contentType);
//
// }
//
// public String getCommand() {
// return COMMAND;
// }
//
// public MultipartEntityBuilder getRequestEntity() {
// return this.requestEntity;
// }
// }
|
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.junit.Test;
import org.mockito.Mockito;
import de.vivistra.telegrambot.receiver.UpdateRequest;
|
package de.vivistra.telegrambot.client;
public class TestBotRequest {
@Test
public void testUpdateRequest() {
|
// Path: src/main/java/de/vivistra/telegrambot/receiver/UpdateRequest.java
// public class UpdateRequest {
//
// private static final String COMMAND = "getUpdates";
// private static final Integer TIMEOUT = 60; // in seconds for long polling
// private static final Integer LIMIT = 100;
//
// private static final String KEY_MSG_UPDATE_OFFSET = "offset";
// private static final String KEY_MSG_UPDATE_LIMIT = "limit";
// private static final String KEY_MSG_UPDATE_TIMEOUT = "timeout";
//
// private final Integer offset;
//
// private MultipartEntityBuilder requestEntity = null;
//
// public UpdateRequest(Integer nextExpectedMsg) {
// this.offset = nextExpectedMsg;
//
// this.requestEntity = MultipartEntityBuilder.create();
// // New MIME type, data need to be UTF-8 encrypted
// ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);
//
// // Set timout, limit and offset
// requestEntity.addTextBody(KEY_MSG_UPDATE_TIMEOUT, TIMEOUT.toString(), contentType);
// requestEntity.addTextBody(KEY_MSG_UPDATE_LIMIT, LIMIT.toString(), contentType);
// requestEntity.addTextBody(KEY_MSG_UPDATE_OFFSET, offset.toString(), contentType);
//
// }
//
// public String getCommand() {
// return COMMAND;
// }
//
// public MultipartEntityBuilder getRequestEntity() {
// return this.requestEntity;
// }
// }
// Path: src/test/java/de/vivistra/telegrambot/client/TestBotRequest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.junit.Test;
import org.mockito.Mockito;
import de.vivistra.telegrambot.receiver.UpdateRequest;
package de.vivistra.telegrambot.client;
public class TestBotRequest {
@Test
public void testUpdateRequest() {
|
UpdateRequest updateRequest = Mockito.mock(UpdateRequest.class);
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/LocationMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/Location.java
// public class Location {
// private Double longitude;
// private Double latitude;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Location(Double longitude, Double latitude) {
// this.longitude = longitude;
// this.latitude = latitude;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Location fromJSON(JSONObject documentObject) {
//
// Double longitude = documentObject.getDouble("longitude");
//
// // Optional
// JSONObject thumbJson = documentObject.optJSONObject("thumb");
// PhotoSize thumb = (thumbJson != null) ? PhotoSize.fromJSON(thumbJson) : null;
//
// Double latitude = documentObject.getDouble("latitude");
// return new Location(longitude, latitude);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.longitude == null) ? 0 : this.longitude.hashCode());
// result = prime * result + ((this.latitude == null) ? 0 : this.latitude.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Location)) {
// return false;
// }
// Location other = (Location) obj;
// if (this.longitude == null) {
// if (other.longitude!= null) {
// return false;
// }
// } else if (!this.longitude.equals(other.longitude)) {
// return false;
// }
// if (this.latitude == null) {
// if (other.latitude != null) {
// return false;
// }
// } else if (!this.latitude.equals(other.latitude)) {
// return false;
// }
// return true;
// }
//
// public Double getLongitude()
// {
// return longitude;
// }
//
// public void setLongitude(Double aLongitude)
// {
// longitude = aLongitude;
// }
//
// public Double getLatitude()
// {
// return latitude;
// }
//
// public void setLatitude(Double aLatitude)
// {
// latitude = aLatitude;
// }
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.Location;
|
package de.vivistra.telegrambot.model.message;
public class LocationMessage extends Message {
private static final String COMMAND = "sendLocation";
public static final String JSON_KEY = "location";
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/Location.java
// public class Location {
// private Double longitude;
// private Double latitude;
//
// /**
// * Creates a document object
// *
// * @param fileId
// * @param thumb
// * @param fileName
// * @param mimeType
// * @param fileSize
// */
// public Location(Double longitude, Double latitude) {
// this.longitude = longitude;
// this.latitude = latitude;
// }
//
// /**
// * Create a document object from a JSON String
// *
// * @param documentObject
// * @return Document
// */
// public static Location fromJSON(JSONObject documentObject) {
//
// Double longitude = documentObject.getDouble("longitude");
//
// // Optional
// JSONObject thumbJson = documentObject.optJSONObject("thumb");
// PhotoSize thumb = (thumbJson != null) ? PhotoSize.fromJSON(thumbJson) : null;
//
// Double latitude = documentObject.getDouble("latitude");
// return new Location(longitude, latitude);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.longitude == null) ? 0 : this.longitude.hashCode());
// result = prime * result + ((this.latitude == null) ? 0 : this.latitude.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof Location)) {
// return false;
// }
// Location other = (Location) obj;
// if (this.longitude == null) {
// if (other.longitude!= null) {
// return false;
// }
// } else if (!this.longitude.equals(other.longitude)) {
// return false;
// }
// if (this.latitude == null) {
// if (other.latitude != null) {
// return false;
// }
// } else if (!this.latitude.equals(other.latitude)) {
// return false;
// }
// return true;
// }
//
// public Double getLongitude()
// {
// return longitude;
// }
//
// public void setLongitude(Double aLongitude)
// {
// longitude = aLongitude;
// }
//
// public Double getLatitude()
// {
// return latitude;
// }
//
// public void setLatitude(Double aLatitude)
// {
// latitude = aLatitude;
// }
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/LocationMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.Location;
package de.vivistra.telegrambot.model.message;
public class LocationMessage extends Message {
private static final String COMMAND = "sendLocation";
public static final String JSON_KEY = "location";
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
public LocationMessage(Long recipient, Location message) {
|
marzn/telegrambot-japi
|
src/main/java/de/vivistra/telegrambot/model/message/ImageMessage.java
|
// Path: src/main/java/de/vivistra/telegrambot/model/PhotoSize.java
// public class PhotoSize {
// // Unique identifier for this file
// private String fileId;
// // Photo width
// private Integer width;
// // Photo height
// private Integer height;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a PhotoSize object
// *
// * @param fileId
// * @param width
// * @param height
// * @param fileSize
// */
// public PhotoSize(String fileId, Integer width, Integer height, Integer fileSize) {
// super();
// this.fileId = fileId;
// this.width = width;
// this.height = height;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a user or bot object from a JSON String
// *
// * @param userObject
// * @return User
// */
// public static PhotoSize fromJSON(JSONObject userObject) {
//
// String fileId = userObject.getString("file_id");
// Integer width = userObject.getInt("width");
// Integer height = userObject.getInt("height");
//
// // Optional
// Integer fileSize = userObject.optInt("file_size");
//
// return new PhotoSize(fileId, width, height, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.height == null) ? 0 : this.height.hashCode());
// result = prime * result + ((this.width == null) ? 0 : this.width.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof PhotoSize)) {
// return false;
// }
// PhotoSize other = (PhotoSize) obj;
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.height == null) {
// if (other.height != null) {
// return false;
// }
// } else if (!this.height.equals(other.height)) {
// return false;
// }
// if (this.width == null) {
// if (other.width != null) {
// return false;
// }
// } else if (!this.width.equals(other.width)) {
// return false;
// }
// return true;
// }
//
// public String getFileId()
// {
// return fileId;
// }
//
// public void setFileId(String aFileId)
// {
// fileId = aFileId;
// }
//
// public Integer getWidth()
// {
// return width;
// }
//
// public void setWidth(Integer aWidth)
// {
// width = aWidth;
// }
//
// public Integer getHeight()
// {
// return height;
// }
//
// public void setHeight(Integer aHeight)
// {
// height = aHeight;
// }
//
// public Integer getFileSize()
// {
// return fileSize;
// }
//
// public void setFileSize(Integer aFileSize)
// {
// fileSize = aFileSize;
// }
//
// }
|
import java.io.File;
import de.vivistra.telegrambot.model.PhotoSize;
|
package de.vivistra.telegrambot.model.message;
public class ImageMessage extends Message {
private static final String COMMAND = "sendPhoto";
public static final String JSON_KEY = "photo";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public ImageMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
// Path: src/main/java/de/vivistra/telegrambot/model/PhotoSize.java
// public class PhotoSize {
// // Unique identifier for this file
// private String fileId;
// // Photo width
// private Integer width;
// // Photo height
// private Integer height;
// // Optional. File size
// private Integer fileSize;
//
// /**
// * Creates a PhotoSize object
// *
// * @param fileId
// * @param width
// * @param height
// * @param fileSize
// */
// public PhotoSize(String fileId, Integer width, Integer height, Integer fileSize) {
// super();
// this.fileId = fileId;
// this.width = width;
// this.height = height;
// this.fileSize = fileSize;
// }
//
// /**
// * Create a user or bot object from a JSON String
// *
// * @param userObject
// * @return User
// */
// public static PhotoSize fromJSON(JSONObject userObject) {
//
// String fileId = userObject.getString("file_id");
// Integer width = userObject.getInt("width");
// Integer height = userObject.getInt("height");
//
// // Optional
// Integer fileSize = userObject.optInt("file_size");
//
// return new PhotoSize(fileId, width, height, fileSize);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((this.fileId == null) ? 0 : this.fileId.hashCode());
// result = prime * result + ((this.fileSize == null) ? 0 : this.fileSize.hashCode());
// result = prime * result + ((this.height == null) ? 0 : this.height.hashCode());
// result = prime * result + ((this.width == null) ? 0 : this.width.hashCode());
// return result;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (!(obj instanceof PhotoSize)) {
// return false;
// }
// PhotoSize other = (PhotoSize) obj;
// if (this.fileId == null) {
// if (other.fileId != null) {
// return false;
// }
// } else if (!this.fileId.equals(other.fileId)) {
// return false;
// }
// if (this.fileSize == null) {
// if (other.fileSize != null) {
// return false;
// }
// } else if (!this.fileSize.equals(other.fileSize)) {
// return false;
// }
// if (this.height == null) {
// if (other.height != null) {
// return false;
// }
// } else if (!this.height.equals(other.height)) {
// return false;
// }
// if (this.width == null) {
// if (other.width != null) {
// return false;
// }
// } else if (!this.width.equals(other.width)) {
// return false;
// }
// return true;
// }
//
// public String getFileId()
// {
// return fileId;
// }
//
// public void setFileId(String aFileId)
// {
// fileId = aFileId;
// }
//
// public Integer getWidth()
// {
// return width;
// }
//
// public void setWidth(Integer aWidth)
// {
// width = aWidth;
// }
//
// public Integer getHeight()
// {
// return height;
// }
//
// public void setHeight(Integer aHeight)
// {
// height = aHeight;
// }
//
// public Integer getFileSize()
// {
// return fileSize;
// }
//
// public void setFileSize(Integer aFileSize)
// {
// fileSize = aFileSize;
// }
//
// }
// Path: src/main/java/de/vivistra/telegrambot/model/message/ImageMessage.java
import java.io.File;
import de.vivistra.telegrambot.model.PhotoSize;
package de.vivistra.telegrambot.model.message;
public class ImageMessage extends Message {
private static final String COMMAND = "sendPhoto";
public static final String JSON_KEY = "photo";
/**
* Creates a message
*
* @param recipient
* @param message
*/
public ImageMessage(Long recipient, File message) {
super(recipient, message);
}
/**
* Creates a message from String
*
* @param recipient
* @param message
*/
|
public ImageMessage(Long recipient, PhotoSize[] message) {
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/command/CmdAdminDecay.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
|
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
|
package com.devotedmc.ExilePearl.command;
public class CmdAdminDecay extends PearlCommand {
public CmdAdminDecay(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("decay");
this.setHelpShort("Performs decay operation on all pearls");
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/command/CmdAdminDecay.java
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
package com.devotedmc.ExilePearl.command;
public class CmdAdminDecay extends PearlCommand {
public CmdAdminDecay(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("decay");
this.setHelpShort("Performs decay operation on all pearls");
|
this.permission = Permission.DECAY.node;
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/command/CmdConfig.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
|
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
|
package com.devotedmc.ExilePearl.command;
public class CmdConfig extends PearlCommand {
public CmdConfig(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("config");
this.setHelpShort("Manage ExilePearl configuration");
this.addSubCommand(new CmdConfigLoad(plugin));
this.addSubCommand(new CmdConfigSave(plugin));
this.addSubCommand(new CmdConfigList(plugin));
this.addSubCommand(new CmdConfigSet(plugin));
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/command/CmdConfig.java
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
package com.devotedmc.ExilePearl.command;
public class CmdConfig extends PearlCommand {
public CmdConfig(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("config");
this.setHelpShort("Manage ExilePearl configuration");
this.addSubCommand(new CmdConfigLoad(plugin));
this.addSubCommand(new CmdConfigSave(plugin));
this.addSubCommand(new CmdConfigList(plugin));
this.addSubCommand(new CmdConfigSet(plugin));
|
this.permission = Permission.CONFIG.node;
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/command/CmdAutoHelp.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
|
import java.util.ArrayList;
import com.devotedmc.ExilePearl.ExilePearlApi;
import vg.civcraft.mc.civmodcore.util.TextUtil;
|
package com.devotedmc.ExilePearl.command;
public class CmdAutoHelp extends PearlCommand
{
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
// Path: src/main/java/com/devotedmc/ExilePearl/command/CmdAutoHelp.java
import java.util.ArrayList;
import com.devotedmc.ExilePearl.ExilePearlApi;
import vg.civcraft.mc.civmodcore.util.TextUtil;
package com.devotedmc.ExilePearl.command;
public class CmdAutoHelp extends PearlCommand
{
|
public CmdAutoHelp(ExilePearlApi pearlApi) {
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/command/CmdAdminReload.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
|
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
|
package com.devotedmc.ExilePearl.command;
public class CmdAdminReload extends PearlCommand {
public CmdAdminReload(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("reload");
this.setHelpShort("Reloads the entire plugin.");
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/util/Permission.java
// public enum Permission
// {
// PLAYER("player"),
// CHECK("check"),
// DECAY("decay"),
// EXILE_ANY("exileany"),
// FREE_ANY("freeany"),
// LIST("list"),
// RELOAD("reload"),
// SET_HEALTH("sethealth"),
// SET_TYPE("settype"),
// SET_KILLER("setkiller"),
// CONFIG("config")
// ;
//
// /**
// * The node string that is referenced for permissions
// */
// public final String node;
//
// Permission(final String node) {
// this.node = "exilepearl." + node;
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/command/CmdAdminReload.java
import com.devotedmc.ExilePearl.ExilePearlApi;
import com.devotedmc.ExilePearl.util.Permission;
package com.devotedmc.ExilePearl.command;
public class CmdAdminReload extends PearlCommand {
public CmdAdminReload(ExilePearlApi pearlApi) {
super(pearlApi);
this.aliases.add("reload");
this.setHelpShort("Reloads the entire plugin.");
|
this.permission = Permission.RELOAD.node;
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/command/CmdExilePearl.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
|
import com.devotedmc.ExilePearl.ExilePearlApi;
|
package com.devotedmc.ExilePearl.command;
public class CmdExilePearl extends PearlCommand {
private static CmdExilePearl instance;
public static CmdExilePearl instance() {
return instance;
}
public final PearlCommand cmdLocate;
public final PearlCommand cmdFree;
public final PearlCommand cmdBcast;
public final PearlCommand cmdBcastConfirm;
public final PearlCommand cmdBcastSilence;
public final PearlCommand cmdDowngrade;
|
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlApi.java
// public interface ExilePearlApi extends Plugin, PearlAccess, PearlLogger, PlayerProvider {
//
// /**
// * Gets the exile pearl configuration
// * @return The exile pearl configuration
// */
// PearlConfig getPearlConfig();
//
// /**
// * Gets the pearl lore provider
// * @return The lore provider
// */
// LoreProvider getLoreProvider();
//
// /**
// * Gets the storage provider
// * @return The storage provider
// */
// StorageProvider getStorageProvider();
//
// /**
// * Gets the suicide handler
// * @return The suicide handler
// */
// SuicideHandler getSuicideHandler();
//
// /**
// * Gets the pearl manager
// * @return The pearl manager
// */
// PearlManager getPearlManager();
//
// /**
// * Gets the damage logger
// * @return The damage logger
// */
// DamageLogger getDamageLogger();
//
// /**
// * Gets the auto-help command
// * @return The auto-help
// */
// PearlCommand getAutoHelp();
//
// /**
// * Gets whether a player is combat tagged
// * @param uid The player UUID
// * @return true if the player is tagged
// */
// boolean isPlayerTagged(UUID uid);
//
// /**
// * Gets a player as a tagged NPC entity.
// * <p>
// * This will return null for a normal player.
// * @param player The player being referenced
// * @return The NPC entity instance
// */
// NpcIdentity getPlayerAsTaggedNpc(Player player);
//
// /**
// * Gets whether Artemis hooks are enabled
// * @return True if it is enabled
// */
// boolean isArtemisEnabled();
//
// /**
// * Gets whether NameLayer hooks are enabled
// * @return True if it is enabled
// */
// boolean isNameLayerEnabled();
//
// /**
// * Gets whether Citadel hooks are enabled
// * @return True if it is enabled
// */
// boolean isCitadelEnabled();
//
// /**
// * Gets whether Bastion hooks are enabled
// * @return True if it is enabled
// */
// boolean isBastionEnabled();
//
// /**
// * Gets whether JukeAlert hooks are enabled
// * @return True if it is enabled
// */
// boolean isJukeAlertEnabled();
//
// /**
// * Gets whether BanStick hooks are enabled
// * @return True if it is enabled
// */
// boolean isBanStickEnabled();
//
// /**
// * Gets whether RandomSpawn hooks are enabled
// * @return True if it is enabled
// */
// boolean isRandomSpawnEnabled();
//
// /**
// * Gets whether WorldBorder hooks are enabled
// * @return True if it is enabled
// */
// boolean isWorldBorderEnabled();
//
// /**
// * Gets whether CombatTag hooks are enabled
// * @return True if it is enabled
// */
// boolean isCombatTagEnabled();
//
// /**
// * Checks if a location is inside the world border
// * @param location the location to check
// * @return true if the location is inside the border
// */
// boolean isLocationInsideBorder(Location location);
//
// /**
// * Gets whether a player is in a non-permission bastion
// * @param player The player to check
// * @return true if the player is inside a non-permission bastion
// */
// boolean isPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets bastions the player is in, that they shouldn't be in.
// * @param player The player to check
// * @return list of bastions the player is inside that they shouldn't be
// */
// List<BastionWrapper> getPlayerInUnpermittedBastion(Player player);
//
// /**
// * Gets the clock instance
// * @return the clock instance
// */
// Clock getClock();
//
// /**
// * Gets the Brew handler for brew checking, if any.
// *
// * @return a Brew Handler appropriate for the server.
// */
// BrewHandler getBrewHandler();
//
// /**
// * Gets NameLayer PermissionTracker
// *
// * @return NameLayerPermissions class
// */
// NameLayerPermissions getNameLayerPermissions();
// }
// Path: src/main/java/com/devotedmc/ExilePearl/command/CmdExilePearl.java
import com.devotedmc.ExilePearl.ExilePearlApi;
package com.devotedmc.ExilePearl.command;
public class CmdExilePearl extends PearlCommand {
private static CmdExilePearl instance;
public static CmdExilePearl instance() {
return instance;
}
public final PearlCommand cmdLocate;
public final PearlCommand cmdFree;
public final PearlCommand cmdBcast;
public final PearlCommand cmdBcastConfirm;
public final PearlCommand cmdBcastSilence;
public final PearlCommand cmdDowngrade;
|
public CmdExilePearl(ExilePearlApi pearlApi) {
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/ExilePearl.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/broadcast/BroadcastListener.java
// public interface BroadcastListener {
//
// /**
// * Broadcasts the pearl location
// * @param pearl The pearl to broadcast
// */
// void broadcast(ExilePearl pearl);
//
// /**
// * Gets whether the broadcast listener contains an underlying object
// * @param o the object to check
// * @return true if it exists
// */
// boolean contains(Object o);
//
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/holder/PearlHolder.java
// public interface PearlHolder {
//
// /**
// * Gets the holder name
// * @return The holder name
// */
// public String getName();
//
// /**
// * Gets the holder location
// * @return The holder location
// */
// public Location getLocation();
//
// /**
// * Validate that the given pearl still exists in this holder instance
// * @param pearl The exile pearl
// * @return the validation result
// */
// public HolderVerifyResult validate(final ExilePearl pearl);
//
// /**
// * Gets whether the holder is a block
// * @return true if the holder is a block
// */
// public boolean isBlock();
//
// /**
// * Gets whether the holder is in a loaded chunk
// * @return true if the holder is in a loaded chunk
// */
// public default boolean inLoadedChunk() {
// Location loc = getLocation();
// World world = loc.getWorld();
//
// if (world == null) {
// return false;
// }
//
// return world.isChunkLoaded(BlockBasedChunkMeta.toChunkCoord(loc.getBlockX()), BlockBasedChunkMeta.toChunkCoord(loc.getBlockZ()));
// }
// }
|
import java.util.Date;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.devotedmc.ExilePearl.broadcast.BroadcastListener;
import com.devotedmc.ExilePearl.holder.PearlHolder;
|
package com.devotedmc.ExilePearl;
/**
* Interface for a player who is imprisoned in an exile pearl
* @author Gordon
*/
public interface ExilePearl {
/**
* Gets the pearl item name
* @return The item name
*/
String getItemName();
/**
* Gets the exiled player ID
* @return The player ID
*/
UUID getPlayerId();
/**
* Gets the unique pearl ID
* @return The pearl ID
*/
int getPearlId();
/**
* Gets the exiled player instance
* @return The exiled player
*/
Player getPlayer();
/**
* Gets the pearl type
* @return The pearl type
*/
PearlType getPearlType();
/**
* Sets the pearl type
* @param type The pearl type
*/
void setPearlType(PearlType type);
/**
* Gets when the player was pearled
* @return The time the player was pearled
*/
Date getPearledOn();
/**
* Sets when the player was pearled
* @param pearledOn The time the player was pearled
*/
void setPearledOn(Date pearledOn);
/**
* Gets the exiled player's name
* @return The exiled player's name
*/
String getPlayerName();
/**
* Gets the pearl holder
* @return The pearl holder
*/
|
// Path: src/main/java/com/devotedmc/ExilePearl/broadcast/BroadcastListener.java
// public interface BroadcastListener {
//
// /**
// * Broadcasts the pearl location
// * @param pearl The pearl to broadcast
// */
// void broadcast(ExilePearl pearl);
//
// /**
// * Gets whether the broadcast listener contains an underlying object
// * @param o the object to check
// * @return true if it exists
// */
// boolean contains(Object o);
//
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/holder/PearlHolder.java
// public interface PearlHolder {
//
// /**
// * Gets the holder name
// * @return The holder name
// */
// public String getName();
//
// /**
// * Gets the holder location
// * @return The holder location
// */
// public Location getLocation();
//
// /**
// * Validate that the given pearl still exists in this holder instance
// * @param pearl The exile pearl
// * @return the validation result
// */
// public HolderVerifyResult validate(final ExilePearl pearl);
//
// /**
// * Gets whether the holder is a block
// * @return true if the holder is a block
// */
// public boolean isBlock();
//
// /**
// * Gets whether the holder is in a loaded chunk
// * @return true if the holder is in a loaded chunk
// */
// public default boolean inLoadedChunk() {
// Location loc = getLocation();
// World world = loc.getWorld();
//
// if (world == null) {
// return false;
// }
//
// return world.isChunkLoaded(BlockBasedChunkMeta.toChunkCoord(loc.getBlockX()), BlockBasedChunkMeta.toChunkCoord(loc.getBlockZ()));
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearl.java
import java.util.Date;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.devotedmc.ExilePearl.broadcast.BroadcastListener;
import com.devotedmc.ExilePearl.holder.PearlHolder;
package com.devotedmc.ExilePearl;
/**
* Interface for a player who is imprisoned in an exile pearl
* @author Gordon
*/
public interface ExilePearl {
/**
* Gets the pearl item name
* @return The item name
*/
String getItemName();
/**
* Gets the exiled player ID
* @return The player ID
*/
UUID getPlayerId();
/**
* Gets the unique pearl ID
* @return The pearl ID
*/
int getPearlId();
/**
* Gets the exiled player instance
* @return The exiled player
*/
Player getPlayer();
/**
* Gets the pearl type
* @return The pearl type
*/
PearlType getPearlType();
/**
* Sets the pearl type
* @param type The pearl type
*/
void setPearlType(PearlType type);
/**
* Gets when the player was pearled
* @return The time the player was pearled
*/
Date getPearledOn();
/**
* Sets when the player was pearled
* @param pearledOn The time the player was pearled
*/
void setPearledOn(Date pearledOn);
/**
* Gets the exiled player's name
* @return The exiled player's name
*/
String getPlayerName();
/**
* Gets the pearl holder
* @return The pearl holder
*/
|
PearlHolder getHolder();
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/ExilePearl.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/broadcast/BroadcastListener.java
// public interface BroadcastListener {
//
// /**
// * Broadcasts the pearl location
// * @param pearl The pearl to broadcast
// */
// void broadcast(ExilePearl pearl);
//
// /**
// * Gets whether the broadcast listener contains an underlying object
// * @param o the object to check
// * @return true if it exists
// */
// boolean contains(Object o);
//
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/holder/PearlHolder.java
// public interface PearlHolder {
//
// /**
// * Gets the holder name
// * @return The holder name
// */
// public String getName();
//
// /**
// * Gets the holder location
// * @return The holder location
// */
// public Location getLocation();
//
// /**
// * Validate that the given pearl still exists in this holder instance
// * @param pearl The exile pearl
// * @return the validation result
// */
// public HolderVerifyResult validate(final ExilePearl pearl);
//
// /**
// * Gets whether the holder is a block
// * @return true if the holder is a block
// */
// public boolean isBlock();
//
// /**
// * Gets whether the holder is in a loaded chunk
// * @return true if the holder is in a loaded chunk
// */
// public default boolean inLoadedChunk() {
// Location loc = getLocation();
// World world = loc.getWorld();
//
// if (world == null) {
// return false;
// }
//
// return world.isChunkLoaded(BlockBasedChunkMeta.toChunkCoord(loc.getBlockX()), BlockBasedChunkMeta.toChunkCoord(loc.getBlockZ()));
// }
// }
|
import java.util.Date;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.devotedmc.ExilePearl.broadcast.BroadcastListener;
import com.devotedmc.ExilePearl.holder.PearlHolder;
|
*/
ItemStack createItemStack();
/**
* Verifies the pearl location
* @return true if the location is verified
*/
boolean verifyLocation();
/**
* Validates that an item stack is the exile pearl
* @param is The item stack
* @return true if validation passes
*/
boolean validateItemStack(ItemStack is);
/**
* Enables storage updates when writing values
*/
void enableStorage();
/**
* Broadcasts the pearl location to all the listeners
*/
void performBroadcast();
/**
* Adds a broadcast target
* @param bcast The broadcast target
*/
|
// Path: src/main/java/com/devotedmc/ExilePearl/broadcast/BroadcastListener.java
// public interface BroadcastListener {
//
// /**
// * Broadcasts the pearl location
// * @param pearl The pearl to broadcast
// */
// void broadcast(ExilePearl pearl);
//
// /**
// * Gets whether the broadcast listener contains an underlying object
// * @param o the object to check
// * @return true if it exists
// */
// boolean contains(Object o);
//
// }
//
// Path: src/main/java/com/devotedmc/ExilePearl/holder/PearlHolder.java
// public interface PearlHolder {
//
// /**
// * Gets the holder name
// * @return The holder name
// */
// public String getName();
//
// /**
// * Gets the holder location
// * @return The holder location
// */
// public Location getLocation();
//
// /**
// * Validate that the given pearl still exists in this holder instance
// * @param pearl The exile pearl
// * @return the validation result
// */
// public HolderVerifyResult validate(final ExilePearl pearl);
//
// /**
// * Gets whether the holder is a block
// * @return true if the holder is a block
// */
// public boolean isBlock();
//
// /**
// * Gets whether the holder is in a loaded chunk
// * @return true if the holder is in a loaded chunk
// */
// public default boolean inLoadedChunk() {
// Location loc = getLocation();
// World world = loc.getWorld();
//
// if (world == null) {
// return false;
// }
//
// return world.isChunkLoaded(BlockBasedChunkMeta.toChunkCoord(loc.getBlockX()), BlockBasedChunkMeta.toChunkCoord(loc.getBlockZ()));
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearl.java
import java.util.Date;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.devotedmc.ExilePearl.broadcast.BroadcastListener;
import com.devotedmc.ExilePearl.holder.PearlHolder;
*/
ItemStack createItemStack();
/**
* Verifies the pearl location
* @return true if the location is verified
*/
boolean verifyLocation();
/**
* Validates that an item stack is the exile pearl
* @param is The item stack
* @return true if validation passes
*/
boolean validateItemStack(ItemStack is);
/**
* Enables storage updates when writing values
*/
void enableStorage();
/**
* Broadcasts the pearl location to all the listeners
*/
void performBroadcast();
/**
* Adds a broadcast target
* @param bcast The broadcast target
*/
|
void addBroadcastListener(BroadcastListener bcast);
|
DevotedMC/ExilePearl
|
src/main/java/com/devotedmc/ExilePearl/ExilePearlPlugin.java
|
// Path: src/main/java/com/devotedmc/ExilePearl/core/CorePluginFactory.java
// public final class CorePluginFactory implements PearlFactory {
//
// private final ExilePearlApi pearlApi;
//
// public static ExilePearlApi createCore(final Plugin plugin) {
// return new ExilePearlCore(plugin);
// }
//
// /**
// * Creates a new ExilePearlFactory instance
// * @param plugin The plugin instance
// */
// public CorePluginFactory(final ExilePearlApi plugin) {
// Guard.ArgumentNotNull(plugin, "plugin");
//
// this.pearlApi = plugin;
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, Document doc) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(doc, "doc");
//
// try {
// UUID killedBy = UUID.fromString(doc.getString("killer_id"));
// int pearlId = doc.getInteger("pearl_id");
// Location loc = doc.getLocation("location");
// int health = doc.getInteger("health");
// Date pearledOn = doc.getDate("pearled_on", new Date());
// Date lastSeen = doc.getDate("last_seen", new Date());
// boolean freedOffline = doc.getBoolean("freed_offline", false);
// boolean summoned = doc.getBoolean("summoned", false);
// Location returnLoc = doc.getLocation("returnLoc");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedBy, pearlId, new BlockHolder(loc.getBlock()), pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.setPearlType(PearlType.valueOf(doc.getInteger("type", 0)));
// pearl.setHealth(health);
// pearl.setPearledOn(pearledOn);
// pearl.setLastOnline(lastSeen);
// pearl.setFreedOffline(freedOffline);
// pearl.setSummoned(summoned);
// pearl.setReturnLocation(returnLoc);
// pearl.enableStorage();
// return pearl;
//
// } catch(Exception ex) {
// pearlApi.log(Level.SEVERE, "Failed to create pearl for ID=%s, ", uid.toString(), doc);
// return null;
// }
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, Player killedBy, int pearlId) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(killedBy, "killedBy");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedBy.getUniqueId(), pearlId, new PlayerHolder(killedBy), pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.enableStorage();
// return pearl;
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, UUID killedById, int pearlId, PearlHolder holder) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(killedById, "killedById");
// Guard.ArgumentNotNull(holder, "holder");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedById, pearlId, holder, pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.enableStorage();
// return pearl;
// }
//
// @Override
// public ExilePearl createdMigratedPearl(UUID uid, Document doc) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(doc, "doc");
//
// doc.append("health", pearlApi.getPearlConfig().getPearlHealthMaxValue() / 2); // set health to half max health
// return createExilePearl(uid, doc);
// }
//
// public PearlManager createPearlManager() {
// return new CorePearlManager(pearlApi, this, pearlApi.getStorageProvider());
// }
//
// public ExilePearlRunnable createPearlDecayWorker() {
// return new PearlDecayTask(pearlApi);
// }
//
// public SuicideHandler createSuicideHandler() {
// return new PlayerSuicideTask(pearlApi);
// }
//
// public BorderHandler createPearlBorderHandler() {
// return new PearlBoundaryTask(pearlApi);
// }
//
// public BrewHandler createBrewHandler() {
// if (Bukkit.getPluginManager().isPluginEnabled("Brewery")) {
// return new BreweryHandler();
// } else {
// pearlApi.log("Brewery not found, defaulting to no-brew handler");
// return new NoBrewHandler(pearlApi);
// }
// }
//
// public LoreProvider createLoreGenerator() {
// return new CoreLoreGenerator(pearlApi.getPearlConfig());
// }
//
// public PearlConfig createPearlConfig() {
// return new CorePearlConfig(pearlApi, pearlApi);
// }
//
// public DamageLogger createDamageLogger() {
// return new CoreDamageLogger(pearlApi);
// }
// }
|
import java.io.File;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import com.devotedmc.ExilePearl.core.CorePluginFactory;
|
package com.devotedmc.ExilePearl;
/**
* The plugin class for ExilePearl
* <p>
* The meat of the plugin is located in ExilePearlCore.java
*
* @author GordonFreemanQ
*
*/
public final class ExilePearlPlugin extends JavaPlugin {
private static ExilePearlApi core;
public static ExilePearlApi getApi() {
return core;
}
public ExilePearlPlugin() {
|
// Path: src/main/java/com/devotedmc/ExilePearl/core/CorePluginFactory.java
// public final class CorePluginFactory implements PearlFactory {
//
// private final ExilePearlApi pearlApi;
//
// public static ExilePearlApi createCore(final Plugin plugin) {
// return new ExilePearlCore(plugin);
// }
//
// /**
// * Creates a new ExilePearlFactory instance
// * @param plugin The plugin instance
// */
// public CorePluginFactory(final ExilePearlApi plugin) {
// Guard.ArgumentNotNull(plugin, "plugin");
//
// this.pearlApi = plugin;
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, Document doc) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(doc, "doc");
//
// try {
// UUID killedBy = UUID.fromString(doc.getString("killer_id"));
// int pearlId = doc.getInteger("pearl_id");
// Location loc = doc.getLocation("location");
// int health = doc.getInteger("health");
// Date pearledOn = doc.getDate("pearled_on", new Date());
// Date lastSeen = doc.getDate("last_seen", new Date());
// boolean freedOffline = doc.getBoolean("freed_offline", false);
// boolean summoned = doc.getBoolean("summoned", false);
// Location returnLoc = doc.getLocation("returnLoc");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedBy, pearlId, new BlockHolder(loc.getBlock()), pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.setPearlType(PearlType.valueOf(doc.getInteger("type", 0)));
// pearl.setHealth(health);
// pearl.setPearledOn(pearledOn);
// pearl.setLastOnline(lastSeen);
// pearl.setFreedOffline(freedOffline);
// pearl.setSummoned(summoned);
// pearl.setReturnLocation(returnLoc);
// pearl.enableStorage();
// return pearl;
//
// } catch(Exception ex) {
// pearlApi.log(Level.SEVERE, "Failed to create pearl for ID=%s, ", uid.toString(), doc);
// return null;
// }
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, Player killedBy, int pearlId) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(killedBy, "killedBy");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedBy.getUniqueId(), pearlId, new PlayerHolder(killedBy), pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.enableStorage();
// return pearl;
// }
//
// @Override
// public ExilePearl createExilePearl(UUID uid, UUID killedById, int pearlId, PearlHolder holder) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(killedById, "killedById");
// Guard.ArgumentNotNull(holder, "holder");
//
// ExilePearl pearl = new CoreExilePearl(pearlApi, pearlApi.getStorageProvider().getStorage(), uid, killedById, pearlId, holder, pearlApi.getPearlConfig().getDefaultPearlType());
// pearl.enableStorage();
// return pearl;
// }
//
// @Override
// public ExilePearl createdMigratedPearl(UUID uid, Document doc) {
// Guard.ArgumentNotNull(uid, "uid");
// Guard.ArgumentNotNull(doc, "doc");
//
// doc.append("health", pearlApi.getPearlConfig().getPearlHealthMaxValue() / 2); // set health to half max health
// return createExilePearl(uid, doc);
// }
//
// public PearlManager createPearlManager() {
// return new CorePearlManager(pearlApi, this, pearlApi.getStorageProvider());
// }
//
// public ExilePearlRunnable createPearlDecayWorker() {
// return new PearlDecayTask(pearlApi);
// }
//
// public SuicideHandler createSuicideHandler() {
// return new PlayerSuicideTask(pearlApi);
// }
//
// public BorderHandler createPearlBorderHandler() {
// return new PearlBoundaryTask(pearlApi);
// }
//
// public BrewHandler createBrewHandler() {
// if (Bukkit.getPluginManager().isPluginEnabled("Brewery")) {
// return new BreweryHandler();
// } else {
// pearlApi.log("Brewery not found, defaulting to no-brew handler");
// return new NoBrewHandler(pearlApi);
// }
// }
//
// public LoreProvider createLoreGenerator() {
// return new CoreLoreGenerator(pearlApi.getPearlConfig());
// }
//
// public PearlConfig createPearlConfig() {
// return new CorePearlConfig(pearlApi, pearlApi);
// }
//
// public DamageLogger createDamageLogger() {
// return new CoreDamageLogger(pearlApi);
// }
// }
// Path: src/main/java/com/devotedmc/ExilePearl/ExilePearlPlugin.java
import java.io.File;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import com.devotedmc.ExilePearl.core.CorePluginFactory;
package com.devotedmc.ExilePearl;
/**
* The plugin class for ExilePearl
* <p>
* The meat of the plugin is located in ExilePearlCore.java
*
* @author GordonFreemanQ
*
*/
public final class ExilePearlPlugin extends JavaPlugin {
private static ExilePearlApi core;
public static ExilePearlApi getApi() {
return core;
}
public ExilePearlPlugin() {
|
core = CorePluginFactory.createCore(this);
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/config/GotyeTheme.java
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
|
import android.content.Context;
import android.view.View;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
|
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public interface GotyeTheme {
public int getTitileBackgrounId(Context context);
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
// Path: GotyeSDK/src/com/gotye/sdk/config/GotyeTheme.java
import android.content.Context;
import android.view.View;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public interface GotyeTheme {
public int getTitileBackgrounId(Context context);
|
public View createTab(Context context, GotyeTabType type);
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/config/GotyeTheme.java
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
|
import android.content.Context;
import android.view.View;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
|
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public interface GotyeTheme {
public int getTitileBackgrounId(Context context);
public View createTab(Context context, GotyeTabType type);
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
// Path: GotyeSDK/src/com/gotye/sdk/config/GotyeTheme.java
import android.content.Context;
import android.view.View;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public interface GotyeTheme {
public int getTitileBackgrounId(Context context);
public View createTab(Context context, GotyeTabType type);
|
public void onTabSelectedChanged(Context context, GotyeTab tab, boolean select);
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/PullToRefreshExpandableListView.java
|
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java
// public interface EmptyViewMethodAccessor {
//
// /**
// * Calls upto AdapterView.setEmptyView()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyViewInternal(View emptyView);
//
// /**
// * Should call PullToRefreshBase.setEmptyView() which will then
// * automatically call through to setEmptyViewInternal()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyView(View emptyView);
//
// }
|
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ExpandableListView;
import com.gotye.sdk.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor;
|
/*******************************************************************************
* Copyright 2011, 2012 Chris Banes.
*
* 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.gotye.sdk.handmark.pulltorefresh.library;
public class PullToRefreshExpandableListView extends PullToRefreshAdapterViewBase<ExpandableListView> {
public PullToRefreshExpandableListView(Context context) {
super(context);
}
public PullToRefreshExpandableListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PullToRefreshExpandableListView(Context context, Mode mode) {
super(context, mode);
}
public PullToRefreshExpandableListView(Context context, Mode mode, AnimationStyle style) {
super(context, mode, style);
}
@Override
public final Orientation getPullToRefreshScrollDirection() {
return Orientation.VERTICAL;
}
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
final ExpandableListView lv;
if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
lv = new InternalExpandableListViewSDK9(context, attrs);
} else {
lv = new InternalExpandableListView(context, attrs);
}
// Set it to this so it can be used in ListActivity/ListFragment
lv.setId(android.R.id.list);
return lv;
}
|
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java
// public interface EmptyViewMethodAccessor {
//
// /**
// * Calls upto AdapterView.setEmptyView()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyViewInternal(View emptyView);
//
// /**
// * Should call PullToRefreshBase.setEmptyView() which will then
// * automatically call through to setEmptyViewInternal()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyView(View emptyView);
//
// }
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/PullToRefreshExpandableListView.java
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ExpandableListView;
import com.gotye.sdk.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor;
/*******************************************************************************
* Copyright 2011, 2012 Chris Banes.
*
* 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.gotye.sdk.handmark.pulltorefresh.library;
public class PullToRefreshExpandableListView extends PullToRefreshAdapterViewBase<ExpandableListView> {
public PullToRefreshExpandableListView(Context context) {
super(context);
}
public PullToRefreshExpandableListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PullToRefreshExpandableListView(Context context, Mode mode) {
super(context, mode);
}
public PullToRefreshExpandableListView(Context context, Mode mode, AnimationStyle style) {
super(context, mode, style);
}
@Override
public final Orientation getPullToRefreshScrollDirection() {
return Orientation.VERTICAL;
}
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
final ExpandableListView lv;
if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
lv = new InternalExpandableListViewSDK9(context, attrs);
} else {
lv = new InternalExpandableListView(context, attrs);
}
// Set it to this so it can be used in ListActivity/ListFragment
lv.setId(android.R.id.list);
return lv;
}
|
class InternalExpandableListView extends ExpandableListView implements EmptyViewMethodAccessor {
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/ui/adapter/EmotiAdapter.java
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/GraphicsUtil.java
// public class GraphicsUtil {
// final static float scale = Resources.getSystem().getDisplayMetrics().density;
//
// /**
// * Converts DIP to pixels.
// *
// * @param dip
// * the value of the dip.
// * @return the value of the pixels.
// */
// public static int dipToPixel(int dip) {
// return (int) (dip * scale + 0.5f);
// }
//
// public static int pixelToDip(int px) {
// return (int) ((px - 0.5f) / scale);
// }
//
// public static Bitmap drawableToBitmap(Drawable drawable) {
// BitmapDrawable bd = (BitmapDrawable) drawable;
// Bitmap bitmap = bd.getBitmap();
// return bitmap;
// }
//
// public static Drawable BitmapToDrawable(final Bitmap bitmap) {
// BitmapDrawable bd = new BitmapDrawable(bitmap);
// return bd;
// }
//
// /**
// * 通过图片url返回图片Bitmap
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static Bitmap returnBitMap(String path) throws IOException {
// URL url = null;
// Bitmap bitmap = null;
// url = new URL(path);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 利用HttpURLConnection对象,我们可以从网络中获取网页数据.
// conn.setDoInput(true);
// conn.connect();
// InputStream is = conn.getInputStream(); // 得到网络返回的输入流
// bitmap = BitmapFactory.decodeStream(is);
// is.close();
// return bitmap;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/utils/ImageCache.java
// public class ImageCache {
// /**
// * 缓存
// */
// HashMap<String, SoftReference<Bitmap>> cache;
//
// public ImageCache(){
// cache = new HashMap<String, SoftReference<Bitmap>>();
// }
//
// /**
// * 将图片放入内存
// * @param path
// * @param d
// */
// public synchronized void putImage(String path, Bitmap d){
// cache.put(path, new SoftReference<Bitmap>(d));
// }
//
// /**
// * 通过key获取bitmap
// * @param path
// * @return
// */
// public Bitmap getImage(String path){
// SoftReference<Bitmap> value = cache.get(path);
// if(value == null || value.get() == null){
// return null;
// }
// return value.get();
// }
//
// public void clear(){
// cache.clear();
// }
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.utils.GraphicsUtil;
import com.gotye.sdk.utils.ImageCache;
|
package com.gotye.sdk.ui.adapter;
public class EmotiAdapter extends BaseAdapter {
private Context mContext;
private Resources mResources;
private List<Integer> data;
private HashMap<String, Integer> faceMap;
String[] icons;
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/GraphicsUtil.java
// public class GraphicsUtil {
// final static float scale = Resources.getSystem().getDisplayMetrics().density;
//
// /**
// * Converts DIP to pixels.
// *
// * @param dip
// * the value of the dip.
// * @return the value of the pixels.
// */
// public static int dipToPixel(int dip) {
// return (int) (dip * scale + 0.5f);
// }
//
// public static int pixelToDip(int px) {
// return (int) ((px - 0.5f) / scale);
// }
//
// public static Bitmap drawableToBitmap(Drawable drawable) {
// BitmapDrawable bd = (BitmapDrawable) drawable;
// Bitmap bitmap = bd.getBitmap();
// return bitmap;
// }
//
// public static Drawable BitmapToDrawable(final Bitmap bitmap) {
// BitmapDrawable bd = new BitmapDrawable(bitmap);
// return bd;
// }
//
// /**
// * 通过图片url返回图片Bitmap
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static Bitmap returnBitMap(String path) throws IOException {
// URL url = null;
// Bitmap bitmap = null;
// url = new URL(path);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 利用HttpURLConnection对象,我们可以从网络中获取网页数据.
// conn.setDoInput(true);
// conn.connect();
// InputStream is = conn.getInputStream(); // 得到网络返回的输入流
// bitmap = BitmapFactory.decodeStream(is);
// is.close();
// return bitmap;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/utils/ImageCache.java
// public class ImageCache {
// /**
// * 缓存
// */
// HashMap<String, SoftReference<Bitmap>> cache;
//
// public ImageCache(){
// cache = new HashMap<String, SoftReference<Bitmap>>();
// }
//
// /**
// * 将图片放入内存
// * @param path
// * @param d
// */
// public synchronized void putImage(String path, Bitmap d){
// cache.put(path, new SoftReference<Bitmap>(d));
// }
//
// /**
// * 通过key获取bitmap
// * @param path
// * @return
// */
// public Bitmap getImage(String path){
// SoftReference<Bitmap> value = cache.get(path);
// if(value == null || value.get() == null){
// return null;
// }
// return value.get();
// }
//
// public void clear(){
// cache.clear();
// }
// }
// Path: GotyeSDK/src/com/gotye/sdk/ui/adapter/EmotiAdapter.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.utils.GraphicsUtil;
import com.gotye.sdk.utils.ImageCache;
package com.gotye.sdk.ui.adapter;
public class EmotiAdapter extends BaseAdapter {
private Context mContext;
private Resources mResources;
private List<Integer> data;
private HashMap<String, Integer> faceMap;
String[] icons;
|
ImageCache cache;
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/ui/adapter/EmotiAdapter.java
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/GraphicsUtil.java
// public class GraphicsUtil {
// final static float scale = Resources.getSystem().getDisplayMetrics().density;
//
// /**
// * Converts DIP to pixels.
// *
// * @param dip
// * the value of the dip.
// * @return the value of the pixels.
// */
// public static int dipToPixel(int dip) {
// return (int) (dip * scale + 0.5f);
// }
//
// public static int pixelToDip(int px) {
// return (int) ((px - 0.5f) / scale);
// }
//
// public static Bitmap drawableToBitmap(Drawable drawable) {
// BitmapDrawable bd = (BitmapDrawable) drawable;
// Bitmap bitmap = bd.getBitmap();
// return bitmap;
// }
//
// public static Drawable BitmapToDrawable(final Bitmap bitmap) {
// BitmapDrawable bd = new BitmapDrawable(bitmap);
// return bd;
// }
//
// /**
// * 通过图片url返回图片Bitmap
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static Bitmap returnBitMap(String path) throws IOException {
// URL url = null;
// Bitmap bitmap = null;
// url = new URL(path);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 利用HttpURLConnection对象,我们可以从网络中获取网页数据.
// conn.setDoInput(true);
// conn.connect();
// InputStream is = conn.getInputStream(); // 得到网络返回的输入流
// bitmap = BitmapFactory.decodeStream(is);
// is.close();
// return bitmap;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/utils/ImageCache.java
// public class ImageCache {
// /**
// * 缓存
// */
// HashMap<String, SoftReference<Bitmap>> cache;
//
// public ImageCache(){
// cache = new HashMap<String, SoftReference<Bitmap>>();
// }
//
// /**
// * 将图片放入内存
// * @param path
// * @param d
// */
// public synchronized void putImage(String path, Bitmap d){
// cache.put(path, new SoftReference<Bitmap>(d));
// }
//
// /**
// * 通过key获取bitmap
// * @param path
// * @return
// */
// public Bitmap getImage(String path){
// SoftReference<Bitmap> value = cache.get(path);
// if(value == null || value.get() == null){
// return null;
// }
// return value.get();
// }
//
// public void clear(){
// cache.clear();
// }
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.utils.GraphicsUtil;
import com.gotye.sdk.utils.ImageCache;
|
this.mContext = context;
this.mResources = resources;
cache = new ImageCache();
data = new ArrayList<Integer>();
faceMap = new HashMap<String, Integer>();
Resources rs = resources;
TypedArray ty = rs.obtainTypedArray(R.array.gotye_smiley_resid_array);
icons = rs.getStringArray(R.array.gotye_smiley_resid_array);
for(int i = 0;i < icons.length;i++){
data.add(ty.getResourceId(i, R.drawable.gotye_smiley_1));
faceMap.put(icons[i], ty.getResourceId(i, R.drawable.gotye_smiley_1));
}
ty.recycle();
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i;
if (convertView == null) {
i = new ImageView(mContext);
i.setAdjustViewBounds(true);
i.setLayoutParams(new GridView.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} else {
i = (ImageView) convertView;
}
Bitmap d = cache.getImage(String.valueOf(position));
if(d == null){
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/GraphicsUtil.java
// public class GraphicsUtil {
// final static float scale = Resources.getSystem().getDisplayMetrics().density;
//
// /**
// * Converts DIP to pixels.
// *
// * @param dip
// * the value of the dip.
// * @return the value of the pixels.
// */
// public static int dipToPixel(int dip) {
// return (int) (dip * scale + 0.5f);
// }
//
// public static int pixelToDip(int px) {
// return (int) ((px - 0.5f) / scale);
// }
//
// public static Bitmap drawableToBitmap(Drawable drawable) {
// BitmapDrawable bd = (BitmapDrawable) drawable;
// Bitmap bitmap = bd.getBitmap();
// return bitmap;
// }
//
// public static Drawable BitmapToDrawable(final Bitmap bitmap) {
// BitmapDrawable bd = new BitmapDrawable(bitmap);
// return bd;
// }
//
// /**
// * 通过图片url返回图片Bitmap
// *
// * @param url
// * @return
// * @throws IOException
// */
// public static Bitmap returnBitMap(String path) throws IOException {
// URL url = null;
// Bitmap bitmap = null;
// url = new URL(path);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 利用HttpURLConnection对象,我们可以从网络中获取网页数据.
// conn.setDoInput(true);
// conn.connect();
// InputStream is = conn.getInputStream(); // 得到网络返回的输入流
// bitmap = BitmapFactory.decodeStream(is);
// is.close();
// return bitmap;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/utils/ImageCache.java
// public class ImageCache {
// /**
// * 缓存
// */
// HashMap<String, SoftReference<Bitmap>> cache;
//
// public ImageCache(){
// cache = new HashMap<String, SoftReference<Bitmap>>();
// }
//
// /**
// * 将图片放入内存
// * @param path
// * @param d
// */
// public synchronized void putImage(String path, Bitmap d){
// cache.put(path, new SoftReference<Bitmap>(d));
// }
//
// /**
// * 通过key获取bitmap
// * @param path
// * @return
// */
// public Bitmap getImage(String path){
// SoftReference<Bitmap> value = cache.get(path);
// if(value == null || value.get() == null){
// return null;
// }
// return value.get();
// }
//
// public void clear(){
// cache.clear();
// }
// }
// Path: GotyeSDK/src/com/gotye/sdk/ui/adapter/EmotiAdapter.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.utils.GraphicsUtil;
import com.gotye.sdk.utils.ImageCache;
this.mContext = context;
this.mResources = resources;
cache = new ImageCache();
data = new ArrayList<Integer>();
faceMap = new HashMap<String, Integer>();
Resources rs = resources;
TypedArray ty = rs.obtainTypedArray(R.array.gotye_smiley_resid_array);
icons = rs.getStringArray(R.array.gotye_smiley_resid_array);
for(int i = 0;i < icons.length;i++){
data.add(ty.getResourceId(i, R.drawable.gotye_smiley_1));
faceMap.put(icons[i], ty.getResourceId(i, R.drawable.gotye_smiley_1));
}
ty.recycle();
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i;
if (convertView == null) {
i = new ImageView(mContext);
i.setAdjustViewBounds(true);
i.setLayoutParams(new GridView.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} else {
i = (ImageView) convertView;
}
Bitmap d = cache.getImage(String.valueOf(position));
if(d == null){
|
d = GraphicsUtil.drawableToBitmap(mResources.getDrawable(data.get(position)));
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/ui/fragment/adapter/GotyeMsgBoxAdapter.java
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/ObjectValuePair.java
// public class ObjectValuePair<Key, Value> {
// public Key name;
// public Value value;
// }
|
import java.util.List;
import java.util.Map;
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.gotye.sdk.R;
import com.gotye.sdk.logic.beans.GotyeMsgInfo;
import com.gotye.sdk.utils.ObjectValuePair;
|
package com.gotye.sdk.ui.fragment.adapter;
/**
* Created by lhxia on 13-12-25.
*/
public class GotyeMsgBoxAdapter extends BaseExpandableListAdapter {
private Context mContext;
|
// Path: GotyeSDK/src/com/gotye/sdk/utils/ObjectValuePair.java
// public class ObjectValuePair<Key, Value> {
// public Key name;
// public Value value;
// }
// Path: GotyeSDK/src/com/gotye/sdk/ui/fragment/adapter/GotyeMsgBoxAdapter.java
import java.util.List;
import java.util.Map;
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.gotye.sdk.R;
import com.gotye.sdk.logic.beans.GotyeMsgInfo;
import com.gotye.sdk.utils.ObjectValuePair;
package com.gotye.sdk.ui.fragment.adapter;
/**
* Created by lhxia on 13-12-25.
*/
public class GotyeMsgBoxAdapter extends BaseExpandableListAdapter {
private Context mContext;
|
private List<ObjectValuePair<Map<String, String>, List<GotyeMsgInfo>>> msgBox;
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/ui/fragment/FragmentHolder.java
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
|
import android.support.v4.app.Fragment;
import com.gotye.sdk.ui.view.tab.GotyeTab;
|
package com.gotye.sdk.ui.fragment;
/**
* Created by lhxia on 13-12-24.
*/
public class FragmentHolder {
private Fragment mFragment;
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
// Path: GotyeSDK/src/com/gotye/sdk/ui/fragment/FragmentHolder.java
import android.support.v4.app.Fragment;
import com.gotye.sdk.ui.view.tab.GotyeTab;
package com.gotye.sdk.ui.fragment;
/**
* Created by lhxia on 13-12-24.
*/
public class FragmentHolder {
private Fragment mFragment;
|
private GotyeTab mTab;
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/config/DefaultTheme.java
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
|
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.exceptions.UnSupportClientModeError;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
|
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public class DefaultTheme implements GotyeTheme{
@Override
public int getTitileBackgrounId(Context context) {
return 0;
}
@Override
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
// Path: GotyeSDK/src/com/gotye/sdk/config/DefaultTheme.java
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.exceptions.UnSupportClientModeError;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public class DefaultTheme implements GotyeTheme{
@Override
public int getTitileBackgrounId(Context context) {
return 0;
}
@Override
|
public View createTab(Context context, GotyeTabType type) {
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/config/DefaultTheme.java
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
|
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.exceptions.UnSupportClientModeError;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
|
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public class DefaultTheme implements GotyeTheme{
@Override
public int getTitileBackgrounId(Context context) {
return 0;
}
@Override
public View createTab(Context context, GotyeTabType type) {
ImageView tab = new ImageView(context);
tab.setClickable(true);
tab.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
switch (type){
case ROOM:
tab.setImageResource(R.drawable.gotye_bg_tab_room_selected);
break;
case CONTACT:
tab.setImageResource(R.drawable.gotye_bg_tab_contact_selected);
break;
case MSG_BOX:
tab.setImageResource(R.drawable.gotye_bg_tab_msgbox_selected);
break;
default:
throw new UnSupportClientModeError("unknown tab type --> " + type);
}
return tab;
}
@Override
|
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTab.java
// public class GotyeTab {
//
// private GotyeTabType mType;
// /**
// * tab's view for showing
// */
// private View mContentView;
//
// private GotyeTabHostSelectListener mSelectListener;
//
// /**
// * just hold the page references, may be null
// */
// private Fragment mBindFragment;
//
// /**
// * tab selected state
// */
// boolean mSelected = false;
//
// public GotyeTab(GotyeTabType type, View mContentView, GotyeTabHostSelectListener mSelectListener) {
// this.mType = type;
// this.mContentView = mContentView;
// this.mSelectListener = mSelectListener;
// mContentView.setTag(this);
// }
//
// public View getContentView() {
// return mContentView;
// }
//
// public GotyeTabHostSelectListener getSelectListener() {
// return mSelectListener;
// }
//
// public boolean isSelected() {
// return mSelected;
// }
//
// public Fragment getBindFragment() {
// return mBindFragment;
// }
//
// public void setBindFragment(Fragment mBindFragment) {
// this.mBindFragment = mBindFragment;
// }
//
// public GotyeTabType getType() {
// return mType;
// }
// }
//
// Path: GotyeSDK/src/com/gotye/sdk/ui/view/tab/GotyeTabType.java
// public enum GotyeTabType {
//
// ROOM,
// CONTACT,
// MSG_BOX;
// }
// Path: GotyeSDK/src/com/gotye/sdk/config/DefaultTheme.java
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.gotye.sdk.R;
import com.gotye.sdk.exceptions.UnSupportClientModeError;
import com.gotye.sdk.ui.view.tab.GotyeTab;
import com.gotye.sdk.ui.view.tab.GotyeTabType;
package com.gotye.sdk.config;
/**
* Created by lhxia on 13-12-24.
*/
public class DefaultTheme implements GotyeTheme{
@Override
public int getTitileBackgrounId(Context context) {
return 0;
}
@Override
public View createTab(Context context, GotyeTabType type) {
ImageView tab = new ImageView(context);
tab.setClickable(true);
tab.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
switch (type){
case ROOM:
tab.setImageResource(R.drawable.gotye_bg_tab_room_selected);
break;
case CONTACT:
tab.setImageResource(R.drawable.gotye_bg_tab_contact_selected);
break;
case MSG_BOX:
tab.setImageResource(R.drawable.gotye_bg_tab_msgbox_selected);
break;
default:
throw new UnSupportClientModeError("unknown tab type --> " + type);
}
return tab;
}
@Override
|
public void onTabSelectedChanged(Context context, GotyeTab tab, boolean select) {
|
Gotye-QPlus/GotyeSDK-Android
|
GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/PullToRefreshListView.java
|
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java
// public interface EmptyViewMethodAccessor {
//
// /**
// * Calls upto AdapterView.setEmptyView()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyViewInternal(View emptyView);
//
// /**
// * Should call PullToRefreshBase.setEmptyView() which will then
// * automatically call through to setEmptyViewInternal()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyView(View emptyView);
//
// }
|
import com.gotye.sdk.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor;
import com.gotye.sdk.handmark.pulltorefresh.library.internal.LoadingLayout;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.gotye.sdk.R;
|
* If the value for Scrolling While Refreshing hasn't been
* explicitly set via XML, enable Scrolling While Refreshing.
*/
if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
setScrollingWhileRefreshingEnabled(true);
}
}
}
@TargetApi(9)
final class InternalListViewSDK9 extends InternalListView {
public InternalListViewSDK9(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX,
int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX,
scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
// Does all of the hard work...
// OverscrollHelper.overScrollBy(PullToRefreshListView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent);
return returnValue;
}
}
|
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java
// public interface EmptyViewMethodAccessor {
//
// /**
// * Calls upto AdapterView.setEmptyView()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyViewInternal(View emptyView);
//
// /**
// * Should call PullToRefreshBase.setEmptyView() which will then
// * automatically call through to setEmptyViewInternal()
// *
// * @param emptyView - to set as Empty View
// */
// public void setEmptyView(View emptyView);
//
// }
// Path: GotyeSDK/src/com/gotye/sdk/handmark/pulltorefresh/library/PullToRefreshListView.java
import com.gotye.sdk.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor;
import com.gotye.sdk.handmark.pulltorefresh.library.internal.LoadingLayout;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.gotye.sdk.R;
* If the value for Scrolling While Refreshing hasn't been
* explicitly set via XML, enable Scrolling While Refreshing.
*/
if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
setScrollingWhileRefreshingEnabled(true);
}
}
}
@TargetApi(9)
final class InternalListViewSDK9 extends InternalListView {
public InternalListViewSDK9(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX,
int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX,
scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
// Does all of the hard work...
// OverscrollHelper.overScrollBy(PullToRefreshListView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent);
return returnValue;
}
}
|
protected class InternalListView extends ListView implements EmptyViewMethodAccessor {
|
aschaaff/savot
|
src/test/java/tests/sax/TestSAX.java
|
// Path: src/main/java/cds/astrores/sax/AstroresSAXParser.java
// @SuppressWarnings({"deprecation", "UseOfSystemOutOrSystemErr"})
// public class AstroresSAXParser {
//
// // the pull parser engine
// private AstroresSAXEngine engine = null;
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param file
// * a file to parse
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, String file) {
// this(consumer, file, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param file
// * a file to parse
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, String file,
// boolean debug) {
//
// try {
// // new parser
// XmlPullParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, file, debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param url
// * url to parse
// * @param enc
// * encoding (example : UTF-8)
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc) {
// this(consumer, url, enc, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param url
// * url to parse
// * @param enc
// * encoding (example : UTF-8)
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc,
// boolean debug) {
//
// try {
// // new parser
// KXmlParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, url, enc, debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param instream
// * stream to parse
// * @param enc
// * encoding (example : UTF-8)
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer,
// InputStream instream, String enc) {
// this(consumer, instream, enc, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param instream
// * stream to parse
// * @param enc
// * encoding (example : UTF-8)
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer,
// InputStream instream, String enc, boolean debug) {
// try {
// // new parser
// KXmlParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, instream, enc,
// debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Main
// *
// * @param argv
// * @throws IOException
// */
// public static void main(String[] argv) throws IOException {
//
// if (argv.length == 0) {
// System.err.println("Usage: java AstroresSAXParser <xml document>");
// } else {
// // new AstroresSAXParser(argv[0]);
// }
// }
// }
|
import java.io.IOException;
import cds.astrores.sax.AstroresSAXParser;
|
package tests.sax;
//Copyright 2002-2014 - UDS/CNRS
//The SAVOT library is distributed under the terms
//of the GNU General Public License version 3.
//
//This file is part of SAVOT.
//
// SAVOT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// SAVOT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The GNU General Public License is available in COPYING file
// along with SAVOT.
//
//SAVOT - Simple Access to VOTable - Parser
//
//Author, Co-Author: Andre Schaaff (CDS), Laurent Bourges (JMMC)
/**
* <p>
* Astrores SAX Parser Tester, a sample designed to show the SAX usage of the
* parser
* </p>
* @author Andre Schaaff
*/
public class TestSAX {
static long freeMemory = 0;
static long freeMemory2 = 0;
public static boolean statistics = true;
/**
* Constructor
*
* @param file
*/
public TestSAX(String file) {
try {
System.err.println("Total memory : "
+ Runtime.getRuntime().totalMemory());
freeMemory = Runtime.getRuntime().freeMemory();
System.err.println("Free memory (Begin) : " + freeMemory);
AstroresSAXSample consumer = new AstroresSAXSample();
@SuppressWarnings("unused")
|
// Path: src/main/java/cds/astrores/sax/AstroresSAXParser.java
// @SuppressWarnings({"deprecation", "UseOfSystemOutOrSystemErr"})
// public class AstroresSAXParser {
//
// // the pull parser engine
// private AstroresSAXEngine engine = null;
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param file
// * a file to parse
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, String file) {
// this(consumer, file, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param file
// * a file to parse
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, String file,
// boolean debug) {
//
// try {
// // new parser
// XmlPullParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, file, debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param url
// * url to parse
// * @param enc
// * encoding (example : UTF-8)
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc) {
// this(consumer, url, enc, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param url
// * url to parse
// * @param enc
// * encoding (example : UTF-8)
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer, URL url, String enc,
// boolean debug) {
//
// try {
// // new parser
// KXmlParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, url, enc, debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param instream
// * stream to parse
// * @param enc
// * encoding (example : UTF-8)
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer,
// InputStream instream, String enc) {
// this(consumer, instream, enc, false);
// }
//
// /**
// * Constructor
// *
// * @param consumer
// * AstroresSAXConsumer
// * @param instream
// * stream to parse
// * @param enc
// * encoding (example : UTF-8)
// * @param debug
// * boolean
// */
// public AstroresSAXParser(AstroresSAXConsumer consumer,
// InputStream instream, String enc, boolean debug) {
// try {
// // new parser
// KXmlParser parser = new KXmlParser();
//
// engine = new AstroresSAXEngine(consumer, parser, instream, enc,
// debug);
//
// engine.parse(parser);
//
// } catch (IOException e) {
// System.err.println("AstroresSAXParser : " + e);
// } catch (Exception f) {
// System.err.println("AstroresSAXParser : " + f);
// }
// }
//
// /**
// * Main
// *
// * @param argv
// * @throws IOException
// */
// public static void main(String[] argv) throws IOException {
//
// if (argv.length == 0) {
// System.err.println("Usage: java AstroresSAXParser <xml document>");
// } else {
// // new AstroresSAXParser(argv[0]);
// }
// }
// }
// Path: src/test/java/tests/sax/TestSAX.java
import java.io.IOException;
import cds.astrores.sax.AstroresSAXParser;
package tests.sax;
//Copyright 2002-2014 - UDS/CNRS
//The SAVOT library is distributed under the terms
//of the GNU General Public License version 3.
//
//This file is part of SAVOT.
//
// SAVOT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// SAVOT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The GNU General Public License is available in COPYING file
// along with SAVOT.
//
//SAVOT - Simple Access to VOTable - Parser
//
//Author, Co-Author: Andre Schaaff (CDS), Laurent Bourges (JMMC)
/**
* <p>
* Astrores SAX Parser Tester, a sample designed to show the SAX usage of the
* parser
* </p>
* @author Andre Schaaff
*/
public class TestSAX {
static long freeMemory = 0;
static long freeMemory2 = 0;
public static boolean statistics = true;
/**
* Constructor
*
* @param file
*/
public TestSAX(String file) {
try {
System.err.println("Total memory : "
+ Runtime.getRuntime().totalMemory());
freeMemory = Runtime.getRuntime().freeMemory();
System.err.println("Free memory (Begin) : " + freeMemory);
AstroresSAXSample consumer = new AstroresSAXSample();
@SuppressWarnings("unused")
|
AstroresSAXParser sb = new AstroresSAXParser(consumer, file);
|
aschaaff/savot
|
src/main/java/cds/savot/binary/SavotDataWriter.java
|
// Path: src/main/java/cds/savot/model/SavotTR.java
// public final class SavotTR extends SavotBase {
//
// // TR element set
// private TDSet TDs = null;
// private int lineInXMLFile = 0;
//
// /**
// * Constructor
// */
// public SavotTR() {
// }
//
// /**
// * Create a TR element from a Separated Value String
// *
// * @param svline
// * String, line with separated values
// * @param sv
// * char, separated value
// */
// public void SVtoTR(final String svline, final char sv) {
// String line = svline;
//
// int index;
// String token;
// TDs = new TDSet();
// // cut sv following the separator
//
// // tabulation
// do {
// if ((index = line.indexOf(sv)) >= 0) {
// token = line.substring(0, index);
// line = line.substring(index + 1);
// } else {
// // last element
// token = line;
// }
// SavotTD td = new SavotTD();
// td.setContent(token);
// TDs.addItem(td);
// } while (index >= 0);
// }
//
// /**
// * Get the TD set (same as getTDSet) TDSet
// *
// * @return TDSet
// */
// public TDSet getTDs() {
// if (TDs == null) {
// TDs = new TDSet();
// }
// return TDs;
// }
//
// /**
// * Get the TD set (same as getTDs) TDSet
// * @param capacity minimal capacity to provide
// * @return TDSet
// */
// public TDSet getTDSet(final int capacity) {
// if (TDs == null) {
// TDs = new TDSet();
// TDs.ensureCapacity(capacity);
// }
// return TDs;
// }
//
// /**
// * Get the TD set (same as getTDs) TDSet
// * @see #getTDSet(int)
// *
// * @return TDSet
// */
// public TDSet getTDSet() {
// if (TDs == null) {
// TDs = new TDSet();
// }
// return TDs;
// }
//
// /**
// * Set the TD set (same as setTDSet) TDSet
// *
// * @param TDs
// */
// public void setTDs(final TDSet TDs) {
// this.TDs = TDs;
// }
//
// /**
// * Set the TD set (same as setTDs) TDSet
// *
// * @param TDs
// */
// public void setTDSet(final TDSet TDs) {
// this.TDs = TDs;
// }
//
// /**
// * Get the corresponding line in the XML file or flow
// *
// * @return lineInXMLFile
// */
// public int getLineInXMLFile() {
// return lineInXMLFile;
// }
//
// /**
// * Set the corresponding line in the XML file or flow during the parsing
// *
// * @param lineInXMLFile
// */
// public void setLineInXMLFile(final int lineInXMLFile) {
// this.lineInXMLFile = lineInXMLFile;
// }
//
// /**
// * Clear this TR instance to recycle it
// */
// public void clear() {
// if (TDs != null) {
// TDs.removeAllItems(); // recycle TDSet (same capacity)
// }
// lineInXMLFile = 0;
// }
// }
//
// Path: src/main/java/cds/savot/model/TRSet.java
// public final class TRSet extends SavotSet<SavotTR> {
//
// /**
// * Constructor
// */
// public TRSet() {
// }
//
// /**
// * Get a TDSet object at the TRIndex position of the TRSet
// *
// * @param TRIndex
// * @return TDSet
// */
// public TDSet getTDSet(final int TRIndex) {
// if (this.getItemCount() != 0) {
// return getItemAt(TRIndex).getTDSet();
// }
// return new TDSet();
// }
// }
|
import cds.savot.model.SavotTR;
import cds.savot.model.TRSet;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
|
package cds.savot.binary;
//Copyright 2002-2014 - UDS/CNRS
//The SAVOT library is distributed under the terms
//of the GNU General Public License version 3.
//
//This file is part of SAVOT.
//
// SAVOT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// SAVOT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The GNU General Public License is available in COPYING file
// along with SAVOT.
//
//SAVOT - Simple Access to VOTable - Parser
//
//Author, Co-Author: Andre Schaaff (CDS), Laurent Bourges (LAOG)
/**
* Common interface of a writer of the data of a VOTable DATA node
* (whatever is its child node: FITS, BINARY or TABLEDATA).
*
* @author Gregory Mantelet
* @since 09/2011
*/
public interface SavotDataWriter extends Closeable, Flushable {
/**
* Writes the given row.
*
* @param row Row to write.
*
* @throws IOException If there is an error while writing the given row.
*/
public void writeTR(SavotTR row) throws IOException;
/**
* Writes the given rows.
*
* @param rows Rows to write.
*
* @throws IOException If there is an error while writing the given rows.
*/
|
// Path: src/main/java/cds/savot/model/SavotTR.java
// public final class SavotTR extends SavotBase {
//
// // TR element set
// private TDSet TDs = null;
// private int lineInXMLFile = 0;
//
// /**
// * Constructor
// */
// public SavotTR() {
// }
//
// /**
// * Create a TR element from a Separated Value String
// *
// * @param svline
// * String, line with separated values
// * @param sv
// * char, separated value
// */
// public void SVtoTR(final String svline, final char sv) {
// String line = svline;
//
// int index;
// String token;
// TDs = new TDSet();
// // cut sv following the separator
//
// // tabulation
// do {
// if ((index = line.indexOf(sv)) >= 0) {
// token = line.substring(0, index);
// line = line.substring(index + 1);
// } else {
// // last element
// token = line;
// }
// SavotTD td = new SavotTD();
// td.setContent(token);
// TDs.addItem(td);
// } while (index >= 0);
// }
//
// /**
// * Get the TD set (same as getTDSet) TDSet
// *
// * @return TDSet
// */
// public TDSet getTDs() {
// if (TDs == null) {
// TDs = new TDSet();
// }
// return TDs;
// }
//
// /**
// * Get the TD set (same as getTDs) TDSet
// * @param capacity minimal capacity to provide
// * @return TDSet
// */
// public TDSet getTDSet(final int capacity) {
// if (TDs == null) {
// TDs = new TDSet();
// TDs.ensureCapacity(capacity);
// }
// return TDs;
// }
//
// /**
// * Get the TD set (same as getTDs) TDSet
// * @see #getTDSet(int)
// *
// * @return TDSet
// */
// public TDSet getTDSet() {
// if (TDs == null) {
// TDs = new TDSet();
// }
// return TDs;
// }
//
// /**
// * Set the TD set (same as setTDSet) TDSet
// *
// * @param TDs
// */
// public void setTDs(final TDSet TDs) {
// this.TDs = TDs;
// }
//
// /**
// * Set the TD set (same as setTDs) TDSet
// *
// * @param TDs
// */
// public void setTDSet(final TDSet TDs) {
// this.TDs = TDs;
// }
//
// /**
// * Get the corresponding line in the XML file or flow
// *
// * @return lineInXMLFile
// */
// public int getLineInXMLFile() {
// return lineInXMLFile;
// }
//
// /**
// * Set the corresponding line in the XML file or flow during the parsing
// *
// * @param lineInXMLFile
// */
// public void setLineInXMLFile(final int lineInXMLFile) {
// this.lineInXMLFile = lineInXMLFile;
// }
//
// /**
// * Clear this TR instance to recycle it
// */
// public void clear() {
// if (TDs != null) {
// TDs.removeAllItems(); // recycle TDSet (same capacity)
// }
// lineInXMLFile = 0;
// }
// }
//
// Path: src/main/java/cds/savot/model/TRSet.java
// public final class TRSet extends SavotSet<SavotTR> {
//
// /**
// * Constructor
// */
// public TRSet() {
// }
//
// /**
// * Get a TDSet object at the TRIndex position of the TRSet
// *
// * @param TRIndex
// * @return TDSet
// */
// public TDSet getTDSet(final int TRIndex) {
// if (this.getItemCount() != 0) {
// return getItemAt(TRIndex).getTDSet();
// }
// return new TDSet();
// }
// }
// Path: src/main/java/cds/savot/binary/SavotDataWriter.java
import cds.savot.model.SavotTR;
import cds.savot.model.TRSet;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
package cds.savot.binary;
//Copyright 2002-2014 - UDS/CNRS
//The SAVOT library is distributed under the terms
//of the GNU General Public License version 3.
//
//This file is part of SAVOT.
//
// SAVOT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// SAVOT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The GNU General Public License is available in COPYING file
// along with SAVOT.
//
//SAVOT - Simple Access to VOTable - Parser
//
//Author, Co-Author: Andre Schaaff (CDS), Laurent Bourges (LAOG)
/**
* Common interface of a writer of the data of a VOTable DATA node
* (whatever is its child node: FITS, BINARY or TABLEDATA).
*
* @author Gregory Mantelet
* @since 09/2011
*/
public interface SavotDataWriter extends Closeable, Flushable {
/**
* Writes the given row.
*
* @param row Row to write.
*
* @throws IOException If there is an error while writing the given row.
*/
public void writeTR(SavotTR row) throws IOException;
/**
* Writes the given rows.
*
* @param rows Rows to write.
*
* @throws IOException If there is an error while writing the given rows.
*/
|
public void writeTRSet(TRSet rows) throws IOException;
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Attachment.java
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONObject;
import org.json.JSONException;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
public class Attachment extends Payload
{
private JSONObject data;
private static final String URL = "url";
private static final String FILENAME = "filename";
private static final String MIMETYPE = "mime_type";
/**
* @param url full URL to a resource i.e. http://example.com/image.jpg
* @param filename name of the file i.e. image.jpg
* @param mimeType mime Type of the resource i.e. image/jpg
* @throws GengoException
*/
public Attachment(String url, String filename, String mimeType)
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Attachment.java
import org.json.JSONObject;
import org.json.JSONException;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
public class Attachment extends Payload
{
private JSONObject data;
private static final String URL = "url";
private static final String FILENAME = "filename";
private static final String MIMETYPE = "mime_type";
/**
* @param url full URL to a resource i.e. http://example.com/image.jpg
* @param filename name of the file i.e. image.jpg
* @param mimeType mime Type of the resource i.e. image/jpg
* @throws GengoException
*/
public Attachment(String url, String filename, String mimeType)
|
throws GengoException
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Payloads.java
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import java.util.List;
import org.json.JSONArray;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* A collection of payload objects.
*/
public class Payloads
{
private JSONArray arr;
/**
* Initialize an empty collection.
*/
public Payloads()
{
arr = new JSONArray();
}
/**
* Initialize a collection of payloads from a List collection
* @param payloads
* @throws GengoException
*/
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Payloads.java
import java.util.List;
import org.json.JSONArray;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* A collection of payload objects.
*/
public class Payloads
{
private JSONArray arr;
/**
* Initialize an empty collection.
*/
public Payloads()
{
arr = new JSONArray();
}
/**
* Initialize a collection of payloads from a List collection
* @param payloads
* @throws GengoException
*/
|
public Payloads(List<Payload> payloads) throws GengoException
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Payload.java
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONObject;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
public abstract class Payload
{
/**
* Create a JSONObject representing this payload object
* @return the JSONObject created
* @throws GengoException
*/
|
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Payload.java
import org.json.JSONObject;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
public abstract class Payload
{
/**
* Create a JSONObject representing this payload object
* @return the JSONObject created
* @throws GengoException
*/
|
public abstract JSONObject toJSONObject() throws GengoException;
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Revision.java
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Job revision payload
*/
public class Revision extends JobUpdate
{
private String comment;
public Revision(int jobId, String comment)
{
super(jobId);
init(comment);
}
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Revision.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Job revision payload
*/
public class Revision extends JobUpdate
{
private String comment;
public Revision(int jobId, String comment)
{
super(jobId);
init(comment);
}
|
public Revision(String lc_src, String lc_tgt, String body_src, Tier tier, String comment)
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Revision.java
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Job revision payload
*/
public class Revision extends JobUpdate
{
private String comment;
public Revision(int jobId, String comment)
{
super(jobId);
init(comment);
}
public Revision(String lc_src, String lc_tgt, String body_src, Tier tier, String comment)
{
super(lc_src, lc_tgt, body_src, tier);
init(comment);
}
private void init(String comment)
{
this.comment = comment;
}
/**
* Create a JSONObject representing this rejection
* @return the JSONObject created
* @throws GengoException
*/
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Revision.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Job revision payload
*/
public class Revision extends JobUpdate
{
private String comment;
public Revision(int jobId, String comment)
{
super(jobId);
init(comment);
}
public Revision(String lc_src, String lc_tgt, String body_src, Tier tier, String comment)
{
super(lc_src, lc_tgt, body_src, tier);
init(comment);
}
private void init(String comment)
{
this.comment = comment;
}
/**
* Create a JSONObject representing this rejection
* @return the JSONObject created
* @throws GengoException
*/
|
public JSONObject toJSONObject() throws GengoException
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Rejection.java
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Rejection.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
|
private RejectReason reason;
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Rejection.java
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
private RejectReason reason;
private String comment;
private String captcha;
private boolean requeue;
public Rejection(int jobId, RejectReason reason, String comment, String captcha, boolean requeue)
{
super(jobId);
init(reason, comment, captcha, requeue);
}
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Rejection.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
private RejectReason reason;
private String comment;
private String captcha;
private boolean requeue;
public Rejection(int jobId, RejectReason reason, String comment, String captcha, boolean requeue)
{
super(jobId);
init(reason, comment, captcha, requeue);
}
|
public Rejection(String lc_src, String lc_tgt, String body_src, Tier tier,
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/Rejection.java
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
private RejectReason reason;
private String comment;
private String captcha;
private boolean requeue;
public Rejection(int jobId, RejectReason reason, String comment, String captcha, boolean requeue)
{
super(jobId);
init(reason, comment, captcha, requeue);
}
public Rejection(String lc_src, String lc_tgt, String body_src, Tier tier,
RejectReason reason, String comment, String captcha, boolean requeue)
{
super(lc_src, lc_tgt, body_src, tier);
init(reason, comment, captcha, requeue);
}
private void init(RejectReason reason, String comment, String captcha, boolean requeue)
{
this.reason = reason;
this.comment = comment;
this.captcha = captcha;
this.requeue = requeue;
}
/**
* Create a JSONObject representing this rejection
* @return the JSONObject created
* @throws GengoException
*/
|
// Path: src/main/java/com/gengo/client/enums/RejectReason.java
// public enum RejectReason
// {
// QUALITY,
// INCOMPLETE,
// OTHER
// };
//
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/Rejection.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.RejectReason;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Job rejection payload
*/
public class Rejection extends JobUpdate
{
private RejectReason reason;
private String comment;
private String captcha;
private boolean requeue;
public Rejection(int jobId, RejectReason reason, String comment, String captcha, boolean requeue)
{
super(jobId);
init(reason, comment, captcha, requeue);
}
public Rejection(String lc_src, String lc_tgt, String body_src, Tier tier,
RejectReason reason, String comment, String captcha, boolean requeue)
{
super(lc_src, lc_tgt, body_src, tier);
init(reason, comment, captcha, requeue);
}
private void init(RejectReason reason, String comment, String captcha, boolean requeue)
{
this.reason = reason;
this.comment = comment;
this.captcha = captcha;
this.requeue = requeue;
}
/**
* Create a JSONObject representing this rejection
* @return the JSONObject created
* @throws GengoException
*/
|
public JSONObject toJSONObject() throws GengoException
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/JobUpdate.java
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Abstract base class for update payloads
*/
public abstract class JobUpdate extends Payload
{
private int jobId = 0;
private String lcSrc;
private String lcTgt;
private String bodySrc;
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/JobUpdate.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Abstract base class for update payloads
*/
public abstract class JobUpdate extends Payload
{
private int jobId = 0;
private String lcSrc;
private String lcTgt;
private String bodySrc;
|
private Tier tier;
|
gengo/gengo-java
|
src/main/java/com/gengo/client/payloads/JobUpdate.java
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
|
package com.gengo.client.payloads;
/**
* Abstract base class for update payloads
*/
public abstract class JobUpdate extends Payload
{
private int jobId = 0;
private String lcSrc;
private String lcTgt;
private String bodySrc;
private Tier tier;
/**
* Create a job update payload identified by job ID
* @param jobId
*/
public JobUpdate(int jobId)
{
this.jobId = jobId;
}
/**
* Create a job update payload identified by source and target languages, text body and tier
* @param lcSrc
* @param lcTgt
* @param bodySrc
* @param tier
*/
public JobUpdate(String lcSrc, String lcTgt, String bodySrc, Tier tier)
{
this.jobId = 0;
this.lcSrc = lcSrc;
this.lcTgt = lcTgt;
this.bodySrc = bodySrc;
this.tier = tier;
}
/**
* Determine whether this update identifies job by job ID or not
* @return true if the job is identified by job ID, false if indentified by (lcSrc, lcTgt, bodySrc, tier)
*/
public boolean isIdentifiedByJobId()
{
return 0 != jobId;
}
/**
* Create a JSONObject representing this update
* @return the JSONObject created
* @throws GengoException
*/
|
// Path: src/main/java/com/gengo/client/enums/Tier.java
// public enum Tier
// {
// MACHINE,
// STANDARD,
// PRO,
// ULTRA;
//
// public String toRequestString()
// {
// return super.toString().toLowerCase();
// }
//
// public String toString()
// {
// return toRequestString();
// }
//
// };
//
// Path: src/main/java/com/gengo/client/exceptions/GengoException.java
// @SuppressWarnings("serial")
// /**
// * Encapsulates all exceptions thrown by the API
// */
// public class GengoException extends Exception
// {
// public GengoException(String e)
// {
// super(e);
// }
//
// public GengoException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
//
// }
// Path: src/main/java/com/gengo/client/payloads/JobUpdate.java
import org.json.JSONException;
import org.json.JSONObject;
import com.gengo.client.enums.Tier;
import com.gengo.client.exceptions.GengoException;
package com.gengo.client.payloads;
/**
* Abstract base class for update payloads
*/
public abstract class JobUpdate extends Payload
{
private int jobId = 0;
private String lcSrc;
private String lcTgt;
private String bodySrc;
private Tier tier;
/**
* Create a job update payload identified by job ID
* @param jobId
*/
public JobUpdate(int jobId)
{
this.jobId = jobId;
}
/**
* Create a job update payload identified by source and target languages, text body and tier
* @param lcSrc
* @param lcTgt
* @param bodySrc
* @param tier
*/
public JobUpdate(String lcSrc, String lcTgt, String bodySrc, Tier tier)
{
this.jobId = 0;
this.lcSrc = lcSrc;
this.lcTgt = lcTgt;
this.bodySrc = bodySrc;
this.tier = tier;
}
/**
* Determine whether this update identifies job by job ID or not
* @return true if the job is identified by job ID, false if indentified by (lcSrc, lcTgt, bodySrc, tier)
*/
public boolean isIdentifiedByJobId()
{
return 0 != jobId;
}
/**
* Create a JSONObject representing this update
* @return the JSONObject created
* @throws GengoException
*/
|
public JSONObject toJSONObject() throws GengoException
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QubitZero.java
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
|
import com.ars.complexnumbers.ComplexNumber;
|
package com.ars.qubits;
/**
* <h1>QubitZero</h1>
* Representation of the qubit |0>=[1,0].
*/
public class QubitZero extends Qubit {
/**
* Construct a new <code> QubitZero</code> object.
*/
public QubitZero() {
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
// Path: quantum/src/main/java/com/ars/qubits/QubitZero.java
import com.ars.complexnumbers.ComplexNumber;
package com.ars.qubits;
/**
* <h1>QubitZero</h1>
* Representation of the qubit |0>=[1,0].
*/
public class QubitZero extends Qubit {
/**
* Construct a new <code> QubitZero</code> object.
*/
public QubitZero() {
|
super(new ComplexNumber(1.0, 0.0), new ComplexNumber(0.0, 0.0));
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QubitPlus.java
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
|
import com.ars.complexnumbers.ComplexNumber;
|
package com.ars.qubits;
/**
* <h1>QubitPlus</h1>
*/
public class QubitPlus extends Qubit {
/**
* Construct a new <code> QubitPlus</code> object.
*/
public QubitPlus() {
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
// Path: quantum/src/main/java/com/ars/qubits/QubitPlus.java
import com.ars.complexnumbers.ComplexNumber;
package com.ars.qubits;
/**
* <h1>QubitPlus</h1>
*/
public class QubitPlus extends Qubit {
/**
* Construct a new <code> QubitPlus</code> object.
*/
public QubitPlus() {
|
super(new ComplexNumber(1.0 / Math.sqrt(2), 0.0), new ComplexNumber(1.0 / Math.sqrt(2), 0.0));
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/gates/IdentityGate.java
|
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
|
import com.ars.qubits.Qubit;
|
package com.ars.gates;
public final class IdentityGate implements IGate{
@Override
|
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
// Path: quantum/src/main/java/com/ars/gates/IdentityGate.java
import com.ars.qubits.Qubit;
package com.ars.gates;
public final class IdentityGate implements IGate{
@Override
|
public Qubit applyGate(Qubit inputQubit, int[] targetPosition,
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QubitOne.java
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
|
import com.ars.complexnumbers.ComplexNumber;
|
package com.ars.qubits;
/**
* <h1>QubitOne</h1>
* Representation of the qubit |1>=[0,1].
*/
public class QubitOne extends Qubit {
/**
* Construct a new <code> QubitOne</code> object.
*/
public QubitOne() {
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
// Path: quantum/src/main/java/com/ars/qubits/QubitOne.java
import com.ars.complexnumbers.ComplexNumber;
package com.ars.qubits;
/**
* <h1>QubitOne</h1>
* Representation of the qubit |1>=[0,1].
*/
public class QubitOne extends Qubit {
/**
* Construct a new <code> QubitOne</code> object.
*/
public QubitOne() {
|
super(new ComplexNumber(0.0, 0.0), new ComplexNumber(1.0, 0.0));
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
|
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
|
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
// Path: quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
|
protected Qubit resultQubit;
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
|
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
|
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
protected Qubit resultQubit;
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
// Path: quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
protected Qubit resultQubit;
|
protected GatesAbstractFactory gateFactory = GateProducer.getGateFactory();
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
|
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
|
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
protected Qubit resultQubit;
|
// Path: quantum/src/main/java/com/ars/gates/GateProducer.java
// public class GateProducer {
//
// /**
// * Return a new <code>GateFactory</code> object.
// * @return GatesFactory
// */
// public static GatesAbstractFactory getGateFactory() {
// return new GateFactory();
// }
// }
//
// Path: quantum/src/main/java/com/ars/gates/GatesAbstractFactory.java
// public abstract class GatesAbstractFactory {
// public abstract IGate getGate(EGateTypes id);
// }
//
// Path: quantum/src/main/java/com/ars/gates/IGate.java
// public interface IGate {
//
// public Qubit applyGate(Qubit inputQubit,int[] targetPosition,int[] conditions,int noOfEntangledQubits);
//
//
//
// }
//
// Path: quantum/src/main/java/com/ars/qubits/Qubit.java
// public class Qubit {
//
// protected ComplexNumber[] qubitVector;
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param no0 complex number
// * @param no1 complex number
// *
// */
// public Qubit(ComplexNumber no0, ComplexNumber no1) {
// qubitVector = new ComplexNumber[2];
// qubitVector[0] = no0;
// qubitVector[1] = no1;
// }
//
// /**
// * Constructs a new <code>Qubit</code> object.
// * @param qubitVector an array of 2 complex numbers
// */
// public Qubit(ComplexNumber[] qubitVector) {
// this.qubitVector =Arrays.copyOf(qubitVector, qubitVector.length);
// }
//
// /**
// * Return the qubit represented as an array of 2 complex numbers.
// * @return qubit
// */
// public ComplexNumber[] getQubit() {
// ComplexNumber[] copyOfQubitVector = qubitVector;
// return copyOfQubitVector;
// }
//
// /**
// * Return a string representation of the qubit.
// * @return string the representation of the qubit
// */
// @Override
// public String toString() {
// StringBuffer output=new StringBuffer();
// output.append("[ ");
// for (ComplexNumber i : qubitVector) {
// output.append(i);
// output.append(" ");
// }
// output.append("]");
// return output.toString();
// }
//
// /**
// * Check if passed <code>Qubit</code> is equal to the current.
// * @param o the qubit to be checked
// * @return true if the two qubits are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof Qubit) {
// if (this.qubitVector.length != ((Qubit) o).getQubit().length) {
// return false;
// }
// for (int i = 0; i < this.qubitVector.length; i++) {
// if (this.qubitVector[i].equals(((Qubit) o).getQubit()[i])==false) {
// return false;
// }
// }
// return true;
// }
// return false;
// }
//
// /**
// * Calculate the hashcode of the qubit.
// * @return int hashcode
// */
// @Override
// public int hashCode() {
// int hash = 5;
// hash += (this.qubitVector != null ? Arrays.hashCode(qubitVector) : 0);
// return hash;
// }
//
// /**
// * Check if qubit state is valid
// * @return true if the state is valid, otherwise false
// */
// public boolean isValid(){
// double sum=0.0;
// for(ComplexNumber c:this.qubitVector){
// double mod=ComplexMath.mod(c);
// sum+=mod*mod;
// }
// return (sum==1.0);
// }
// }
// Path: quantum/src/main/java/com/ars/algorithms/QuantumAlgorithms.java
import com.ars.gates.GateProducer;
import com.ars.gates.GatesAbstractFactory;
import com.ars.gates.IGate;
import com.ars.qubits.Qubit;
package com.ars.algorithms;
public abstract class QuantumAlgorithms {
protected IGate oracle;
protected Qubit resultQubit;
|
protected GatesAbstractFactory gateFactory = GateProducer.getGateFactory();
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QRegister.java
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
//
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// private static final QRegisterOperations INSTANCE = new QRegisterOperations();
//
// private QRegisterOperations() {
// }
//
// public static QRegisterOperations getInstance() {
// return INSTANCE;
// }
//
// public List<Qubit> fillWith(List<Qubit> list,
// Supplier<Qubit> qubitSupplier, int size) {
// list = Stream.generate(qubitSupplier).limit(size)
// .collect(Collectors.toList());
// return list;
// }
//
// public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// .collect(Collectors.toList()));
// return reg;
// }
//
// public QRegister fillWithPattern(String pattern)
// throws RegisterOverflowException {
// QRegister qreg = new QRegister(pattern.length()).initialize();
// for (int i = 0; i < pattern.length(); i++) {
// if (pattern.charAt(i) == '1') {
// qreg.change(i, new QubitOne());
// } else {
// qreg.change(i, new QubitZero());
// }
// }
// return qreg;
// }
//
// /**
// * Perform the tensor product between two or more qubits. Example, for three
// * qubits |0>, |0> and |1>, the result will be |001>.
// *
// * @param quantumRegister
// * @return qubit the tensor product of the two qubits.
// */
// public Qubit entangle(QRegister quantumRegister) {
// if (quantumRegister.size() < 2) {
// return null;
// }
// Qubit bufferQubit = quantumRegister.get(0);
// for (int i = 1; i < quantumRegister.size(); i++) {
// bufferQubit = QuantumOperations.entangle(bufferQubit,
// quantumRegister.get(i));
//
// }
// return bufferQubit;
// }
//
// }
|
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;
|
package com.ars.qubits;
public class QRegister implements Iterable<Qubit> {
private List<Qubit> qubitRegister;
private int registerSize;
public QRegister(int size) {
this.registerSize = size;
qubitRegister = new ArrayList<>(size);
}
public QRegister initialize() {
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
//
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// private static final QRegisterOperations INSTANCE = new QRegisterOperations();
//
// private QRegisterOperations() {
// }
//
// public static QRegisterOperations getInstance() {
// return INSTANCE;
// }
//
// public List<Qubit> fillWith(List<Qubit> list,
// Supplier<Qubit> qubitSupplier, int size) {
// list = Stream.generate(qubitSupplier).limit(size)
// .collect(Collectors.toList());
// return list;
// }
//
// public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// .collect(Collectors.toList()));
// return reg;
// }
//
// public QRegister fillWithPattern(String pattern)
// throws RegisterOverflowException {
// QRegister qreg = new QRegister(pattern.length()).initialize();
// for (int i = 0; i < pattern.length(); i++) {
// if (pattern.charAt(i) == '1') {
// qreg.change(i, new QubitOne());
// } else {
// qreg.change(i, new QubitZero());
// }
// }
// return qreg;
// }
//
// /**
// * Perform the tensor product between two or more qubits. Example, for three
// * qubits |0>, |0> and |1>, the result will be |001>.
// *
// * @param quantumRegister
// * @return qubit the tensor product of the two qubits.
// */
// public Qubit entangle(QRegister quantumRegister) {
// if (quantumRegister.size() < 2) {
// return null;
// }
// Qubit bufferQubit = quantumRegister.get(0);
// for (int i = 1; i < quantumRegister.size(); i++) {
// bufferQubit = QuantumOperations.entangle(bufferQubit,
// quantumRegister.get(i));
//
// }
// return bufferQubit;
// }
//
// }
// Path: quantum/src/main/java/com/ars/qubits/QRegister.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;
package com.ars.qubits;
public class QRegister implements Iterable<Qubit> {
private List<Qubit> qubitRegister;
private int registerSize;
public QRegister(int size) {
this.registerSize = size;
qubitRegister = new ArrayList<>(size);
}
public QRegister initialize() {
|
qubitRegister = QRegisterOperations.getInstance().fillWith(qubitRegister, QubitZero::new, registerSize);
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QRegister.java
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
//
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// private static final QRegisterOperations INSTANCE = new QRegisterOperations();
//
// private QRegisterOperations() {
// }
//
// public static QRegisterOperations getInstance() {
// return INSTANCE;
// }
//
// public List<Qubit> fillWith(List<Qubit> list,
// Supplier<Qubit> qubitSupplier, int size) {
// list = Stream.generate(qubitSupplier).limit(size)
// .collect(Collectors.toList());
// return list;
// }
//
// public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// .collect(Collectors.toList()));
// return reg;
// }
//
// public QRegister fillWithPattern(String pattern)
// throws RegisterOverflowException {
// QRegister qreg = new QRegister(pattern.length()).initialize();
// for (int i = 0; i < pattern.length(); i++) {
// if (pattern.charAt(i) == '1') {
// qreg.change(i, new QubitOne());
// } else {
// qreg.change(i, new QubitZero());
// }
// }
// return qreg;
// }
//
// /**
// * Perform the tensor product between two or more qubits. Example, for three
// * qubits |0>, |0> and |1>, the result will be |001>.
// *
// * @param quantumRegister
// * @return qubit the tensor product of the two qubits.
// */
// public Qubit entangle(QRegister quantumRegister) {
// if (quantumRegister.size() < 2) {
// return null;
// }
// Qubit bufferQubit = quantumRegister.get(0);
// for (int i = 1; i < quantumRegister.size(); i++) {
// bufferQubit = QuantumOperations.entangle(bufferQubit,
// quantumRegister.get(i));
//
// }
// return bufferQubit;
// }
//
// }
|
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;
|
package com.ars.qubits;
public class QRegister implements Iterable<Qubit> {
private List<Qubit> qubitRegister;
private int registerSize;
public QRegister(int size) {
this.registerSize = size;
qubitRegister = new ArrayList<>(size);
}
public QRegister initialize() {
qubitRegister = QRegisterOperations.getInstance().fillWith(qubitRegister, QubitZero::new, registerSize);
return this;
}
public int size() {
return registerSize;
}
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
//
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// private static final QRegisterOperations INSTANCE = new QRegisterOperations();
//
// private QRegisterOperations() {
// }
//
// public static QRegisterOperations getInstance() {
// return INSTANCE;
// }
//
// public List<Qubit> fillWith(List<Qubit> list,
// Supplier<Qubit> qubitSupplier, int size) {
// list = Stream.generate(qubitSupplier).limit(size)
// .collect(Collectors.toList());
// return list;
// }
//
// public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// .collect(Collectors.toList()));
// return reg;
// }
//
// public QRegister fillWithPattern(String pattern)
// throws RegisterOverflowException {
// QRegister qreg = new QRegister(pattern.length()).initialize();
// for (int i = 0; i < pattern.length(); i++) {
// if (pattern.charAt(i) == '1') {
// qreg.change(i, new QubitOne());
// } else {
// qreg.change(i, new QubitZero());
// }
// }
// return qreg;
// }
//
// /**
// * Perform the tensor product between two or more qubits. Example, for three
// * qubits |0>, |0> and |1>, the result will be |001>.
// *
// * @param quantumRegister
// * @return qubit the tensor product of the two qubits.
// */
// public Qubit entangle(QRegister quantumRegister) {
// if (quantumRegister.size() < 2) {
// return null;
// }
// Qubit bufferQubit = quantumRegister.get(0);
// for (int i = 1; i < quantumRegister.size(); i++) {
// bufferQubit = QuantumOperations.entangle(bufferQubit,
// quantumRegister.get(i));
//
// }
// return bufferQubit;
// }
//
// }
// Path: quantum/src/main/java/com/ars/qubits/QRegister.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;
package com.ars.qubits;
public class QRegister implements Iterable<Qubit> {
private List<Qubit> qubitRegister;
private int registerSize;
public QRegister(int size) {
this.registerSize = size;
qubitRegister = new ArrayList<>(size);
}
public QRegister initialize() {
qubitRegister = QRegisterOperations.getInstance().fillWith(qubitRegister, QubitZero::new, registerSize);
return this;
}
public int size() {
return registerSize;
}
|
public void add(Qubit e) throws RegisterOverflowException {
|
ardeleanasm/quantum_computing
|
quantum/src/main/java/com/ars/qubits/QubitMinus.java
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
|
import com.ars.complexnumbers.ComplexNumber;
|
package com.ars.qubits;
/**
* <h1>QubitMinus</h1>
*/
public class QubitMinus extends Qubit {
/**
* Construct a new <code> QubitMinus</code> object.
*/
public QubitMinus() {
|
// Path: complexnumbers/src/main/java/com/ars/complexnumbers/ComplexNumber.java
// public class ComplexNumber {
//
// /**
// * The imaginary, Im(z), part of the <code>ComplexNumber</code>.
// */
// private double imaginary;
//
// /**
// * The real,Re(z), part of the <code>ComplexNumber</code>.
// */
// private double real;
//
// /**
// * Constructs a new <code>ComplexNumber</code> object.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public ComplexNumber(double real, double imaginary) {
// this.imaginary = imaginary;
// this.real = real;
// }
//
// /**
// * Constructs a new <code>ComplexNumber</code> object with both real and imaginary parts 0.
// */
// public ComplexNumber() {
// this.imaginary = 0.0;
// this.real = 0.0;
// }
//
//
// /**
// * Set the real and the imaginary part of the complex number.
// * @param real the real part, Re(z), of the complex number
// * @param imaginary the imaginary,Im(z), of the complex number
// */
// public void set(double real, double imaginary) {
// this.real = real;
// this.imaginary = imaginary;
// }
//
// /**
// * Set the real part of the complex number.
// * @param real the real part, Re(z), of the complex number
// */
// public void setReal(double real) {
// this.real = real;
// }
//
// /**
// * Return the real part of the complex number.
// * @return Re(z), the real part of the complex number
// */
// public double getReal() {
// return real;
// }
//
// /**
// * Return the imaginary part of the complex number.
// * @return Im(z), the imaginary part of the complex number
// */
// public double getImaginary() {
// return imaginary;
// }
//
// /**
// * Set the imaginary part of the complex number.
// * @param imaginary the imaginary part, Im(z), of the complex number
// */
// public void setImaginary(double imaginary) {
// this.imaginary = imaginary;
// }
//
// /**
// * Check if passed <code>ComplexNumber</code> is equal to the current.
// * @param o the complex number to be checked
// * @return true if the two complex numbers are equals, otherwise false
// */
// @Override
// public boolean equals(Object o) {
// if (o instanceof ComplexNumber) {
// return (Double.compare(((ComplexNumber) o).real, real) == 0
// && Double.compare(((ComplexNumber) o).imaginary, imaginary) == 0);
// }
// return false;
// }
//
// /**
// * Return a string representation of the complex number.
// * @return string the representation of the complex number
// */
// @Override
// public String toString() {
// return (this.imaginary < 0 ? (String.format("%f%fi", real, imaginary))
// : (String.format("%f+%fi", real, imaginary)));
// }
//
// /**
// * Calculates the argument of the current complex number.
// * @return arg(z) the argument of the complex number.
// */
// public double getArg() {
// return Math.atan2(this.imaginary, this.real);
// }
// }
// Path: quantum/src/main/java/com/ars/qubits/QubitMinus.java
import com.ars.complexnumbers.ComplexNumber;
package com.ars.qubits;
/**
* <h1>QubitMinus</h1>
*/
public class QubitMinus extends Qubit {
/**
* Construct a new <code> QubitMinus</code> object.
*/
public QubitMinus() {
|
super(new ComplexNumber(1.0 / Math.sqrt(2), 0.0), new ComplexNumber(-1.0 / Math.sqrt(2), 0.0));
|
ardeleanasm/quantum_computing
|
quantumapp/src/main/java/com/ars/quantumapp/GroverRunner.java
|
// Path: quantumapp/src/main/java/com/ars/algorithms/grover/GroversAlgorithm.java
// public class GroversAlgorithm extends QuantumAlgorithms {
// private static final int NO_OF_INPUT = 3;
// private IGate gateH;
// private IGate gateX;
// private IGate gateCNot;
// private IGate gateCPhaseShift;
//
//
// public GroversAlgorithm() {
//
//
// }
//
//
// @Override
// public void init() {
// gateH = gateFactory.getGate(EGateTypes.E_HadamardGate);
// gateX = gateFactory.getGate(EGateTypes.E_XGate);
// gateCNot = gateFactory.getGate(EGateTypes.E_CNotGate);
// gateCPhaseShift = gateFactory.getGate(EGateTypes.E_CPhaseShift);
// QRegister qRegister=new QRegister(NO_OF_INPUT+1);
// QRegisterOperations qRegOps=QRegisterOperations.getInstance();
// try {
// qRegister=qRegOps.fillWithPattern("0001");
// } catch (RegisterOverflowException e) {
// e.printStackTrace();
// }
// resultQubit=QuantumOperations.entangle(qRegister);
// }
//
// @Override
// public void run() {
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2,3}, null, NO_OF_INPUT+1);
// resultQubit=gateCNot.applyGate(resultQubit, new int[]{3}, new int[]{0,1,2}, NO_OF_INPUT+1);
//
//
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateX.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateCPhaseShift.applyGate(resultQubit, new int[]{2}, new int[]{0,1}, NO_OF_INPUT+1);
//
// resultQubit=gateX.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2,3}, null, NO_OF_INPUT+1);
//
//
//
//
// }
//
// @Override
// public void measure() {
// MeasurementPerformer measurementPerformer = new MeasurementPerformer().configure(resultQubit);
// resultQubit = measurementPerformer.measure();
// System.out.println(resultQubit);
//
// }
//
//
//
// }
|
import com.ars.algorithms.grover.GroversAlgorithm;
|
package com.ars.quantumapp;
public class GroverRunner implements Runnable {
@Override
public void run() {
|
// Path: quantumapp/src/main/java/com/ars/algorithms/grover/GroversAlgorithm.java
// public class GroversAlgorithm extends QuantumAlgorithms {
// private static final int NO_OF_INPUT = 3;
// private IGate gateH;
// private IGate gateX;
// private IGate gateCNot;
// private IGate gateCPhaseShift;
//
//
// public GroversAlgorithm() {
//
//
// }
//
//
// @Override
// public void init() {
// gateH = gateFactory.getGate(EGateTypes.E_HadamardGate);
// gateX = gateFactory.getGate(EGateTypes.E_XGate);
// gateCNot = gateFactory.getGate(EGateTypes.E_CNotGate);
// gateCPhaseShift = gateFactory.getGate(EGateTypes.E_CPhaseShift);
// QRegister qRegister=new QRegister(NO_OF_INPUT+1);
// QRegisterOperations qRegOps=QRegisterOperations.getInstance();
// try {
// qRegister=qRegOps.fillWithPattern("0001");
// } catch (RegisterOverflowException e) {
// e.printStackTrace();
// }
// resultQubit=QuantumOperations.entangle(qRegister);
// }
//
// @Override
// public void run() {
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2,3}, null, NO_OF_INPUT+1);
// resultQubit=gateCNot.applyGate(resultQubit, new int[]{3}, new int[]{0,1,2}, NO_OF_INPUT+1);
//
//
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateX.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateCPhaseShift.applyGate(resultQubit, new int[]{2}, new int[]{0,1}, NO_OF_INPUT+1);
//
// resultQubit=gateX.applyGate(resultQubit, new int[]{0,1,2}, null, NO_OF_INPUT+1);
// resultQubit=gateH.applyGate(resultQubit, new int[]{0,1,2,3}, null, NO_OF_INPUT+1);
//
//
//
//
// }
//
// @Override
// public void measure() {
// MeasurementPerformer measurementPerformer = new MeasurementPerformer().configure(resultQubit);
// resultQubit = measurementPerformer.measure();
// System.out.println(resultQubit);
//
// }
//
//
//
// }
// Path: quantumapp/src/main/java/com/ars/quantumapp/GroverRunner.java
import com.ars.algorithms.grover.GroversAlgorithm;
package com.ars.quantumapp;
public class GroverRunner implements Runnable {
@Override
public void run() {
|
GroversAlgorithm ga = null;
|
ardeleanasm/quantum_computing
|
quantum/src/test/java/com/ars/qubits/QRegisterTest.java
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
|
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.ars.quantum.exception.RegisterOverflowException;
|
package com.ars.qubits;
public class QRegisterTest {
private QRegister qRegister;
private static final int REGISTER_LENGTH = 3;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
qRegister = null;
}
@Test
public void testSizeNoElementsWithoutInit() {
qRegister = new QRegister(REGISTER_LENGTH);
assertEquals(3, qRegister.size());
}
@Test
public void testAddElementsWithoutInit() {
qRegister = new QRegister(REGISTER_LENGTH);
try {
qRegister.add(new QubitOne());
|
// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// /**
// *
// */
// private static final long serialVersionUID = 4071226864956577717L;
//
// public RegisterOverflowException(){
// super("Register size exceeded!");
// }
// }
// Path: quantum/src/test/java/com/ars/qubits/QRegisterTest.java
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.ars.quantum.exception.RegisterOverflowException;
package com.ars.qubits;
public class QRegisterTest {
private QRegister qRegister;
private static final int REGISTER_LENGTH = 3;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
qRegister = null;
}
@Test
public void testSizeNoElementsWithoutInit() {
qRegister = new QRegister(REGISTER_LENGTH);
assertEquals(3, qRegister.size());
}
@Test
public void testAddElementsWithoutInit() {
qRegister = new QRegister(REGISTER_LENGTH);
try {
qRegister.add(new QubitOne());
|
} catch (RegisterOverflowException e) {
|
googleapis/java-iamcredentials
|
google-cloud-iamcredentials/src/test/java/com/google/cloud/iam/credentials/v1/MockIAMCredentialsImpl.java
|
// Path: grpc-google-cloud-iamcredentials-v1/src/main/java/com/google/cloud/iam/credentials/v1/IAMCredentialsGrpc.java
// public abstract static class IAMCredentialsImplBase implements io.grpc.BindableService {
//
// /**
// *
// *
// * <pre>
// * Generates an OAuth 2.0 access token for a service account.
// * </pre>
// */
// public void generateAccessToken(
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
// getGenerateAccessTokenMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Generates an OpenID Connect ID token for a service account.
// * </pre>
// */
// public void generateIdToken(
// com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
// getGenerateIdTokenMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Signs a blob using a service account's system-managed private key.
// * </pre>
// */
// public void signBlob(
// com.google.cloud.iam.credentials.v1.SignBlobRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.SignBlobResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSignBlobMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Signs a JWT using a service account's system-managed private key.
// * </pre>
// */
// public void signJwt(
// com.google.cloud.iam.credentials.v1.SignJwtRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.SignJwtResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSignJwtMethod(), responseObserver);
// }
//
// @java.lang.Override
// public final io.grpc.ServerServiceDefinition bindService() {
// return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
// .addMethod(
// getGenerateAccessTokenMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest,
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse>(
// this, METHODID_GENERATE_ACCESS_TOKEN)))
// .addMethod(
// getGenerateIdTokenMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest,
// com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse>(
// this, METHODID_GENERATE_ID_TOKEN)))
// .addMethod(
// getSignBlobMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.SignBlobRequest,
// com.google.cloud.iam.credentials.v1.SignBlobResponse>(
// this, METHODID_SIGN_BLOB)))
// .addMethod(
// getSignJwtMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.SignJwtRequest,
// com.google.cloud.iam.credentials.v1.SignJwtResponse>(
// this, METHODID_SIGN_JWT)))
// .build();
// }
// }
|
import com.google.api.core.BetaApi;
import com.google.cloud.iam.credentials.v1.IAMCredentialsGrpc.IAMCredentialsImplBase;
import com.google.protobuf.AbstractMessage;
import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import javax.annotation.Generated;
|
/*
* Copyright 2021 Google LLC
*
* 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
*
* https://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.google.cloud.iam.credentials.v1;
@BetaApi
@Generated("by gapic-generator-java")
|
// Path: grpc-google-cloud-iamcredentials-v1/src/main/java/com/google/cloud/iam/credentials/v1/IAMCredentialsGrpc.java
// public abstract static class IAMCredentialsImplBase implements io.grpc.BindableService {
//
// /**
// *
// *
// * <pre>
// * Generates an OAuth 2.0 access token for a service account.
// * </pre>
// */
// public void generateAccessToken(
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
// getGenerateAccessTokenMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Generates an OpenID Connect ID token for a service account.
// * </pre>
// */
// public void generateIdToken(
// com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(
// getGenerateIdTokenMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Signs a blob using a service account's system-managed private key.
// * </pre>
// */
// public void signBlob(
// com.google.cloud.iam.credentials.v1.SignBlobRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.SignBlobResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSignBlobMethod(), responseObserver);
// }
//
// /**
// *
// *
// * <pre>
// * Signs a JWT using a service account's system-managed private key.
// * </pre>
// */
// public void signJwt(
// com.google.cloud.iam.credentials.v1.SignJwtRequest request,
// io.grpc.stub.StreamObserver<com.google.cloud.iam.credentials.v1.SignJwtResponse>
// responseObserver) {
// io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSignJwtMethod(), responseObserver);
// }
//
// @java.lang.Override
// public final io.grpc.ServerServiceDefinition bindService() {
// return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
// .addMethod(
// getGenerateAccessTokenMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest,
// com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse>(
// this, METHODID_GENERATE_ACCESS_TOKEN)))
// .addMethod(
// getGenerateIdTokenMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest,
// com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse>(
// this, METHODID_GENERATE_ID_TOKEN)))
// .addMethod(
// getSignBlobMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.SignBlobRequest,
// com.google.cloud.iam.credentials.v1.SignBlobResponse>(
// this, METHODID_SIGN_BLOB)))
// .addMethod(
// getSignJwtMethod(),
// io.grpc.stub.ServerCalls.asyncUnaryCall(
// new MethodHandlers<
// com.google.cloud.iam.credentials.v1.SignJwtRequest,
// com.google.cloud.iam.credentials.v1.SignJwtResponse>(
// this, METHODID_SIGN_JWT)))
// .build();
// }
// }
// Path: google-cloud-iamcredentials/src/test/java/com/google/cloud/iam/credentials/v1/MockIAMCredentialsImpl.java
import com.google.api.core.BetaApi;
import com.google.cloud.iam.credentials.v1.IAMCredentialsGrpc.IAMCredentialsImplBase;
import com.google.protobuf.AbstractMessage;
import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import javax.annotation.Generated;
/*
* Copyright 2021 Google LLC
*
* 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
*
* https://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.google.cloud.iam.credentials.v1;
@BetaApi
@Generated("by gapic-generator-java")
|
public class MockIAMCredentialsImpl extends IAMCredentialsImplBase {
|
leandreck/spring-typescript-services
|
examples/src/main/java/org/leandreck/endpoints/examples/lombok/LombokTypeScriptEndpoint.java
|
// Path: examples/src/main/java/org/leandreck/endpoints/examples/RootType.java
// @TypeScriptType("MyTypeScriptType")
// public class RootType {
//
// private Long id;
//
// private String name;
// private String givenName;
// private int weight;
//
// private SimpleEnum[] simpleArray;
//
// @TypeScriptIgnore
// private BigDecimal ignoredField;
//
// private transient String transientField;
//
// private char noPublicGetter;
//
// private List<SubType> subTypeList;
//
// private Map<String, SubType> subTypeMap;
//
// private Map<?, MapValueType> mapValue;
// private Map<MapKeyType, ?> mapKey;
//
// public RootType() {
// this.id = Long.MIN_VALUE;
// }
//
// public RootType(final Long id) {
// this.id = id;
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getGivenName() {
// return givenName;
// }
//
// public int getWeight() {
// return weight;
// }
//
// public BigDecimal getIgnoredField() {
// return ignoredField;
// }
//
// public String getTransientField() {
// return transientField;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Map<String, SubType> getSubTypeMap() {
// return subTypeMap;
// }
//
// public void setSubTypeMap(Map<String, SubType> subTypeMap) {
// this.subTypeMap = subTypeMap;
// }
//
// public Map<?, MapValueType> getMapValue() {
// return mapValue;
// }
//
// public void setMapValue(Map<?, MapValueType> mapValue) {
// this.mapValue = mapValue;
// }
//
// public Map<MapKeyType, ?> getMapKey() {
// return mapKey;
// }
//
// public void setMapKey(Map<MapKeyType, ?> mapKey) {
// this.mapKey = mapKey;
// }
//
// public List<SubType> getSubTypeList() {
// return subTypeList;
// }
//
// public void setSubTypeList(List<SubType> subTypeList) {
// this.subTypeList = subTypeList;
// }
//
// public SimpleEnum[] getSimpleArray() {
// return simpleArray;
// }
//
// public void setSimpleArray(SimpleEnum[] simpleArray) {
// this.simpleArray = simpleArray;
// }
// }
|
import java.util.Map;
import java.util.Optional;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import org.leandreck.endpoints.annotations.TypeScriptEndpoint;
import org.leandreck.endpoints.examples.RootType;
import org.leandreck.endpoints.examples.SubType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import java.util.ArrayList;
import java.util.List;
|
/**
* Copyright © 2016 Mathias Kowalzik (Mathias.Kowalzik@leandreck.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.leandreck.endpoints.examples.lombok;
/**
* LombokTypeScriptEndpoint JavaDoc.
*
* @see StringBuilder
* @see java.util.TreeMap
* @since 0.3.0
*/
@TypeScriptEndpoint
@RestController
@RequestMapping("/api")
public class LombokTypeScriptEndpoint {
/**
* this is a simple javadoc for Method {@link #setId(Long, String, Optional, LombokRequest)}.
* @param id id
* @param typeRef a reference
* @param queryParameter a query parameter
* @param body a body parameter
* @return LombokResponse
*/
@RequestMapping(value = "/type/{idPathVariable}/{typeRef}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public LombokResponse<ArrayList<SubType>, List<Object>, Boolean, Map<String, String>, SubType> setId(
@PathVariable(name = "idPathVariable") Long id,
@PathVariable String typeRef,
@RequestParam(name = "queryRequestParam", required = false) Optional<String> queryParameter,
@RequestBody(required = false) LombokRequest body) {
// do something
return new LombokResponse<>();
}
@RequestMapping(value = "/foo/{idPathVariable}/{typeRef}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
|
// Path: examples/src/main/java/org/leandreck/endpoints/examples/RootType.java
// @TypeScriptType("MyTypeScriptType")
// public class RootType {
//
// private Long id;
//
// private String name;
// private String givenName;
// private int weight;
//
// private SimpleEnum[] simpleArray;
//
// @TypeScriptIgnore
// private BigDecimal ignoredField;
//
// private transient String transientField;
//
// private char noPublicGetter;
//
// private List<SubType> subTypeList;
//
// private Map<String, SubType> subTypeMap;
//
// private Map<?, MapValueType> mapValue;
// private Map<MapKeyType, ?> mapKey;
//
// public RootType() {
// this.id = Long.MIN_VALUE;
// }
//
// public RootType(final Long id) {
// this.id = id;
// }
//
// public Long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getGivenName() {
// return givenName;
// }
//
// public int getWeight() {
// return weight;
// }
//
// public BigDecimal getIgnoredField() {
// return ignoredField;
// }
//
// public String getTransientField() {
// return transientField;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Map<String, SubType> getSubTypeMap() {
// return subTypeMap;
// }
//
// public void setSubTypeMap(Map<String, SubType> subTypeMap) {
// this.subTypeMap = subTypeMap;
// }
//
// public Map<?, MapValueType> getMapValue() {
// return mapValue;
// }
//
// public void setMapValue(Map<?, MapValueType> mapValue) {
// this.mapValue = mapValue;
// }
//
// public Map<MapKeyType, ?> getMapKey() {
// return mapKey;
// }
//
// public void setMapKey(Map<MapKeyType, ?> mapKey) {
// this.mapKey = mapKey;
// }
//
// public List<SubType> getSubTypeList() {
// return subTypeList;
// }
//
// public void setSubTypeList(List<SubType> subTypeList) {
// this.subTypeList = subTypeList;
// }
//
// public SimpleEnum[] getSimpleArray() {
// return simpleArray;
// }
//
// public void setSimpleArray(SimpleEnum[] simpleArray) {
// this.simpleArray = simpleArray;
// }
// }
// Path: examples/src/main/java/org/leandreck/endpoints/examples/lombok/LombokTypeScriptEndpoint.java
import java.util.Map;
import java.util.Optional;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import org.leandreck.endpoints.annotations.TypeScriptEndpoint;
import org.leandreck.endpoints.examples.RootType;
import org.leandreck.endpoints.examples.SubType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import java.util.ArrayList;
import java.util.List;
/**
* Copyright © 2016 Mathias Kowalzik (Mathias.Kowalzik@leandreck.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.leandreck.endpoints.examples.lombok;
/**
* LombokTypeScriptEndpoint JavaDoc.
*
* @see StringBuilder
* @see java.util.TreeMap
* @since 0.3.0
*/
@TypeScriptEndpoint
@RestController
@RequestMapping("/api")
public class LombokTypeScriptEndpoint {
/**
* this is a simple javadoc for Method {@link #setId(Long, String, Optional, LombokRequest)}.
* @param id id
* @param typeRef a reference
* @param queryParameter a query parameter
* @param body a body parameter
* @return LombokResponse
*/
@RequestMapping(value = "/type/{idPathVariable}/{typeRef}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public LombokResponse<ArrayList<SubType>, List<Object>, Boolean, Map<String, String>, SubType> setId(
@PathVariable(name = "idPathVariable") Long id,
@PathVariable String typeRef,
@RequestParam(name = "queryRequestParam", required = false) Optional<String> queryParameter,
@RequestBody(required = false) LombokRequest body) {
// do something
return new LombokResponse<>();
}
@RequestMapping(value = "/foo/{idPathVariable}/{typeRef}", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
|
public LombokResponse<List<RootType>, List<Object>, Boolean, SubType, RootType> setFoo(
|
leandreck/spring-typescript-services
|
annotations/src/main/java/org/leandreck/endpoints/processor/model/TypeNodeFactory.java
|
// Path: annotations/src/main/java/org/leandreck/endpoints/processor/model/typefactories/TypeNodeUtils.java
// public class TypeNodeUtils {
//
// static final String NO_TEMPLATE = "NO_TEMPLATE";
// static final String UNDEFINED_TYPE_NAME = "UNDEFINED";
// static final String JAVA_LANG_OBJECT = "java.lang.Object";
// static TypeMirror objectMirror;
//
// public static <A extends Annotation> A getAnnotationForClass(final TypeMirror typeMirror, final Class<A> annotation, final Types typeUtils) {
// final TypeKind kind = typeMirror.getKind();
// final TypeMirror realMirror;
// if (TypeKind.ARRAY.equals(kind)) {
// realMirror = ((ArrayType) typeMirror).getComponentType();
// } else {
// realMirror = typeMirror;
// }
//
// final Element definingElement = typeUtils.asElement(realMirror);
// return (definingElement != null) ? definingElement.getAnnotation(annotation) : null;
// }
//
// static String defineTemplate(final String typeNodeTemplate,
// final TypeScriptType typeScriptTypeAnnotation,
// final Element element) {
//
// if (typeNodeTemplate == null || typeNodeTemplate.isEmpty()) {
// throw new MissingConfigurationTemplateException("TemplateConfiguration is null while processing Element", element);
// }
//
// final String template;
// if (typeScriptTypeAnnotation == null || typeScriptTypeAnnotation.template().isEmpty()) {
// template = typeNodeTemplate;
// } else {
// template = typeScriptTypeAnnotation.template();
// }
//
// return template;
// }
//
// static String defineName(final TypeMirror typeMirror, final TypeScriptType typeScriptTypeAnnotation, final Function<TypeMirror, String> nameFunction) {
// //check if has a annotation and a type
// final String typeFromAnnotation = TypeNodeUtils.defineTypeFromAnnotation(typeScriptTypeAnnotation);
// if (!UNDEFINED_TYPE_NAME.equals(typeFromAnnotation)) {
// return typeFromAnnotation;
// }
// //forward to furter determination
// return nameFunction.apply(typeMirror);
// }
//
// static TypeMirror getObjectMirror(final Elements elementUtils) {
// if (objectMirror == null) {
// objectMirror = elementUtils.getTypeElement(JAVA_LANG_OBJECT).asType();
// }
// return objectMirror;
// }
//
// private static String defineTypeFromAnnotation(final TypeScriptType annotation) {
// if (annotation != null && !annotation.value().isEmpty()) {
// return annotation.value();
// }
// return UNDEFINED_TYPE_NAME;
// }
//
// /**
// * No Instances of this utility class.
// */
// private TypeNodeUtils() {
// }
// }
//
// Path: annotations/src/main/java/org/leandreck/endpoints/processor/model/TypeNode.java
// protected static final String EMPTY_JAVA_DOC = "";
|
import org.leandreck.endpoints.annotations.TypeScriptIgnore;
import org.leandreck.endpoints.processor.config.TemplateConfiguration;
import org.leandreck.endpoints.processor.model.typefactories.ConcreteTypeNodeFactory;
import org.leandreck.endpoints.processor.model.typefactories.TypeNodeKind;
import org.leandreck.endpoints.processor.model.typefactories.TypeNodeUtils;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static java.util.stream.Collectors.toList;
import static org.leandreck.endpoints.processor.model.TypeNode.EMPTY_JAVA_DOC;
import static org.leandreck.endpoints.processor.model.typefactories.TypeNodeKind.OPTIONAL;
|
final Map<TypeNodeKind, ConcreteTypeNodeFactory> tmpFactories = new EnumMap<>(TypeNodeKind.class);
Arrays.stream(TypeNodeKind.values()).forEach(it -> {
try {
tmpFactories.put(it, it.getTypeNodeFactory().newConfiguredInstance(this, this.configuration, this.typeUtils, this.elementUtils));
} catch (final Exception e) {
throw new InitTypeNodeFactoriesException(e);
}
});
return tmpFactories;
}
/**
* Factory Method to create new Root-TypeNodes like Returnvalues of Methods.
*
* @param typeMirror {@link TypeMirror} of Returnvalue or Parameter.
* @return created {@link TypeNode} from given typeMirror
*/
public TypeNode createTypeNode(final TypeMirror typeMirror) {
return createTypeNode(typeMirror, null);
}
/**
* Factory Method to create new Root-TypeNodes like Generics.
*
* @param typeMirror {@link TypeMirror} of TypeVariable.
* @param containingType {@link TypeMirror} of the Type containing this {@link TypeNode}
* @return created {@link TypeNode} from given typeMirror
*/
public TypeNode createTypeNode(final TypeMirror typeMirror, final DeclaredType containingType) {
final String fieldName = "TYPE-ROOT";
|
// Path: annotations/src/main/java/org/leandreck/endpoints/processor/model/typefactories/TypeNodeUtils.java
// public class TypeNodeUtils {
//
// static final String NO_TEMPLATE = "NO_TEMPLATE";
// static final String UNDEFINED_TYPE_NAME = "UNDEFINED";
// static final String JAVA_LANG_OBJECT = "java.lang.Object";
// static TypeMirror objectMirror;
//
// public static <A extends Annotation> A getAnnotationForClass(final TypeMirror typeMirror, final Class<A> annotation, final Types typeUtils) {
// final TypeKind kind = typeMirror.getKind();
// final TypeMirror realMirror;
// if (TypeKind.ARRAY.equals(kind)) {
// realMirror = ((ArrayType) typeMirror).getComponentType();
// } else {
// realMirror = typeMirror;
// }
//
// final Element definingElement = typeUtils.asElement(realMirror);
// return (definingElement != null) ? definingElement.getAnnotation(annotation) : null;
// }
//
// static String defineTemplate(final String typeNodeTemplate,
// final TypeScriptType typeScriptTypeAnnotation,
// final Element element) {
//
// if (typeNodeTemplate == null || typeNodeTemplate.isEmpty()) {
// throw new MissingConfigurationTemplateException("TemplateConfiguration is null while processing Element", element);
// }
//
// final String template;
// if (typeScriptTypeAnnotation == null || typeScriptTypeAnnotation.template().isEmpty()) {
// template = typeNodeTemplate;
// } else {
// template = typeScriptTypeAnnotation.template();
// }
//
// return template;
// }
//
// static String defineName(final TypeMirror typeMirror, final TypeScriptType typeScriptTypeAnnotation, final Function<TypeMirror, String> nameFunction) {
// //check if has a annotation and a type
// final String typeFromAnnotation = TypeNodeUtils.defineTypeFromAnnotation(typeScriptTypeAnnotation);
// if (!UNDEFINED_TYPE_NAME.equals(typeFromAnnotation)) {
// return typeFromAnnotation;
// }
// //forward to furter determination
// return nameFunction.apply(typeMirror);
// }
//
// static TypeMirror getObjectMirror(final Elements elementUtils) {
// if (objectMirror == null) {
// objectMirror = elementUtils.getTypeElement(JAVA_LANG_OBJECT).asType();
// }
// return objectMirror;
// }
//
// private static String defineTypeFromAnnotation(final TypeScriptType annotation) {
// if (annotation != null && !annotation.value().isEmpty()) {
// return annotation.value();
// }
// return UNDEFINED_TYPE_NAME;
// }
//
// /**
// * No Instances of this utility class.
// */
// private TypeNodeUtils() {
// }
// }
//
// Path: annotations/src/main/java/org/leandreck/endpoints/processor/model/TypeNode.java
// protected static final String EMPTY_JAVA_DOC = "";
// Path: annotations/src/main/java/org/leandreck/endpoints/processor/model/TypeNodeFactory.java
import org.leandreck.endpoints.annotations.TypeScriptIgnore;
import org.leandreck.endpoints.processor.config.TemplateConfiguration;
import org.leandreck.endpoints.processor.model.typefactories.ConcreteTypeNodeFactory;
import org.leandreck.endpoints.processor.model.typefactories.TypeNodeKind;
import org.leandreck.endpoints.processor.model.typefactories.TypeNodeUtils;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static java.util.stream.Collectors.toList;
import static org.leandreck.endpoints.processor.model.TypeNode.EMPTY_JAVA_DOC;
import static org.leandreck.endpoints.processor.model.typefactories.TypeNodeKind.OPTIONAL;
final Map<TypeNodeKind, ConcreteTypeNodeFactory> tmpFactories = new EnumMap<>(TypeNodeKind.class);
Arrays.stream(TypeNodeKind.values()).forEach(it -> {
try {
tmpFactories.put(it, it.getTypeNodeFactory().newConfiguredInstance(this, this.configuration, this.typeUtils, this.elementUtils));
} catch (final Exception e) {
throw new InitTypeNodeFactoriesException(e);
}
});
return tmpFactories;
}
/**
* Factory Method to create new Root-TypeNodes like Returnvalues of Methods.
*
* @param typeMirror {@link TypeMirror} of Returnvalue or Parameter.
* @return created {@link TypeNode} from given typeMirror
*/
public TypeNode createTypeNode(final TypeMirror typeMirror) {
return createTypeNode(typeMirror, null);
}
/**
* Factory Method to create new Root-TypeNodes like Generics.
*
* @param typeMirror {@link TypeMirror} of TypeVariable.
* @param containingType {@link TypeMirror} of the Type containing this {@link TypeNode}
* @return created {@link TypeNode} from given typeMirror
*/
public TypeNode createTypeNode(final TypeMirror typeMirror, final DeclaredType containingType) {
final String fieldName = "TYPE-ROOT";
|
final String doc = EMPTY_JAVA_DOC + "FIXME: createTypeNode(final TypeMirror typeMirror, final DeclaredType containingType)";
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.