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 |
|---|---|---|---|---|---|---|
yu-kopylov/shared-mq | src/test/java/org/sharedmq/primitives/RollbackJournalTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; | package org.sharedmq.primitives;
@Category(CommonTests.class)
public class RollbackJournalTest {
@Test
public void testMultipleFiles() throws IOException {
try ( | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
// Path: src/test/java/org/sharedmq/primitives/RollbackJournalTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
package org.sharedmq.primitives;
@Category(CommonTests.class)
public class RollbackJournalTest {
@Test
public void testMultipleFiles() throws IOException {
try ( | TestFolder testFolder = new TestFolder("RollbackJournalTest", "testMultipleFiles"); |
yu-kopylov/shared-mq | src/main/java/org/sharedmq/internals/MessageHeaderStorageAdapter.java | // Path: src/main/java/org/sharedmq/primitives/MappedByteArrayStorageKeyStorageAdapter.java
// public class MappedByteArrayStorageKeyStorageAdapter implements StorageAdapter<MappedByteArrayStorageKey> {
//
// private static final MappedByteArrayStorageKeyStorageAdapter instance
// = new MappedByteArrayStorageKeyStorageAdapter();
//
// public static MappedByteArrayStorageKeyStorageAdapter getInstance() {
// return instance;
// }
//
// @Override
// public int getRecordSize() {
// return 4 * 2 + 8;
// }
//
// @Override
// public void store(ByteBuffer buffer, MappedByteArrayStorageKey key) {
//
// if (key == null) {
// throw new IllegalArgumentException(
// "The MappedByteArrayStorageKeyStorageAdapter does not support null records.");
// }
//
// buffer.putInt(key.getSegmentNumber());
// buffer.putInt(key.getRecordNumber());
// buffer.putLong(key.getRecordId());
// }
//
// @Override
// public MappedByteArrayStorageKey load(ByteBuffer buffer) {
// int segmentNumber = buffer.getInt();
// int recordNumber = buffer.getInt();
// long recordId = buffer.getLong();
// return new MappedByteArrayStorageKey(segmentNumber, recordNumber, recordId);
// }
// }
//
// Path: src/main/java/org/sharedmq/primitives/StorageAdapter.java
// public interface StorageAdapter<TRecord> {
// /**
// * Returns the size of one record in bytes.
// */
// int getRecordSize();
//
// /**
// * Writes the given record to the buffer at current buffer position.
// *
// * @param buffer The buffer to write the record to.
// * @param record The record to store.
// */
// void store(ByteBuffer buffer, TRecord record);
//
// /**
// * Reads a record from the buffer at current buffer position.
// *
// * @param buffer The buffer to read from.
// * @return The record at the given buffer position.
// */
// TRecord load(ByteBuffer buffer) throws IOException;
// }
| import org.sharedmq.primitives.MappedByteArrayStorageKeyStorageAdapter;
import org.sharedmq.primitives.StorageAdapter;
import java.nio.ByteBuffer; | package org.sharedmq.internals;
/**
* A storage adapter for the {@link MessageHeader}.
*/
public class MessageHeaderStorageAdapter implements StorageAdapter<MessageHeader> {
// We assume that such timestamp can never occur (292269055 BC).
private static final long TimestampNullValue = Long.MIN_VALUE;
private static final byte NullMarker = 0;
private static final byte NotNullMarker = 1;
private static final MessageHeaderStorageAdapter instance = new MessageHeaderStorageAdapter();
| // Path: src/main/java/org/sharedmq/primitives/MappedByteArrayStorageKeyStorageAdapter.java
// public class MappedByteArrayStorageKeyStorageAdapter implements StorageAdapter<MappedByteArrayStorageKey> {
//
// private static final MappedByteArrayStorageKeyStorageAdapter instance
// = new MappedByteArrayStorageKeyStorageAdapter();
//
// public static MappedByteArrayStorageKeyStorageAdapter getInstance() {
// return instance;
// }
//
// @Override
// public int getRecordSize() {
// return 4 * 2 + 8;
// }
//
// @Override
// public void store(ByteBuffer buffer, MappedByteArrayStorageKey key) {
//
// if (key == null) {
// throw new IllegalArgumentException(
// "The MappedByteArrayStorageKeyStorageAdapter does not support null records.");
// }
//
// buffer.putInt(key.getSegmentNumber());
// buffer.putInt(key.getRecordNumber());
// buffer.putLong(key.getRecordId());
// }
//
// @Override
// public MappedByteArrayStorageKey load(ByteBuffer buffer) {
// int segmentNumber = buffer.getInt();
// int recordNumber = buffer.getInt();
// long recordId = buffer.getLong();
// return new MappedByteArrayStorageKey(segmentNumber, recordNumber, recordId);
// }
// }
//
// Path: src/main/java/org/sharedmq/primitives/StorageAdapter.java
// public interface StorageAdapter<TRecord> {
// /**
// * Returns the size of one record in bytes.
// */
// int getRecordSize();
//
// /**
// * Writes the given record to the buffer at current buffer position.
// *
// * @param buffer The buffer to write the record to.
// * @param record The record to store.
// */
// void store(ByteBuffer buffer, TRecord record);
//
// /**
// * Reads a record from the buffer at current buffer position.
// *
// * @param buffer The buffer to read from.
// * @return The record at the given buffer position.
// */
// TRecord load(ByteBuffer buffer) throws IOException;
// }
// Path: src/main/java/org/sharedmq/internals/MessageHeaderStorageAdapter.java
import org.sharedmq.primitives.MappedByteArrayStorageKeyStorageAdapter;
import org.sharedmq.primitives.StorageAdapter;
import java.nio.ByteBuffer;
package org.sharedmq.internals;
/**
* A storage adapter for the {@link MessageHeader}.
*/
public class MessageHeaderStorageAdapter implements StorageAdapter<MessageHeader> {
// We assume that such timestamp can never occur (292269055 BC).
private static final long TimestampNullValue = Long.MIN_VALUE;
private static final byte NullMarker = 0;
private static final byte NotNullMarker = 1;
private static final MessageHeaderStorageAdapter instance = new MessageHeaderStorageAdapter();
| private MappedByteArrayStorageKeyStorageAdapter keyStorageAdapter |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/SharedMessageQueuePerformanceTest.java | // Path: src/test/java/org/sharedmq/test/PerformanceTests.java
// public interface PerformanceTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
| import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.PerformanceTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.sharedmq.test.TestUtils.printResult; | package org.sharedmq;
@Category(PerformanceTests.class)
public class SharedMessageQueuePerformanceTest {
private static final long PullTimeout = 5000;
private static final long Hours12 = 12 * 60 * 60 * 1000L;
@Test
public void testPushPullDelete() throws IOException, InterruptedException { | // Path: src/test/java/org/sharedmq/test/PerformanceTests.java
// public interface PerformanceTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
// Path: src/test/java/org/sharedmq/SharedMessageQueuePerformanceTest.java
import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.PerformanceTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.sharedmq.test.TestUtils.printResult;
package org.sharedmq;
@Category(PerformanceTests.class)
public class SharedMessageQueuePerformanceTest {
private static final long PullTimeout = 5000;
private static final long Hours12 = 12 * 60 * 60 * 1000L;
@Test
public void testPushPullDelete() throws IOException, InterruptedException { | try (TestFolder testFolder = new TestFolder("SharedMessageQueuePerformanceTest", "testPushPullDelete")) { |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/SharedMessageQueuePerformanceTest.java | // Path: src/test/java/org/sharedmq/test/PerformanceTests.java
// public interface PerformanceTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
| import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.PerformanceTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.sharedmq.test.TestUtils.printResult; | final List<Thread> threads = new ArrayList<>();
final CountDownLatch startLatch = new CountDownLatch(threadCount);
try (SharedMessageQueue queue = SharedMessageQueue.createQueue(queueFolder, Hours12, Hours12)) {
for (int threadNum = 0; threadNum < threadCount; threadNum++) {
threads.add(new Thread(() -> {
try {
// Thread startup can be slow.
// We want all threads to start their job approximately at same time.
startLatch.countDown();
startLatch.await();
for (int i = 0; i < messagesPerThread; i++) {
queue.push(0, messageBody);
Message message = queue.pull(PullTimeout);
assertNotNull(message);
queue.delete(message);
}
} catch (Exception e) {
errorCount.incrementAndGet();
e.printStackTrace();
}
}));
}
Stopwatch sw = Stopwatch.createStarted();
startThreads(threads);
joinThreads(threads);
sw.stop();
| // Path: src/test/java/org/sharedmq/test/PerformanceTests.java
// public interface PerformanceTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
// Path: src/test/java/org/sharedmq/SharedMessageQueuePerformanceTest.java
import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.PerformanceTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.sharedmq.test.TestUtils.printResult;
final List<Thread> threads = new ArrayList<>();
final CountDownLatch startLatch = new CountDownLatch(threadCount);
try (SharedMessageQueue queue = SharedMessageQueue.createQueue(queueFolder, Hours12, Hours12)) {
for (int threadNum = 0; threadNum < threadCount; threadNum++) {
threads.add(new Thread(() -> {
try {
// Thread startup can be slow.
// We want all threads to start their job approximately at same time.
startLatch.countDown();
startLatch.await();
for (int i = 0; i < messagesPerThread; i++) {
queue.push(0, messageBody);
Message message = queue.pull(PullTimeout);
assertNotNull(message);
queue.delete(message);
}
} catch (Exception e) {
errorCount.incrementAndGet();
e.printStackTrace();
}
}));
}
Stopwatch sw = Stopwatch.createStarted();
startThreads(threads);
joinThreads(threads);
sw.stop();
| printResult("testPushPullDelete: ", sw, totalMessageCount); |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/internals/QueueParametersValidatorTest.java | // Path: src/main/java/org/sharedmq/Message.java
// public interface Message {
// /**
// * @return The message body as a string.
// */
// String asString();
// }
//
// Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
| import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.sharedmq.Message;
import org.sharedmq.test.CommonTests;
import java.io.File;
import static org.sharedmq.test.TestUtils.assertThrows; | package org.sharedmq.internals;
@Category(CommonTests.class)
public class QueueParametersValidatorTest {
@Test
public void testValidateCreateQueue() {
File rootFolder = new File("some.folder");
QueueParametersValidator.validateCreateQueue(rootFolder, 0, 15 * 1000L);
QueueParametersValidator.validateCreateQueue(rootFolder, 12 * 60 * 60 * 1000L, 14 * 24 * 60 * 60 * 1000L);
// check rootFolder validation | // Path: src/main/java/org/sharedmq/Message.java
// public interface Message {
// /**
// * @return The message body as a string.
// */
// String asString();
// }
//
// Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
// Path: src/test/java/org/sharedmq/internals/QueueParametersValidatorTest.java
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.sharedmq.Message;
import org.sharedmq.test.CommonTests;
import java.io.File;
import static org.sharedmq.test.TestUtils.assertThrows;
package org.sharedmq.internals;
@Category(CommonTests.class)
public class QueueParametersValidatorTest {
@Test
public void testValidateCreateQueue() {
File rootFolder = new File("some.folder");
QueueParametersValidator.validateCreateQueue(rootFolder, 0, 15 * 1000L);
QueueParametersValidator.validateCreateQueue(rootFolder, 12 * 60 * 60 * 1000L, 14 * 24 * 60 * 60 * 1000L);
// check rootFolder validation | assertThrows( |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/internals/QueueParametersValidatorTest.java | // Path: src/main/java/org/sharedmq/Message.java
// public interface Message {
// /**
// * @return The message body as a string.
// */
// String asString();
// }
//
// Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
| import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.sharedmq.Message;
import org.sharedmq.test.CommonTests;
import java.io.File;
import static org.sharedmq.test.TestUtils.assertThrows; | () -> QueueParametersValidator.validatePush(1, Strings.repeat("\u044F", 256 * 1024)));
}
@Test
public void testValidatePull() {
QueueParametersValidator.validatePull(0);
QueueParametersValidator.validatePull(20000);
// timeout validation
assertThrows(IllegalArgumentException.class,
"timeout in milliseconds must be between 0 and 20000",
() -> QueueParametersValidator.validatePull(-1));
assertThrows(IllegalArgumentException.class,
"timeout in milliseconds must be between 0 and 20000",
() -> QueueParametersValidator.validatePull(20001));
}
@Test
public void testValidateDelete() {
QueueParametersValidator.validateDelete(Mockito.mock(SharedQueueMessage.class));
// message validation
assertThrows(IllegalArgumentException.class,
"message parameter cannot be null",
() -> QueueParametersValidator.validateDelete(null));
assertThrows(IllegalArgumentException.class,
"message type does not belong to this message queue", | // Path: src/main/java/org/sharedmq/Message.java
// public interface Message {
// /**
// * @return The message body as a string.
// */
// String asString();
// }
//
// Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
// Path: src/test/java/org/sharedmq/internals/QueueParametersValidatorTest.java
import com.google.common.base.Strings;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.sharedmq.Message;
import org.sharedmq.test.CommonTests;
import java.io.File;
import static org.sharedmq.test.TestUtils.assertThrows;
() -> QueueParametersValidator.validatePush(1, Strings.repeat("\u044F", 256 * 1024)));
}
@Test
public void testValidatePull() {
QueueParametersValidator.validatePull(0);
QueueParametersValidator.validatePull(20000);
// timeout validation
assertThrows(IllegalArgumentException.class,
"timeout in milliseconds must be between 0 and 20000",
() -> QueueParametersValidator.validatePull(-1));
assertThrows(IllegalArgumentException.class,
"timeout in milliseconds must be between 0 and 20000",
() -> QueueParametersValidator.validatePull(20001));
}
@Test
public void testValidateDelete() {
QueueParametersValidator.validateDelete(Mockito.mock(SharedQueueMessage.class));
// message validation
assertThrows(IllegalArgumentException.class,
"message parameter cannot be null",
() -> QueueParametersValidator.validateDelete(null));
assertThrows(IllegalArgumentException.class,
"message type does not belong to this message queue", | () -> QueueParametersValidator.validateDelete(Mockito.mock(Message.class))); |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/internals/ConfigurationFileTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.sharedmq.test.TestUtils.assertThrows; | package org.sharedmq.internals;
@Category(CommonTests.class)
public class ConfigurationFileTest {
@Test
public void testCreateAndOpen() throws IOException, InterruptedException { | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
// Path: src/test/java/org/sharedmq/internals/ConfigurationFileTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.sharedmq.test.TestUtils.assertThrows;
package org.sharedmq.internals;
@Category(CommonTests.class)
public class ConfigurationFileTest {
@Test
public void testCreateAndOpen() throws IOException, InterruptedException { | try (TestFolder testFolder = new TestFolder("ConfigurationFileTest", "testCreateAndOpen")) { |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/internals/ConfigurationFileTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.sharedmq.test.TestUtils.assertThrows; | package org.sharedmq.internals;
@Category(CommonTests.class)
public class ConfigurationFileTest {
@Test
public void testCreateAndOpen() throws IOException, InterruptedException {
try (TestFolder testFolder = new TestFolder("ConfigurationFileTest", "testCreateAndOpen")) {
File file = testFolder.getFile("config.dat");
| // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
// Path: src/test/java/org/sharedmq/internals/ConfigurationFileTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.sharedmq.test.TestUtils.assertThrows;
package org.sharedmq.internals;
@Category(CommonTests.class)
public class ConfigurationFileTest {
@Test
public void testCreateAndOpen() throws IOException, InterruptedException {
try (TestFolder testFolder = new TestFolder("ConfigurationFileTest", "testCreateAndOpen")) {
File file = testFolder.getFile("config.dat");
| assertThrows( |
yu-kopylov/shared-mq | src/main/java/org/sharedmq/internals/MessageHeader.java | // Path: src/main/java/org/sharedmq/primitives/MappedByteArrayStorageKey.java
// public class MappedByteArrayStorageKey {
//
// private final int segmentNumber;
// private final int recordNumber;
// private final long recordId;
//
// public MappedByteArrayStorageKey(int segmentNumber, int recordNumber, long recordId) {
// this.segmentNumber = segmentNumber;
// this.recordNumber = recordNumber;
// this.recordId = recordId;
// }
//
// /**
// * The number of segment where record is stored.
// */
// public int getSegmentNumber() {
// return segmentNumber;
// }
//
// /**
// * The number of record with segment.
// */
// public int getRecordNumber() {
// return recordNumber;
// }
//
// /**
// * The unique identifier of the stored byte array.<br/>
// * Records within segment are reusable,
// * so we need an additional key to check that this key belongs to the stored byte array.
// */
// public long getRecordId() {
// return recordId;
// }
// }
| import org.sharedmq.primitives.MappedByteArrayStorageKey; | package org.sharedmq.internals;
/**
* This class contains message properties and references.
*/
public class MessageHeader {
private final long messageId;
private final int messageNumber;
private long sentTime;
private long delay;
private Long receivedTime;
private int heapIndex; | // Path: src/main/java/org/sharedmq/primitives/MappedByteArrayStorageKey.java
// public class MappedByteArrayStorageKey {
//
// private final int segmentNumber;
// private final int recordNumber;
// private final long recordId;
//
// public MappedByteArrayStorageKey(int segmentNumber, int recordNumber, long recordId) {
// this.segmentNumber = segmentNumber;
// this.recordNumber = recordNumber;
// this.recordId = recordId;
// }
//
// /**
// * The number of segment where record is stored.
// */
// public int getSegmentNumber() {
// return segmentNumber;
// }
//
// /**
// * The number of record with segment.
// */
// public int getRecordNumber() {
// return recordNumber;
// }
//
// /**
// * The unique identifier of the stored byte array.<br/>
// * Records within segment are reusable,
// * so we need an additional key to check that this key belongs to the stored byte array.
// */
// public long getRecordId() {
// return recordId;
// }
// }
// Path: src/main/java/org/sharedmq/internals/MessageHeader.java
import org.sharedmq.primitives.MappedByteArrayStorageKey;
package org.sharedmq.internals;
/**
* This class contains message properties and references.
*/
public class MessageHeader {
private final long messageId;
private final int messageNumber;
private long sentTime;
private long delay;
private Long receivedTime;
private int heapIndex; | private MappedByteArrayStorageKey bodyKey; |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/primitives/MappedByteArrayStorageTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public class TestUtils {
//
// // random is only used for quick generation of non-empty arrays
// private static final Random random = new Random();
//
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
//
// public interface TestedAction {
// void invoke() throws Exception;
// }
//
// public static byte[] generateArray(int length) {
// byte[] array = new byte[length];
// random.nextBytes(array);
// return array;
// }
//
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
//
// public static void printResult(String prefix, long timeSpent, int operationCount) {
// String messagesPerSecond = timeSpent == 0 ? "unknown" : String.valueOf(operationCount * 1000L / timeSpent);
//
// long operationTime = timeSpent * 1000L / operationCount;
//
// System.out.println(Strings.padEnd(prefix, 39, ' ') +
// ": " + operationCount + " operations" +
// ", " + Strings.padStart(String.valueOf(timeSpent), 5, ' ') + "ms" +
// " (" + Strings.padStart(String.valueOf(operationTime), 5, ' ') + "\u00B5s per op." +
// ", " + Strings.padStart(messagesPerSecond, 6, ' ') + " op/second).");
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import org.sharedmq.test.TestUtils;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.*; | package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedByteArrayStorageTest {
@Test
public void testSmoke() throws IOException {
try ( | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public class TestUtils {
//
// // random is only used for quick generation of non-empty arrays
// private static final Random random = new Random();
//
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
//
// public interface TestedAction {
// void invoke() throws Exception;
// }
//
// public static byte[] generateArray(int length) {
// byte[] array = new byte[length];
// random.nextBytes(array);
// return array;
// }
//
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
//
// public static void printResult(String prefix, long timeSpent, int operationCount) {
// String messagesPerSecond = timeSpent == 0 ? "unknown" : String.valueOf(operationCount * 1000L / timeSpent);
//
// long operationTime = timeSpent * 1000L / operationCount;
//
// System.out.println(Strings.padEnd(prefix, 39, ' ') +
// ": " + operationCount + " operations" +
// ", " + Strings.padStart(String.valueOf(timeSpent), 5, ' ') + "ms" +
// " (" + Strings.padStart(String.valueOf(operationTime), 5, ' ') + "\u00B5s per op." +
// ", " + Strings.padStart(messagesPerSecond, 6, ' ') + " op/second).");
// }
// }
// Path: src/test/java/org/sharedmq/primitives/MappedByteArrayStorageTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import org.sharedmq.test.TestUtils;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.*;
package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedByteArrayStorageTest {
@Test
public void testSmoke() throws IOException {
try ( | TestFolder testFolder = new TestFolder("MappedByteArrayStorageTest", "testSmoke"); |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/primitives/MappedByteArrayStorageTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public class TestUtils {
//
// // random is only used for quick generation of non-empty arrays
// private static final Random random = new Random();
//
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
//
// public interface TestedAction {
// void invoke() throws Exception;
// }
//
// public static byte[] generateArray(int length) {
// byte[] array = new byte[length];
// random.nextBytes(array);
// return array;
// }
//
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
//
// public static void printResult(String prefix, long timeSpent, int operationCount) {
// String messagesPerSecond = timeSpent == 0 ? "unknown" : String.valueOf(operationCount * 1000L / timeSpent);
//
// long operationTime = timeSpent * 1000L / operationCount;
//
// System.out.println(Strings.padEnd(prefix, 39, ' ') +
// ": " + operationCount + " operations" +
// ", " + Strings.padStart(String.valueOf(timeSpent), 5, ' ') + "ms" +
// " (" + Strings.padStart(String.valueOf(operationTime), 5, ' ') + "\u00B5s per op." +
// ", " + Strings.padStart(messagesPerSecond, 6, ' ') + " op/second).");
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import org.sharedmq.test.TestUtils;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.*; | package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedByteArrayStorageTest {
@Test
public void testSmoke() throws IOException {
try (
TestFolder testFolder = new TestFolder("MappedByteArrayStorageTest", "testSmoke");
MemoryMappedFile file = new MemoryMappedFile(testFolder.getFile("test.dat"));
MappedByteArrayStorage storage = new MappedByteArrayStorage(file)
) { | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
//
// Path: src/test/java/org/sharedmq/test/TestUtils.java
// public class TestUtils {
//
// // random is only used for quick generation of non-empty arrays
// private static final Random random = new Random();
//
// public static <T extends Exception> void assertThrows(
// Class<T> errorClass,
// String expectedMessagePart,
// TestedAction action
// ) {
// try {
// action.invoke();
// fail("an exception was expected");
// } catch (AssertionError e) {
// throw e;
// } catch (Throwable e) {
// if (!errorClass.isInstance(e)) {
// throw new AssertionError("Expected '" + errorClass.getName() + "'" +
// ", but encountered '" + e.getClass().getName() + "'."
// , e);
// }
// if (expectedMessagePart != null) {
// String message = e.getMessage();
// if (message == null || !message.contains(expectedMessagePart)) {
// throw new AssertionError("Expected an exception" +
// " with the message '..." + expectedMessagePart + "...'" +
// ", but encountered '" + e.getMessage() + "'."
// , e);
// }
// }
// }
// }
//
// public interface TestedAction {
// void invoke() throws Exception;
// }
//
// public static byte[] generateArray(int length) {
// byte[] array = new byte[length];
// random.nextBytes(array);
// return array;
// }
//
// public static void printResult(String prefix, Stopwatch timer, int operationCount) {
// printResult(prefix, timer.elapsed(TimeUnit.MILLISECONDS), operationCount);
// }
//
// public static void printResult(String prefix, long timeSpent, int operationCount) {
// String messagesPerSecond = timeSpent == 0 ? "unknown" : String.valueOf(operationCount * 1000L / timeSpent);
//
// long operationTime = timeSpent * 1000L / operationCount;
//
// System.out.println(Strings.padEnd(prefix, 39, ' ') +
// ": " + operationCount + " operations" +
// ", " + Strings.padStart(String.valueOf(timeSpent), 5, ' ') + "ms" +
// " (" + Strings.padStart(String.valueOf(operationTime), 5, ' ') + "\u00B5s per op." +
// ", " + Strings.padStart(messagesPerSecond, 6, ' ') + " op/second).");
// }
// }
// Path: src/test/java/org/sharedmq/primitives/MappedByteArrayStorageTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import org.sharedmq.test.TestUtils;
import java.io.IOException;
import java.util.Arrays;
import static org.junit.Assert.*;
package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedByteArrayStorageTest {
@Test
public void testSmoke() throws IOException {
try (
TestFolder testFolder = new TestFolder("MappedByteArrayStorageTest", "testSmoke");
MemoryMappedFile file = new MemoryMappedFile(testFolder.getFile("test.dat"));
MappedByteArrayStorage storage = new MappedByteArrayStorage(file)
) { | byte[] originalArray1 = TestUtils.generateArray(20); |
yu-kopylov/shared-mq | src/test/java/org/sharedmq/primitives/MappedHeapTest.java | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
| import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; | package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedHeapTest {
@Test
public void testAddPeekAndPoll() throws IOException { | // Path: src/test/java/org/sharedmq/test/CommonTests.java
// public interface CommonTests {
// }
//
// Path: src/test/java/org/sharedmq/test/TestFolder.java
// public class TestFolder implements Closeable {
//
// private final File root;
//
// /**
// * Creates an new folder in the default temporary-file directory.
// *
// * @param prefix The prefix for the new folder name.
// * @param suffix The suffix for the new folder name.
// * @throws IOException If folder creation fails.
// */
// public TestFolder(String prefix, String suffix) throws IOException {
// root = File.createTempFile(prefix, suffix);
// if (!root.delete() || !root.mkdir()) {
// throw new IOException("Failed to prepare test folder.");
// }
// }
//
// /**
// * Returns a {@link File} object matching this folder location.
// */
// public File getRoot() {
// return root;
// }
//
// /**
// * Returns an {@link File} instance for the file with the given name in this test folder.
// *
// * @param filename The name of the faile.
// */
// public File getFile(String filename) {
// return new File(root, filename);
// }
//
// /**
// * Deletes this test folder and all its content.
// *
// * @throws IOException
// */
// @Override
// public void close() throws IOException {
//
// // A mapped byte buffer and the file mapping that it represents
// // remain valid until the buffer itself is garbage-collected.
// System.gc();
//
// IOUtils.deleteTree(root);
// }
// }
// Path: src/test/java/org/sharedmq/primitives/MappedHeapTest.java
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sharedmq.test.CommonTests;
import org.sharedmq.test.TestFolder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
package org.sharedmq.primitives;
@Category(CommonTests.class)
public class MappedHeapTest {
@Test
public void testAddPeekAndPoll() throws IOException { | try (TestFolder testFolder = new TestFolder("MappedHeapTest", "testAddPeekAndPoll")) { |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/Vespapp.java | // Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.StrictMode;
import android.util.Log;
import com.google.gson.Gson;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.database.Database;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Picasso.Listener;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.Retrofit.Builder;
import retrofit2.converter.gson.GsonConverterFactory; | package com.habitissimo.vespapp;
public class Vespapp extends Application {
private static final boolean FORCE_MOCK = false; | // Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.StrictMode;
import android.util.Log;
import com.google.gson.Gson;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.database.Database;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Picasso.Listener;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.Retrofit.Builder;
import retrofit2.converter.gson.GsonConverterFactory;
package com.habitissimo.vespapp;
public class Vespapp extends Application {
private static final boolean FORCE_MOCK = false; | private Database database; |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/Vespapp.java | // Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.StrictMode;
import android.util.Log;
import com.google.gson.Gson;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.database.Database;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Picasso.Listener;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.Retrofit.Builder;
import retrofit2.converter.gson.GsonConverterFactory; | package com.habitissimo.vespapp;
public class Vespapp extends Application {
private static final boolean FORCE_MOCK = false;
private Database database; | // Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.StrictMode;
import android.util.Log;
import com.google.gson.Gson;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.database.Database;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Picasso.Listener;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.Retrofit.Builder;
import retrofit2.converter.gson.GsonConverterFactory;
package com.habitissimo.vespapp;
public class Vespapp extends Application {
private static final boolean FORCE_MOCK = false;
private Database database; | private VespappApi api; |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/RecyclerViewAdapter.java | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.util.List; | package com.habitissimo.vespapp.sighting;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<String> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<String> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, parent, false);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView, context, new RecyclerViewHolders.Callback() {
@Override
public void onImageDeleted(int index) {
// Update database | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/RecyclerViewAdapter.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.util.List;
package com.habitissimo.vespapp.sighting;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<String> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<String> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, parent, false);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView, context, new RecyclerViewHolders.Callback() {
@Override
public void onImageDeleted(int index) {
// Update database | PicturesActions list = Database.get(context).load(Constants.PICTURES_LIST, PicturesActions.class); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/RecyclerViewAdapter.java | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.util.List; | package com.habitissimo.vespapp.sighting;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<String> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<String> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, parent, false);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView, context, new RecyclerViewHolders.Callback() {
@Override
public void onImageDeleted(int index) {
// Update database | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/RecyclerViewAdapter.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.util.List;
package com.habitissimo.vespapp.sighting;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<String> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<String> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_picture, parent, false);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView, context, new RecyclerViewHolders.Callback() {
@Override
public void onImageDeleted(int index) {
// Update database | PicturesActions list = Database.get(context).load(Constants.PICTURES_LIST, PicturesActions.class); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingDataActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import butterknife.ButterKnife;
import butterknife.OnClick; |
@OnClick(R.id.btn_avispa)
void onWaspPressed() {
onTypeOfSightPressed(Sighting.TYPE_WASP);
}
private void onTypeOfSightPressed(int type) {
Sighting sighting = new Sighting();
sighting.setType(type);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String userEmail = account.name;
sighting.setContact(userEmail);
}
}
// sighting.set_valid(null);
Intent i = new Intent(this, NewSightingLocationsActivity.class);
i.putExtra("sightingObject", sighting);
startActivity(i);
}
private PicturesActions getPicturesList() { | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingDataActivity.java
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import butterknife.ButterKnife;
import butterknife.OnClick;
@OnClick(R.id.btn_avispa)
void onWaspPressed() {
onTypeOfSightPressed(Sighting.TYPE_WASP);
}
private void onTypeOfSightPressed(int type) {
Sighting sighting = new Sighting();
sighting.setType(type);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String userEmail = account.name;
sighting.setContact(userEmail);
}
}
// sighting.set_valid(null);
Intent i = new Intent(this, NewSightingLocationsActivity.class);
i.putExtra("sightingObject", sighting);
startActivity(i);
}
private PicturesActions getPicturesList() { | return Database.get(this).load(Constants.PICTURES_LIST, PicturesActions.class); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingDataActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
| import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import butterknife.ButterKnife;
import butterknife.OnClick; |
@OnClick(R.id.btn_avispa)
void onWaspPressed() {
onTypeOfSightPressed(Sighting.TYPE_WASP);
}
private void onTypeOfSightPressed(int type) {
Sighting sighting = new Sighting();
sighting.setType(type);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String userEmail = account.name;
sighting.setContact(userEmail);
}
}
// sighting.set_valid(null);
Intent i = new Intent(this, NewSightingLocationsActivity.class);
i.putExtra("sightingObject", sighting);
startActivity(i);
}
private PicturesActions getPicturesList() { | // Path: app/src/main/java/com/habitissimo/vespapp/Constants.java
// public class Constants {
// public static final String PICTURES_LIST = "com.habitissimo.vespapp.PICTURES_LIST";
// public static final String KEY_CAPTURE = "com.habitissimo.vespapp.CAPTURE";
// public static final String API_BASE_URL = "http://vespapp.uib.es/api/";
//
// public static boolean isBaseApiUrlDefined() {
// return !TextUtils.isEmpty(API_BASE_URL);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
// public class Database {
// private SharedPreferences preferences;
// private Gson gson;
//
// public Database(Context context, Gson gson) {
// this.gson = gson;
// preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
// }
//
// public static Database get(Context context) {
// return Vespapp.get(context).getDatabase();
// }
//
// public static Database get(Controller controller) {
// return get(controller.getContext());
// }
//
// private SharedPreferences getPrefs() {
// return preferences;
// }
//
// public void save(String key, Object obj) {
// save(key, gson.toJson(obj));
// }
//
// public void save(String key, String value) {
// getStringPref(key).set(value);
// }
//
// public void save(String key, int value) {
// getIntPref(key).set(value);
// }
//
// public void delete(String key) {
// getStringPref(key).delete();
// }
//
// public String load(String key) {
// return getStringPref(key).get();
// }
//
// public <T> T load(String key, Class<T> cls) {
// return gson.fromJson(load(key), cls);
// }
//
// public int loadInt(String key) {
// return getIntPref(key).get();
// }
//
// public void saveInt(String key, int value) {
// getIntPref(key).set(value);
// }
//
// @NonNull private StringPreference getStringPref(String key) {
// return new StringPreference(getPrefs(), key);
// }
//
// @NonNull private IntPreference getIntPref(String key) {
// return new IntPreference(getPrefs(), key);
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingDataActivity.java
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.habitissimo.vespapp.Constants;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.database.Database;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import butterknife.ButterKnife;
import butterknife.OnClick;
@OnClick(R.id.btn_avispa)
void onWaspPressed() {
onTypeOfSightPressed(Sighting.TYPE_WASP);
}
private void onTypeOfSightPressed(int type) {
Sighting sighting = new Sighting();
sighting.setType(type);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String userEmail = account.name;
sighting.setContact(userEmail);
}
}
// sighting.set_valid(null);
Intent i = new Intent(this, NewSightingLocationsActivity.class);
i.putExtra("sightingObject", sighting);
startActivity(i);
}
private PicturesActions getPicturesList() { | return Database.get(this).load(Constants.PICTURES_LIST, PicturesActions.class); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/database/Database.java | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import com.google.gson.Gson;
import com.habitissimo.vespapp.Vespapp; | package com.habitissimo.vespapp.database;
public class Database {
private SharedPreferences preferences;
private Gson gson;
public Database(Context context, Gson gson) {
this.gson = gson;
preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
}
public static Database get(Context context) { | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
// Path: app/src/main/java/com/habitissimo/vespapp/database/Database.java
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import com.google.gson.Gson;
import com.habitissimo.vespapp.Vespapp;
package com.habitissimo.vespapp.database;
public class Database {
private SharedPreferences preferences;
private Gson gson;
public Database(Context context, Gson gson) {
this.gson = gson;
preferences = context.getSharedPreferences("database", Context.MODE_PRIVATE);
}
public static Database get(Context context) { | return Vespapp.get(context).getDatabase(); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | package com.habitissimo.vespapp.sighting;
public class NewSightingLocationsActivity extends AppCompatActivity {
private Sighting sighting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_sighting_locations);
initToolbar();
Intent i = getIntent();
sighting = (Sighting) i.getSerializableExtra("sightingObject");
initList();
}
private void initToolbar() {
// Set a toolbar to replace the action bar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_locations_list);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){ | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
package com.habitissimo.vespapp.sighting;
public class NewSightingLocationsActivity extends AppCompatActivity {
private Sighting sighting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_sighting_locations);
initToolbar();
Intent i = getIntent();
sighting = (Sighting) i.getSerializableExtra("sightingObject");
initList();
}
private void initToolbar() {
// Set a toolbar to replace the action bar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_locations_list);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){ | final VespappApi api = Vespapp.get(this).getApi(); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | package com.habitissimo.vespapp.sighting;
public class NewSightingLocationsActivity extends AppCompatActivity {
private Sighting sighting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_sighting_locations);
initToolbar();
Intent i = getIntent();
sighting = (Sighting) i.getSerializableExtra("sightingObject");
initList();
}
private void initToolbar() {
// Set a toolbar to replace the action bar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_locations_list);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){ | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
package com.habitissimo.vespapp.sighting;
public class NewSightingLocationsActivity extends AppCompatActivity {
private Sighting sighting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_sighting_locations);
initToolbar();
Intent i = getIntent();
sighting = (Sighting) i.getSerializableExtra("sightingObject");
initList();
}
private void initToolbar() {
// Set a toolbar to replace the action bar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_locations_list);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){ | final VespappApi api = Vespapp.get(this).getApi(); |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){
final VespappApi api = Vespapp.get(this).getApi();
final Callback<List<Location>> callback = new Callback<List<Location>>() {
@Override
public void onResponse(Call<List<Location>> call, Response<List<Location>> response) {
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_locations_list);
final List<Location> locationList = response.body();
for (final Location location : locationList) {
addItemList(location);
}
}
@Override
public void onFailure(Call<List<Location>> call, Throwable t) {
System.out.println("onFailure " + t);
}
}; | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){
final VespappApi api = Vespapp.get(this).getApi();
final Callback<List<Location>> callback = new Callback<List<Location>>() {
@Override
public void onResponse(Call<List<Location>> call, Response<List<Location>> response) {
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_locations_list);
final List<Location> locationList = response.body();
for (final Location location : locationList) {
addItemList(location);
}
}
@Override
public void onFailure(Call<List<Location>> call, Throwable t) {
System.out.println("onFailure " + t);
}
}; | Task.doInBackground(new TaskCallback<List<Location>>() { |
CarlosTenorio/vespapp-android | app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; | toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){
final VespappApi api = Vespapp.get(this).getApi();
final Callback<List<Location>> callback = new Callback<List<Location>>() {
@Override
public void onResponse(Call<List<Location>> call, Response<List<Location>> response) {
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_locations_list);
final List<Location> locationList = response.body();
for (final Location location : locationList) {
addItemList(location);
}
}
@Override
public void onFailure(Call<List<Location>> call, Throwable t) {
System.out.println("onFailure " + t);
}
}; | // Path: app/src/main/java/com/habitissimo/vespapp/Vespapp.java
// public class Vespapp extends Application {
// private static final boolean FORCE_MOCK = false;
// private Database database;
// private VespappApi api;
// private Gson gson;
// private OkHttpClient httpClient;
//
// public static Vespapp get(Context context) {
// return (Vespapp) context.getApplicationContext();
// }
//
// private void setStrictModeConfigurationWorkaround() {
// //Workaround for modifying StrictMode parameters.
// //See http://code.google.com/p/android/issues/detail?id=35298
// new Handler().postAtFrontOfQueue(new Runnable() {
// @Override public void run() {
// setStrictModeConfiguration();
// }
// });
// }
//
// private void setStrictModeConfiguration() {
// StrictMode.ThreadPolicy policy;
// policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// @Override public void onCreate() {
// setStrictModeConfiguration();
// super.onCreate();
// setStrictModeConfigurationWorkaround();
//
// Iconify.with(new FontAwesomeModule());
//
// gson = new Gson();
// database = new Database(this, gson);
// httpClient = new OkHttpClient.Builder()
// .build();
// Picasso.setSingletonInstance(new Picasso.Builder(this)
// .listener(new Listener() {
// @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
// Log.d("Picasso", "Image failed loading: " + exception);
// }
// })
// .build());
//
// if (Constants.isBaseApiUrlDefined() && !FORCE_MOCK) {
// Retrofit retrofit = new Builder()
// .baseUrl(Constants.API_BASE_URL)
// .addConverterFactory(GsonConverterFactory.create(gson))
// .client(httpClient)
// .build();
// api = retrofit.create(VespappApi.class);
// }
// }
//
// public Database getDatabase() {
// return database;
// }
//
// public VespappApi getApi() {
// if (api == null)
// throw new RuntimeException("Constants.API_BASE_URL is not defined");
//
// return api;
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/api/VespappApi.java
// public interface VespappApi {
//
// @GET("sightings/{sightingId}/questions/")
// Call<List<Question>> getQuestions(@Path("sightingId") String sightingId);
//
// @GET("sightings/{sightingId}/photos/")
// Call <List<Picture>> getPhotos(@Path("sightingId") String sightingId);
//
// @GET("locations/")
// Call<List<Location>> getLocations();
//
// @GET("sightings/")
// Call<List<Sighting>> getSightings();
//
// @GET("info/")
// Call<List<Info>> getInfo();
//
// @POST("sightings/")
// Call<Sighting> createSighting(@Body Sighting sighting);
//
// @PUT("sightings/{sightingId}/")
// Call<Sighting> updateSighting(@Body Sighting sighting, @Path("sightingId") String sightingId);
//
// /**
// * @see VespappApiHelper#buildPhotoApiParameter(File)
// */
// @Multipart
// @POST("sightings/{sightingId}/photos/")
// Call<Void> addPhoto(@Path("sightingId") String sightingId, @Part("file\"; filename=\"photo.png\" ") RequestBody photo);
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/Task.java
// public class Task {
// public static <T> void doInBackground(final TaskCallback<T> taskCallback) {
// new AsyncTask<Void, Void, T>() {
// @Override protected T doInBackground(Void... params) {
// try {
// return taskCallback.executeInBackground();
// } catch (Throwable t) {
// taskCallback.onError(t);
// return null;
// }
// }
//
// @Override protected void onPostExecute(T t) {
// if (t != null) {
// taskCallback.onCompleted(t);
// }
// }
// }.execute((Void) null);
// }
// }
//
// Path: app/src/main/java/com/habitissimo/vespapp/async/TaskCallback.java
// public interface TaskCallback<T> {
// T executeInBackground();
//
// void onError(Throwable t);
//
// void onCompleted(T t);
// }
// Path: app/src/main/java/com/habitissimo/vespapp/sighting/NewSightingLocationsActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitissimo.vespapp.R;
import com.habitissimo.vespapp.Vespapp;
import com.habitissimo.vespapp.api.VespappApi;
import com.habitissimo.vespapp.async.Task;
import com.habitissimo.vespapp.async.TaskCallback;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.confirm_cap_location);
}
private void initList(){
final VespappApi api = Vespapp.get(this).getApi();
final Callback<List<Location>> callback = new Callback<List<Location>>() {
@Override
public void onResponse(Call<List<Location>> call, Response<List<Location>> response) {
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_locations_list);
final List<Location> locationList = response.body();
for (final Location location : locationList) {
addItemList(location);
}
}
@Override
public void onFailure(Call<List<Location>> call, Throwable t) {
System.out.println("onFailure " + t);
}
}; | Task.doInBackground(new TaskCallback<List<Location>>() { |
BraisGabin/couchbase-lite-orm | compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/ProcessorTest.java | // Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/TestProcessors.java
// static Iterable<? extends javax.annotation.processing.Processor> processors() {
// return Collections.singletonList(
// new Processor()
// );
// }
| import com.google.testing.compile.JavaFileObjects;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import javax.tools.JavaFileObject;
import static com.braisgabin.couchbaseliteorm.compiler.TestProcessors.processors;
import static com.google.common.truth.Truth.ASSERT;
import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;
import static com.google.testing.compile.JavaSourcesSubjectFactory.javaSources; | );
}
private static Path qualifiedNameToPath(String compilerPath, String sampleName, String fullyQualifiedName) {
return Paths.get(compilerPath
+ "/../source-samples/"
+ sampleName
+ "/src/main/java/"
+ fullyQualifiedName.replaceAll("\\.", "/")
+ ".java");
}
@Before
public void init() {
// FIXME this is a workaround.
this.compilerPath = System.getProperty("compilerProjectPath");
if (this.compilerPath == null) {
this.compilerPath = "./compiler";
}
}
@Test
public void simpleCompile() throws IOException {
final String sampleName = "simple";
final JavaFileObject inputFile = getJavaFileObject(compilerPath, sampleName, "com.samples.Person");
final JavaFileObject expectedFile1 = getJavaFileObject(compilerPath, sampleName, "com.samples.Person$$Mapper");
final JavaFileObject expectedFile2 = getJavaFileObject(compilerPath, sampleName, "com.braisgabin.couchbaseliteorm.CouchbaseLiteOrmInternal");
ASSERT.about(javaSource())
.that(inputFile) | // Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/TestProcessors.java
// static Iterable<? extends javax.annotation.processing.Processor> processors() {
// return Collections.singletonList(
// new Processor()
// );
// }
// Path: compiler/src/test/java/com/braisgabin/couchbaseliteorm/compiler/ProcessorTest.java
import com.google.testing.compile.JavaFileObjects;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import javax.tools.JavaFileObject;
import static com.braisgabin.couchbaseliteorm.compiler.TestProcessors.processors;
import static com.google.common.truth.Truth.ASSERT;
import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;
import static com.google.testing.compile.JavaSourcesSubjectFactory.javaSources;
);
}
private static Path qualifiedNameToPath(String compilerPath, String sampleName, String fullyQualifiedName) {
return Paths.get(compilerPath
+ "/../source-samples/"
+ sampleName
+ "/src/main/java/"
+ fullyQualifiedName.replaceAll("\\.", "/")
+ ".java");
}
@Before
public void init() {
// FIXME this is a workaround.
this.compilerPath = System.getProperty("compilerProjectPath");
if (this.compilerPath == null) {
this.compilerPath = "./compiler";
}
}
@Test
public void simpleCompile() throws IOException {
final String sampleName = "simple";
final JavaFileObject inputFile = getJavaFileObject(compilerPath, sampleName, "com.samples.Person");
final JavaFileObject expectedFile1 = getJavaFileObject(compilerPath, sampleName, "com.samples.Person$$Mapper");
final JavaFileObject expectedFile2 = getJavaFileObject(compilerPath, sampleName, "com.braisgabin.couchbaseliteorm.CouchbaseLiteOrmInternal");
ASSERT.about(javaSource())
.that(inputFile) | .processedWith(processors()) |
BraisGabin/couchbase-lite-orm | core/src/test/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmTest.java | // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
| import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Document;
import com.samples.Person;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.ASSERT;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 9/1/15.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(Document.class)
public class CouchbaseLiteOrmTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void checkFactory() {
final CouchbaseLiteOrm orm = CouchbaseLiteOrm.newInstance();
ASSERT.that(orm).isInstanceOf(CouchbaseLiteOrmInternal.class);
}
@Test
public void checkToObject_correct() {
Document document = PowerMockito.mock(Document.class); // FIXME remove PowerMockito
final HashMap<String, Object> properties = new HashMap<>();
properties.put("type", "person");
properties.put("name", "Pepe");
properties.put("age", 23);
when(document.getProperties()).thenReturn(properties);
CouchbaseLiteOrm orm = new CouchbaseLiteOrmInternal();
| // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
// Path: core/src/test/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmTest.java
import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Document;
import com.samples.Person;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.ASSERT;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 9/1/15.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(Document.class)
public class CouchbaseLiteOrmTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void checkFactory() {
final CouchbaseLiteOrm orm = CouchbaseLiteOrm.newInstance();
ASSERT.that(orm).isInstanceOf(CouchbaseLiteOrmInternal.class);
}
@Test
public void checkToObject_correct() {
Document document = PowerMockito.mock(Document.class); // FIXME remove PowerMockito
final HashMap<String, Object> properties = new HashMap<>();
properties.put("type", "person");
properties.put("name", "Pepe");
properties.put("age", 23);
when(document.getProperties()).thenReturn(properties);
CouchbaseLiteOrm orm = new CouchbaseLiteOrmInternal();
| Person person = orm.toObject(document); |
BraisGabin/couchbase-lite-orm | compiler/src/main/java/com/braisgabin/couchbaseliteorm/compiler/MapperEmitter.java | // Path: core/src/main/java/com/braisgabin/couchbaseliteorm/Mapper.java
// public interface Mapper<T> {
//
// T toObject(Map<String, Object> properties);
//
// Map<String, Object> toProperties(T object);
// }
| import com.braisgabin.couchbaseliteorm.Mapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.Filer;
import static javax.lang.model.element.Modifier.PUBLIC; | package com.braisgabin.couchbaseliteorm.compiler;
public class MapperEmitter extends Emitter {
private final Helper helper;
private final EntityModel model;
public MapperEmitter(Helper helper, Filer filer, EntityModel model) throws IOException {
super(filer, model.getMapper().getPackage(), model.getMapper().getName(), model.getElement());
this.helper = helper;
this.model = model;
}
@Override
protected Set<String> getImports() {
final Set<String> imports = new HashSet<>(Arrays.asList(
Map.class.getCanonicalName(),
HashMap.class.getCanonicalName(), | // Path: core/src/main/java/com/braisgabin/couchbaseliteorm/Mapper.java
// public interface Mapper<T> {
//
// T toObject(Map<String, Object> properties);
//
// Map<String, Object> toProperties(T object);
// }
// Path: compiler/src/main/java/com/braisgabin/couchbaseliteorm/compiler/MapperEmitter.java
import com.braisgabin.couchbaseliteorm.Mapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.Filer;
import static javax.lang.model.element.Modifier.PUBLIC;
package com.braisgabin.couchbaseliteorm.compiler;
public class MapperEmitter extends Emitter {
private final Helper helper;
private final EntityModel model;
public MapperEmitter(Helper helper, Filer filer, EntityModel model) throws IOException {
super(filer, model.getMapper().getPackage(), model.getMapper().getName(), model.getElement());
this.helper = helper;
this.model = model;
}
@Override
protected Set<String> getImports() {
final Set<String> imports = new HashSet<>(Arrays.asList(
Map.class.getCanonicalName(),
HashMap.class.getCanonicalName(), | Mapper.class.getCanonicalName() |
BraisGabin/couchbase-lite-orm | source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java | // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
| import com.samples.Person;
import com.samples.Person$$Mapper; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() { | // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
// Path: source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
import com.samples.Person;
import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() { | final Person$$Mapper personMapper = new Person$$Mapper(); |
BraisGabin/couchbase-lite-orm | source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java | // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
| import com.samples.Person;
import com.samples.Person$$Mapper; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Person$$Mapper personMapper = new Person$$Mapper(); | // Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
// Path: source-samples/simple/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
import com.samples.Person;
import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Person$$Mapper personMapper = new Person$$Mapper(); | registerType("person", Person.class, personMapper); |
BraisGabin/couchbase-lite-orm | source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
| import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() { | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
// Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() { | final Address$$Mapper addressMapper = new Address$$Mapper(); |
BraisGabin/couchbase-lite-orm | source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
| import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Address$$Mapper addressMapper = new Address$$Mapper(); | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
// Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Address$$Mapper addressMapper = new Address$$Mapper(); | final Person$$Mapper personMapper = new Person$$Mapper(); |
BraisGabin/couchbase-lite-orm | source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
| import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper; | package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Address$$Mapper addressMapper = new Address$$Mapper();
final Person$$Mapper personMapper = new Person$$Mapper();
personMapper.addressMapper = addressMapper; | // Path: source-samples/objects/src/main/java/com/samples/Address$$Mapper.java
// public class Address$$Mapper implements Mapper<Address> {
//
// @Override
// public Address toObject(Map<String, Object> properties) {
// final Address object = new Address();
// object.street = (String) properties.get("street");
// if (object.street == null && !properties.containsKey("street")) {
// throw new IllegalStateException("The property \"street\" is not set.");
// }
// object.number = (String) properties.get("number");
// if (object.number == null && !properties.containsKey("number")) {
// throw new IllegalStateException("The property \"number\" is not set.");
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Address object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("street", object.street);
// properties.put("number", object.number);
// return properties;
// }
// }
//
// Path: source-samples/simple/src/main/java/com/samples/Person.java
// @Entity("person")
// public class Person {
//
// @Field("name")
// String name;
//
// @Field("age")
// int age;
//
// public Person() {
// }
//
// public Person(String name, Integer age) {
// this.name = name;
// this.age = age;
// }
//
// public String getName() {
// return name;
// }
//
// public Integer getAge() {
// return age;
// }
// }
//
// Path: source-samples/objects/src/main/java/com/samples/Person$$Mapper.java
// public class Person$$Mapper implements Mapper<Person> {
// public Address$$Mapper addressMapper;
//
// @Override
// public Person toObject(Map<String, Object> properties) {
// final Person object = new Person();
// if (properties.get("address") != null) {
// object.address = addressMapper.toObject((Map<String, Object>) properties.get("address"));
// } else if (!properties.containsKey("address")) {
// throw new IllegalStateException("The property \"address\" is not set.");
// } else {
// object.address = null;
// }
// return object;
// }
//
// @Override
// public Map<String, Object> toProperties(Person object) {
// final Map<String, Object> properties = new HashMap<>();
// properties.put("type", "person");
// properties.put("address", object.address == null ? null : addressMapper.toProperties(object.address));
// return properties;
// }
// }
// Path: source-samples/objects/src/main/java/com/braisgabin/couchbaseliteorm/CouchbaseLiteOrmInternal.java
import com.samples.Address$$Mapper;
import com.samples.Person;
import com.samples.Person$$Mapper;
package com.braisgabin.couchbaseliteorm;
/**
* Created by brais on 7/1/15.
*/
class CouchbaseLiteOrmInternal extends CouchbaseLiteOrm {
CouchbaseLiteOrmInternal() {
final Address$$Mapper addressMapper = new Address$$Mapper();
final Person$$Mapper personMapper = new Person$$Mapper();
personMapper.addressMapper = addressMapper; | registerType("person", Person.class, personMapper); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
| import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall; | package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() { | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java
import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall;
package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() { | put("kb", new ZipAppInstall()); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
| import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall; | package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall()); | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java
import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall;
package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall()); | put("bz2", new BZ2AppInstall()); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
| import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall; | package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall());
put("bz2", new BZ2AppInstall()); | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java
import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall;
package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall());
put("bz2", new BZ2AppInstall()); | put("gzip", new GZipAppInstall()); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
| import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall; | package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall());
put("bz2", new BZ2AppInstall());
put("gzip", new GZipAppInstall());
put("zip", new ZipAppInstall()); | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
// public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// UncompressUtil.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
// public class GZipAppInstall extends AbstractMultiSourceAppInstall {
// public void install(InputStream source, File target) throws Exception {
// GzipUtils.unpack(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ZipAppInstall.java
// public class ZipAppInstall extends AbstractDirectoryDataInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// ZipUtil.unpack(source, target);
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/DefaultInstallFactory.java
import org.aksw.kbox.apple.BZ2AppInstall;
import org.aksw.kbox.apple.GZipAppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
import org.aksw.kbox.apple.ZipAppInstall;
package org.aksw.kbox.kns;
public class DefaultInstallFactory extends InstallFactory {
public DefaultInstallFactory() {
put("kb", new ZipAppInstall());
put("bz2", new BZ2AppInstall());
put("gzip", new GZipAppInstall());
put("zip", new ZipAppInstall()); | put("plain", new ResourceAppInstall()); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/GzipUtils.java
// public class GzipUtils {
//
// public static void pack(File input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(new FileInputStream(input), out);
// }
// }
//
// public static void pack(InputStream input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(input, out);
// }
// }
//
// public static void unpack(InputStream input, File output) throws IOException {
// try (GzipCompressorInputStream in = new GzipCompressorInputStream(input)){
// try(FileOutputStream out = new FileOutputStream(output)){
// IOUtils.copy(in, out);
// }
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.GzipUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class GZipAppInstall extends AbstractMultiSourceAppInstall {
public void install(InputStream source, File target) throws Exception { | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/GzipUtils.java
// public class GzipUtils {
//
// public static void pack(File input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(new FileInputStream(input), out);
// }
// }
//
// public static void pack(InputStream input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(input, out);
// }
// }
//
// public static void unpack(InputStream input, File output) throws IOException {
// try (GzipCompressorInputStream in = new GzipCompressorInputStream(input)){
// try(FileOutputStream out = new FileOutputStream(output)){
// IOUtils.copy(in, out);
// }
// }
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/GZipAppInstall.java
import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.GzipUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class GZipAppInstall extends AbstractMultiSourceAppInstall {
public void install(InputStream source, File target) throws Exception { | GzipUtils.unpack(source, target); |
AKSW/KBox | kbox.core/src/main/java/org/aksw/kbox/KBox.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/ArrayUtils.java
// public class ArrayUtils {
//
// /**
// * This class receive an <T> array and invert it.
// *
// * @param array an <T> array.
// */
// public static <T> void reverse(T[] array) {
// for(int i = 0; i < array.length / 2; i++) {
// T temp = array[i];
// array[i] = array[array.length - i - 1];
// array[array.length - i - 1] = temp;
// }
// }
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/ObjectUtils.java
// public class ObjectUtils extends AssertionUtils {
//
// public static <T> T getValue(T value, T defaultValue) {
// if(value == null) {
// return defaultValue;
// }
// return value;
// }
//
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.InvalidPathException;
import org.aksw.kbox.utils.ArrayUtils;
import org.aksw.kbox.utils.ObjectUtils;
import org.apache.log4j.Logger; | logger.error("Error initializing KBox.", e);
}
}
protected static void init() throws Exception {
File kBoxDir = new File(KBOX_DIR);
if (!kBoxDir.exists()) {
kBoxDir.mkdir();
setResourceFolder(KBOX_DIR);
}
}
private static CustomParams getParams() {
CustomParams params = new CustomParams(KBOX_DIR + File.separator
+ KBOX_CONFIG_FILE, KBOX_CONFIG_CONTEXT);
return params;
}
/**
* Converts an URL to a local path.
*
* @param url an URL.
*/
public static String urlToPath(URL url) {
String urlPath = url.getPath();
String host = url.getHost();
String protocol = url.getProtocol();
int port = url.getPort();
String[] pathDirs = urlPath.split("/");
String[] hostDirs = host.split("\\."); | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/ArrayUtils.java
// public class ArrayUtils {
//
// /**
// * This class receive an <T> array and invert it.
// *
// * @param array an <T> array.
// */
// public static <T> void reverse(T[] array) {
// for(int i = 0; i < array.length / 2; i++) {
// T temp = array[i];
// array[i] = array[array.length - i - 1];
// array[array.length - i - 1] = temp;
// }
// }
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/ObjectUtils.java
// public class ObjectUtils extends AssertionUtils {
//
// public static <T> T getValue(T value, T defaultValue) {
// if(value == null) {
// return defaultValue;
// }
// return value;
// }
//
// }
// Path: kbox.core/src/main/java/org/aksw/kbox/KBox.java
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.InvalidPathException;
import org.aksw.kbox.utils.ArrayUtils;
import org.aksw.kbox.utils.ObjectUtils;
import org.apache.log4j.Logger;
logger.error("Error initializing KBox.", e);
}
}
protected static void init() throws Exception {
File kBoxDir = new File(KBOX_DIR);
if (!kBoxDir.exists()) {
kBoxDir.mkdir();
setResourceFolder(KBOX_DIR);
}
}
private static CustomParams getParams() {
CustomParams params = new CustomParams(KBOX_DIR + File.separator
+ KBOX_CONFIG_FILE, KBOX_CONFIG_CONTEXT);
return params;
}
/**
* Converts an URL to a local path.
*
* @param url an URL.
*/
public static String urlToPath(URL url) {
String urlPath = url.getPath();
String host = url.getHost();
String protocol = url.getProtocol();
int port = url.getPort();
String[] pathDirs = urlPath.split("/");
String[] hostDirs = host.split("\\."); | ArrayUtils.reverse(hostDirs); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/Source.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.File;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.aksw.kbox.utils.URLUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; | JSONObject jsonSource = (JSONObject) jsonMirror.get(s);
String install = (String) jsonSource.keySet().toArray()[0];
JSONArray jsonSources = (JSONArray) jsonSource.values().toArray()[0];
if(jsonSources != null) {
for(int i= 0; i < jsonSources.size(); i++) {
JSONObject jsonSourceEntry = (JSONObject)jsonSources.get(i);
String url = (String)jsonSourceEntry.get(KN.URL);
JSONObject jsonChecksum = (JSONObject) jsonSourceEntry.get(KN.CHECKSUM);
Map<String, String> checksum = new HashMap<String, String>();
if(jsonChecksum != null) {
for(int c = 0; c < jsonChecksum.keySet().size(); c++) {
String key = (String) jsonChecksum.keySet().toArray()[c];
String value = (String) jsonChecksum.values().toArray()[c];
checksum.put(key, value);
}
}
JSONObject jsonDataId = (JSONObject) jsonSourceEntry.get(KN.DATAID);
Map<String, String> dataId = new HashMap<String, String>();
if(jsonDataId != null) {
for(int di = 0; di < jsonDataId.keySet().size(); di++) {
String key = (String) jsonDataId.keySet().toArray()[di];
String value = (String) jsonDataId.values().toArray()[di];
dataId.put(key, value);
}
}
Source source = new Source();
source.setInstall(install);
source.setChecksum(checksum);
URI uri = new URI(url);
URL knName = null; | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/Source.java
import java.io.File;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.aksw.kbox.utils.URLUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
JSONObject jsonSource = (JSONObject) jsonMirror.get(s);
String install = (String) jsonSource.keySet().toArray()[0];
JSONArray jsonSources = (JSONArray) jsonSource.values().toArray()[0];
if(jsonSources != null) {
for(int i= 0; i < jsonSources.size(); i++) {
JSONObject jsonSourceEntry = (JSONObject)jsonSources.get(i);
String url = (String)jsonSourceEntry.get(KN.URL);
JSONObject jsonChecksum = (JSONObject) jsonSourceEntry.get(KN.CHECKSUM);
Map<String, String> checksum = new HashMap<String, String>();
if(jsonChecksum != null) {
for(int c = 0; c < jsonChecksum.keySet().size(); c++) {
String key = (String) jsonChecksum.keySet().toArray()[c];
String value = (String) jsonChecksum.values().toArray()[c];
checksum.put(key, value);
}
}
JSONObject jsonDataId = (JSONObject) jsonSourceEntry.get(KN.DATAID);
Map<String, String> dataId = new HashMap<String, String>();
if(jsonDataId != null) {
for(int di = 0; di < jsonDataId.keySet().size(); di++) {
String key = (String) jsonDataId.keySet().toArray()[di];
String value = (String) jsonDataId.values().toArray()[di];
dataId.put(key, value);
}
}
Source source = new Source();
source.setInstall(install);
source.setChecksum(checksum);
URI uri = new URI(url);
URL knName = null; | if(uri.isAbsolute() && URLUtils.hasValidURLHost(uri)) { |
AKSW/KBox | kbox.core/src/main/java/org/aksw/kbox/GzipInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/GzipUtils.java
// public class GzipUtils {
//
// public static void pack(File input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(new FileInputStream(input), out);
// }
// }
//
// public static void pack(InputStream input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(input, out);
// }
// }
//
// public static void unpack(InputStream input, File output) throws IOException {
// try (GzipCompressorInputStream in = new GzipCompressorInputStream(input)){
// try(FileOutputStream out = new FileOutputStream(output)){
// IOUtils.copy(in, out);
// }
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.utils.GzipUtils; | package org.aksw.kbox;
/**
* Default install implementation for Gzip compressed files.
*
* @author {@linkplain http://emarx.org}
*
*/
public class GzipInstall extends ResourceInstall {
@Override
public void install(InputStream resource, URL target) throws Exception {
File destPath = new File(urlToAbsolutePath(target));
destPath.mkdirs(); | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/GzipUtils.java
// public class GzipUtils {
//
// public static void pack(File input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(new FileInputStream(input), out);
// }
// }
//
// public static void pack(InputStream input, File output) throws IOException {
// try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))){
// IOUtils.copy(input, out);
// }
// }
//
// public static void unpack(InputStream input, File output) throws IOException {
// try (GzipCompressorInputStream in = new GzipCompressorInputStream(input)){
// try(FileOutputStream out = new FileOutputStream(output)){
// IOUtils.copy(in, out);
// }
// }
// }
// }
// Path: kbox.core/src/main/java/org/aksw/kbox/GzipInstall.java
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.utils.GzipUtils;
package org.aksw.kbox;
/**
* Default install implementation for Gzip compressed files.
*
* @author {@linkplain http://emarx.org}
*
*/
public class GzipInstall extends ResourceInstall {
@Override
public void install(InputStream resource, URL target) throws Exception {
File destPath = new File(urlToAbsolutePath(target));
destPath.mkdirs(); | GzipUtils.unpack(resource, destPath); |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/URLKNSServerList.java | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerList.java
// public interface KNSServerList {
// public boolean visit(KNSServerListVisitor visitor) throws Exception;
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
| import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import org.aksw.kbox.kns.KNSServer;
import org.aksw.kbox.kns.KNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
import org.apache.log4j.Logger; | package org.aksw.kbox.kibe;
public class URLKNSServerList implements KNSServerList {
private URL serverURL;
private final static Logger logger = Logger.getLogger(URLKNSServerList.class);
private final static String DEFAULT_KNS_SERVER_TABLE_URL = "table.server.kns";
public URLKNSServerList(URL serverURL) {
this.serverURL = serverURL;
}
@Override | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerList.java
// public interface KNSServerList {
// public boolean visit(KNSServerListVisitor visitor) throws Exception;
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/URLKNSServerList.java
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import org.aksw.kbox.kns.KNSServer;
import org.aksw.kbox.kns.KNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
import org.apache.log4j.Logger;
package org.aksw.kbox.kibe;
public class URLKNSServerList implements KNSServerList {
private URL serverURL;
private final static Logger logger = Logger.getLogger(URLKNSServerList.class);
private final static String DEFAULT_KNS_SERVER_TABLE_URL = "table.server.kns";
public URLKNSServerList(URL serverURL) {
this.serverURL = serverURL;
}
@Override | public boolean visit(KNSServerListVisitor visitor) throws Exception { |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/URLKNSServerList.java | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerList.java
// public interface KNSServerList {
// public boolean visit(KNSServerListVisitor visitor) throws Exception;
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
| import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import org.aksw.kbox.kns.KNSServer;
import org.aksw.kbox.kns.KNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
import org.apache.log4j.Logger; | package org.aksw.kbox.kibe;
public class URLKNSServerList implements KNSServerList {
private URL serverURL;
private final static Logger logger = Logger.getLogger(URLKNSServerList.class);
private final static String DEFAULT_KNS_SERVER_TABLE_URL = "table.server.kns";
public URLKNSServerList(URL serverURL) {
this.serverURL = serverURL;
}
@Override
public boolean visit(KNSServerListVisitor visitor) throws Exception {
URL serverTable = new URL(serverURL + org.aksw.kbox.URL.SEPARATOR + DEFAULT_KNS_SERVER_TABLE_URL);
boolean next = true;
try(InputStream is = serverTable.openStream()) {
try(BufferedReader in = new BufferedReader(new InputStreamReader(is))) {
String line = null;
while((line = in.readLine()) != null) { | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerList.java
// public interface KNSServerList {
// public boolean visit(KNSServerListVisitor visitor) throws Exception;
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/URLKNSServerList.java
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import org.aksw.kbox.kns.KNSServer;
import org.aksw.kbox.kns.KNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
import org.apache.log4j.Logger;
package org.aksw.kbox.kibe;
public class URLKNSServerList implements KNSServerList {
private URL serverURL;
private final static Logger logger = Logger.getLogger(URLKNSServerList.class);
private final static String DEFAULT_KNS_SERVER_TABLE_URL = "table.server.kns";
public URLKNSServerList(URL serverURL) {
this.serverURL = serverURL;
}
@Override
public boolean visit(KNSServerListVisitor visitor) throws Exception {
URL serverTable = new URL(serverURL + org.aksw.kbox.URL.SEPARATOR + DEFAULT_KNS_SERVER_TABLE_URL);
boolean next = true;
try(InputStream is = serverTable.openStream()) {
try(BufferedReader in = new BufferedReader(new InputStreamReader(is))) {
String line = null;
while((line = in.readLine()) != null) { | KNSServer knsServer = null; |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/DefaultKNSServerList.java | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/CustomKNSServerList.java
// public class CustomKNSServerList extends CustomParams implements KNSServerList {
//
// /**
// *
// */
// private static final long serialVersionUID = -3697460272426263415L;
//
// public final static String CONTEXT_NAME = "kbox.kns";
// public final static String KNS_FILE_NAME = CONTEXT_NAME;
//
// private KNSServerListVisitor visitor = null;
// private boolean next = false;
// private CustomParamKNSServerListVisitor customParamKNSServerListVisitor = null;
//
// public CustomKNSServerList(String path, String contex) {
// super(path
// + File.separator
// + KNS_FILE_NAME,
// CONTEXT_NAME);
// customParamKNSServerListVisitor = new CustomParamKNSServerListVisitor();
//
// }
//
// public CustomKNSServerList() {
// this(KBox.KBOX_DIR,
// CONTEXT_NAME);
// }
//
// public boolean visit(KNSServerListVisitor visitor) throws Exception {
// this.visitor = visitor;
// return super.visit(customParamKNSServerListVisitor);
// }
//
// private class CustomParamKNSServerListVisitor implements CustomParamVisitor {
//
// @Override
// public boolean visit(String param) throws Exception {
// KNSServer knsServer = new KBoxKNSServer(new URL(param));
// next = visitor.visit(knsServer);
// return next;
// }
//
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
| import java.net.MalformedURLException;
import java.net.URL;
import org.aksw.kbox.kns.CustomKNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor; | package org.aksw.kbox.kibe;
public class DefaultKNSServerList extends URLKNSServerList {
// Default KNS table URL
private final static String DEFAULT_KNS_TABLE_URL = "https://raw.githubusercontent.com/AKSW/KBox/master/kns/2.0/";
| // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/CustomKNSServerList.java
// public class CustomKNSServerList extends CustomParams implements KNSServerList {
//
// /**
// *
// */
// private static final long serialVersionUID = -3697460272426263415L;
//
// public final static String CONTEXT_NAME = "kbox.kns";
// public final static String KNS_FILE_NAME = CONTEXT_NAME;
//
// private KNSServerListVisitor visitor = null;
// private boolean next = false;
// private CustomParamKNSServerListVisitor customParamKNSServerListVisitor = null;
//
// public CustomKNSServerList(String path, String contex) {
// super(path
// + File.separator
// + KNS_FILE_NAME,
// CONTEXT_NAME);
// customParamKNSServerListVisitor = new CustomParamKNSServerListVisitor();
//
// }
//
// public CustomKNSServerList() {
// this(KBox.KBOX_DIR,
// CONTEXT_NAME);
// }
//
// public boolean visit(KNSServerListVisitor visitor) throws Exception {
// this.visitor = visitor;
// return super.visit(customParamKNSServerListVisitor);
// }
//
// private class CustomParamKNSServerListVisitor implements CustomParamVisitor {
//
// @Override
// public boolean visit(String param) throws Exception {
// KNSServer knsServer = new KBoxKNSServer(new URL(param));
// next = visitor.visit(knsServer);
// return next;
// }
//
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/DefaultKNSServerList.java
import java.net.MalformedURLException;
import java.net.URL;
import org.aksw.kbox.kns.CustomKNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
package org.aksw.kbox.kibe;
public class DefaultKNSServerList extends URLKNSServerList {
// Default KNS table URL
private final static String DEFAULT_KNS_TABLE_URL = "https://raw.githubusercontent.com/AKSW/KBox/master/kns/2.0/";
| private CustomKNSServerList customKNSServerList = new CustomKNSServerList(); |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/DefaultKNSServerList.java | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/CustomKNSServerList.java
// public class CustomKNSServerList extends CustomParams implements KNSServerList {
//
// /**
// *
// */
// private static final long serialVersionUID = -3697460272426263415L;
//
// public final static String CONTEXT_NAME = "kbox.kns";
// public final static String KNS_FILE_NAME = CONTEXT_NAME;
//
// private KNSServerListVisitor visitor = null;
// private boolean next = false;
// private CustomParamKNSServerListVisitor customParamKNSServerListVisitor = null;
//
// public CustomKNSServerList(String path, String contex) {
// super(path
// + File.separator
// + KNS_FILE_NAME,
// CONTEXT_NAME);
// customParamKNSServerListVisitor = new CustomParamKNSServerListVisitor();
//
// }
//
// public CustomKNSServerList() {
// this(KBox.KBOX_DIR,
// CONTEXT_NAME);
// }
//
// public boolean visit(KNSServerListVisitor visitor) throws Exception {
// this.visitor = visitor;
// return super.visit(customParamKNSServerListVisitor);
// }
//
// private class CustomParamKNSServerListVisitor implements CustomParamVisitor {
//
// @Override
// public boolean visit(String param) throws Exception {
// KNSServer knsServer = new KBoxKNSServer(new URL(param));
// next = visitor.visit(knsServer);
// return next;
// }
//
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
| import java.net.MalformedURLException;
import java.net.URL;
import org.aksw.kbox.kns.CustomKNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor; | package org.aksw.kbox.kibe;
public class DefaultKNSServerList extends URLKNSServerList {
// Default KNS table URL
private final static String DEFAULT_KNS_TABLE_URL = "https://raw.githubusercontent.com/AKSW/KBox/master/kns/2.0/";
private CustomKNSServerList customKNSServerList = new CustomKNSServerList();
public DefaultKNSServerList() throws MalformedURLException {
super(new URL(DEFAULT_KNS_TABLE_URL));
}
@Override | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/CustomKNSServerList.java
// public class CustomKNSServerList extends CustomParams implements KNSServerList {
//
// /**
// *
// */
// private static final long serialVersionUID = -3697460272426263415L;
//
// public final static String CONTEXT_NAME = "kbox.kns";
// public final static String KNS_FILE_NAME = CONTEXT_NAME;
//
// private KNSServerListVisitor visitor = null;
// private boolean next = false;
// private CustomParamKNSServerListVisitor customParamKNSServerListVisitor = null;
//
// public CustomKNSServerList(String path, String contex) {
// super(path
// + File.separator
// + KNS_FILE_NAME,
// CONTEXT_NAME);
// customParamKNSServerListVisitor = new CustomParamKNSServerListVisitor();
//
// }
//
// public CustomKNSServerList() {
// this(KBox.KBOX_DIR,
// CONTEXT_NAME);
// }
//
// public boolean visit(KNSServerListVisitor visitor) throws Exception {
// this.visitor = visitor;
// return super.visit(customParamKNSServerListVisitor);
// }
//
// private class CustomParamKNSServerListVisitor implements CustomParamVisitor {
//
// @Override
// public boolean visit(String param) throws Exception {
// KNSServer knsServer = new KBoxKNSServer(new URL(param));
// next = visitor.visit(knsServer);
// return next;
// }
//
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServerListVisitor.java
// public interface KNSServerListVisitor extends Visitor<KNSServer> {
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/DefaultKNSServerList.java
import java.net.MalformedURLException;
import java.net.URL;
import org.aksw.kbox.kns.CustomKNSServerList;
import org.aksw.kbox.kns.KNSServerListVisitor;
package org.aksw.kbox.kibe;
public class DefaultKNSServerList extends URLKNSServerList {
// Default KNS table URL
private final static String DEFAULT_KNS_TABLE_URL = "https://raw.githubusercontent.com/AKSW/KBox/master/kns/2.0/";
private CustomKNSServerList customKNSServerList = new CustomKNSServerList();
public DefaultKNSServerList() throws MalformedURLException {
super(new URL(DEFAULT_KNS_TABLE_URL));
}
@Override | public boolean visit(KNSServerListVisitor visitor) throws Exception { |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/RDFDir2KBInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
| import java.io.File;
import java.io.InputStream;
import java.net.URL;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.InputStreamFactory; | package org.aksw.kbox.kibe;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class RDFDir2KBInstall extends RDF2KBInstall {
@Override | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/RDFDir2KBInstall.java
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.InputStreamFactory;
package org.aksw.kbox.kibe;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class RDFDir2KBInstall extends RDF2KBInstall {
@Override | public void install(URL[] resources, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception { |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/CompressedAppInstall.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/util/UncompressUtil.java
// public class UncompressUtil {
// public static void unpack(InputStream is, File output) throws IOException, CompressorException {
// try(BufferedInputStream bis = new BufferedInputStream(is)) {
// try(CompressorInputStream input = new CompressorStreamFactory().createCompressorInputStream(bis)) {
// try(OutputStream out = new FileOutputStream(output)) {
// IOUtils.copy(input, out);
// }
// }
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.apple.util.UncompressUtil; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class CompressedAppInstall extends AbstractDirectoryDataInstall {
@Override
public void install(InputStream source, File target) throws Exception { | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/util/UncompressUtil.java
// public class UncompressUtil {
// public static void unpack(InputStream is, File output) throws IOException, CompressorException {
// try(BufferedInputStream bis = new BufferedInputStream(is)) {
// try(CompressorInputStream input = new CompressorStreamFactory().createCompressorInputStream(bis)) {
// try(OutputStream out = new FileOutputStream(output)) {
// IOUtils.copy(input, out);
// }
// }
// }
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/CompressedAppInstall.java
import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.apple.util.UncompressUtil;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class CompressedAppInstall extends AbstractDirectoryDataInstall {
@Override
public void install(InputStream source, File target) throws Exception { | UncompressUtil.unpack(source, target); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractMultiSourceAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.utils.URLUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractMultiSourceAppInstall extends AbstractAppInstall {
public void install(URL[] resources, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception {
InputStream[] inputStreams = new InputStream[resources.length];
int i = 0;
for(URL resource : resources) { | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractMultiSourceAppInstall.java
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractMultiSourceAppInstall extends AbstractAppInstall {
public void install(URL[] resources, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception {
InputStream[] inputStreams = new InputStream[resources.length];
int i = 0;
for(URL resource : resources) { | URL forwardURL = URLUtils.getURLForward(resource); |
AKSW/KBox | kbox.core/src/main/java/org/aksw/kbox/ResourceInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/StreamUtils.java
// public class StreamUtils {
// public static void stream(InputStream inputStream, File destFile) throws FileNotFoundException, IOException {
// ReadableByteChannel rbc = Channels.newChannel(inputStream);
// try (FileOutputStream fos = new FileOutputStream(destFile)) {
// fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.StreamUtils; | package org.aksw.kbox;
/**
* Default install implementation for files.
*
* @author {@linkplain http://emarx.org}
*
*/
public class ResourceInstall extends AbstractInstall {
public ResourceInstall() {
super(new ResourcePathBinder());
}
public void stream(InputStream inputStream, File dest) throws Exception {
File resourceDir = dest.getParentFile();
resourceDir.mkdirs();
dest.createNewFile(); | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/StreamUtils.java
// public class StreamUtils {
// public static void stream(InputStream inputStream, File destFile) throws FileNotFoundException, IOException {
// ReadableByteChannel rbc = Channels.newChannel(inputStream);
// try (FileOutputStream fos = new FileOutputStream(destFile)) {
// fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// }
// }
// }
// Path: kbox.core/src/main/java/org/aksw/kbox/ResourceInstall.java
import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.StreamUtils;
package org.aksw.kbox;
/**
* Default install implementation for files.
*
* @author {@linkplain http://emarx.org}
*
*/
public class ResourceInstall extends AbstractInstall {
public ResourceInstall() {
super(new ResourcePathBinder());
}
public void stream(InputStream inputStream, File dest) throws Exception {
File resourceDir = dest.getParentFile();
resourceDir.mkdirs();
dest.createNewFile(); | StreamUtils.stream(inputStream, dest); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractDirectoryDataInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
| import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractDirectoryDataInstall extends AbstractMultiSourceAppInstall {
protected void createPath(File destPath) throws Exception {
if(destPath.isFile()) {
throw new InvalidParameterException("The parameter destPath should be a directory.");
}
destPath.mkdirs();
}
| // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractDirectoryDataInstall.java
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractDirectoryDataInstall extends AbstractMultiSourceAppInstall {
protected void createPath(File destPath) throws Exception {
if(destPath.isFile()) {
throw new InvalidParameterException("The parameter destPath should be a directory.");
}
destPath.mkdirs();
}
| public void install(URL source, File dest, InputStreamFactory isFactory) throws Exception { |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/util/UncompressUtil.java
// public class UncompressUtil {
// public static void unpack(InputStream is, File output) throws IOException, CompressorException {
// try(BufferedInputStream bis = new BufferedInputStream(is)) {
// try(CompressorInputStream input = new CompressorStreamFactory().createCompressorInputStream(bis)) {
// try(OutputStream out = new FileOutputStream(output)) {
// IOUtils.copy(input, out);
// }
// }
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.apple.util.UncompressUtil; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
public void install(InputStream source, File target) throws Exception { | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/util/UncompressUtil.java
// public class UncompressUtil {
// public static void unpack(InputStream is, File output) throws IOException, CompressorException {
// try(BufferedInputStream bis = new BufferedInputStream(is)) {
// try(CompressorInputStream input = new CompressorStreamFactory().createCompressorInputStream(bis)) {
// try(OutputStream out = new FileOutputStream(output)) {
// IOUtils.copy(input, out);
// }
// }
// }
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/BZ2AppInstall.java
import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.apple.util.UncompressUtil;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class BZ2AppInstall extends AbstractMultiSourceAppInstall {
public void install(InputStream source, File target) throws Exception { | UncompressUtil.unpack(source, target); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
| import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public interface AppInstall {
/**
* Install a given resource in a given URL.
*
* @param resource the URL of the resource that is going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/
public void install(URL resource, URL dest, String format, String version) throws Exception;
/**
* Install a given resource in a given URL.
*
* @param resources the URL to the resources that are going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/
public void install(URL[] resource, URL dest, String format, String version) throws Exception;
/**
* Install a given resource in a given URL.
*
* @param resource the URL of the resource that is going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/ | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AppInstall.java
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public interface AppInstall {
/**
* Install a given resource in a given URL.
*
* @param resource the URL of the resource that is going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/
public void install(URL resource, URL dest, String format, String version) throws Exception;
/**
* Install a given resource in a given URL.
*
* @param resources the URL to the resources that are going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/
public void install(URL[] resource, URL dest, String format, String version) throws Exception;
/**
* Install a given resource in a given URL.
*
* @param resource the URL of the resource that is going to be published.
* @param dest the URL where the resource is going to be published.
* @param format the format.
* @param version the version.
*
* @throws Exception
*/ | public void install(URL resource, URL dest, String format, String version, InputStreamFactory factory) throws Exception; |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/StreamUtils.java
// public class StreamUtils {
// public static void stream(InputStream inputStream, File destFile) throws FileNotFoundException, IOException {
// ReadableByteChannel rbc = Channels.newChannel(inputStream);
// try (FileOutputStream fos = new FileOutputStream(destFile)) {
// fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// }
// }
// }
| import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.StreamUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class ResourceAppInstall extends AbstractAppInstall {
@Override
public void install(InputStream source, File target) throws Exception { | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/StreamUtils.java
// public class StreamUtils {
// public static void stream(InputStream inputStream, File destFile) throws FileNotFoundException, IOException {
// ReadableByteChannel rbc = Channels.newChannel(inputStream);
// try (FileOutputStream fos = new FileOutputStream(destFile)) {
// fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// }
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
import java.io.File;
import java.io.InputStream;
import org.aksw.kbox.utils.StreamUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public class ResourceAppInstall extends AbstractAppInstall {
@Override
public void install(InputStream source, File target) throws Exception { | StreamUtils.stream(source, target); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/KBox.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
| import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory; |
/**
* Returns the local resource path given by the locate.
*
* @param url the resource URL
* @return the local path of the resource.
*/
public static File locate(URL url, String format, String version, Locate locate) throws Exception {
return locate.locate(url, format, version);
}
/**
* Creates a mirror for the given file in a given {@link URL}. This function allows
* KBox to serve files to applications, acting as proxy to the mirrored
* file. The file that is published in a give {@link URL} will be located when the
* client execute the function {@link KBox#getResource(URL)}.
*
* @param source the URL of the file that is going to be published at the
* given {@link URL}.
* @param target the {@link URL} where the resource is going to be published.
* @param install a customized method for installation.
*
* @throws {@link Exception} if the resource does not exist or can not be copied or some
* error occurs during the resource publication.
*/
public static void install(URL source,
URL target,
String format,
String version,
AppInstall install, | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/KBox.java
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
/**
* Returns the local resource path given by the locate.
*
* @param url the resource URL
* @return the local path of the resource.
*/
public static File locate(URL url, String format, String version, Locate locate) throws Exception {
return locate.locate(url, format, version);
}
/**
* Creates a mirror for the given file in a given {@link URL}. This function allows
* KBox to serve files to applications, acting as proxy to the mirrored
* file. The file that is published in a give {@link URL} will be located when the
* client execute the function {@link KBox#getResource(URL)}.
*
* @param source the URL of the file that is going to be published at the
* given {@link URL}.
* @param target the {@link URL} where the resource is going to be published.
* @param install a customized method for installation.
*
* @throws {@link Exception} if the resource does not exist or can not be copied or some
* error occurs during the resource publication.
*/
public static void install(URL source,
URL target,
String format,
String version,
AppInstall install, | InputStreamFactory isFactory) |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/tdb/TDB.java | // Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// public static String[] files2AbsolutePath(File... files) {
// String[] paths = new String[files.length];
// for(int i = 0; i < files.length; i++) {
// paths[i] = files[i].getAbsolutePath();
// }
// return paths;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
//
// private String url = null;
//
// public ServerAddress(String url) {
// this.url = url;
// }
//
// public String getURL() {
// return url;
// }
//
// public String getQueryURL() {
// return url;
// }
// }
| import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction; | package org.aksw.kbox.kibe.tdb;
public class TDB {
public static ResultSet queryGraph(String sparql, String graph, String dbDir) throws Exception {
Query query = QueryFactory.create(sparql, graph);
return query(query, dbDir);
}
public static Model createModel(String... dbDirs) {
Model mainModel = null;
Dataset dataset = null;
for(String dbDir : dbDirs) {
dataset = TDBFactory.createDataset(dbDir);
if(mainModel == null) {
mainModel = dataset.getDefaultModel();
} else {
Model secondaryModel = dataset.getDefaultModel();
mainModel = ModelFactory.createUnion(mainModel, secondaryModel);
}
}
mainModel = ModelFactory.createRDFSModel(mainModel);
return mainModel;
}
public static Model createModel(File... dirs) { | // Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// public static String[] files2AbsolutePath(File... files) {
// String[] paths = new String[files.length];
// for(int i = 0; i < files.length; i++) {
// paths[i] = files[i].getAbsolutePath();
// }
// return paths;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
//
// private String url = null;
//
// public ServerAddress(String url) {
// this.url = url;
// }
//
// public String getURL() {
// return url;
// }
//
// public String getQueryURL() {
// return url;
// }
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/tdb/TDB.java
import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction;
package org.aksw.kbox.kibe.tdb;
public class TDB {
public static ResultSet queryGraph(String sparql, String graph, String dbDir) throws Exception {
Query query = QueryFactory.create(sparql, graph);
return query(query, dbDir);
}
public static Model createModel(String... dbDirs) {
Model mainModel = null;
Dataset dataset = null;
for(String dbDir : dbDirs) {
dataset = TDBFactory.createDataset(dbDir);
if(mainModel == null) {
mainModel = dataset.getDefaultModel();
} else {
Model secondaryModel = dataset.getDefaultModel();
mainModel = ModelFactory.createUnion(mainModel, secondaryModel);
}
}
mainModel = ModelFactory.createRDFSModel(mainModel);
return mainModel;
}
public static Model createModel(File... dirs) { | return createModel(FileUtils.files2AbsolutePath(dirs)); |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/tdb/TDB.java | // Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// public static String[] files2AbsolutePath(File... files) {
// String[] paths = new String[files.length];
// for(int i = 0; i < files.length; i++) {
// paths[i] = files[i].getAbsolutePath();
// }
// return paths;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
//
// private String url = null;
//
// public ServerAddress(String url) {
// this.url = url;
// }
//
// public String getURL() {
// return url;
// }
//
// public String getQueryURL() {
// return url;
// }
// }
| import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction; | * @param dir directory containing the database file.
* @param lang the RDF streams syntax.
* @param inputStreams URLs of the files containing the RDF content to be loaded into the database file.
*/
public static void bulkload(String dir, Lang lang, InputStream... inputStreams) {
List<InputStream> streams = Arrays.asList(inputStreams);
SequenceInputStream sInputStream = new SequenceInputStream(Collections.enumeration(streams));
bulkload(dir, lang, sInputStream);
}
/**
* Load a list of files into a database located in a given directory.
*
* @param dir directory containing the database file. *
* @param lang the RDF streams syntax.
* @param inputStream URLs of the files containing the RDF content to be loaded into the database file.
*/
public static void bulkload(String dir, Lang lang, InputStream inputStream) {
DatasetGraph dataset = TDBFactory.createDatasetGraph(dir);
RDFDataMgr.read(dataset, inputStream, lang);
dataset.close();
}
/**
* Query a given KBox endpoint.
*
* @param sparql a valid SPARQL query.
* @param address the ServerAddress of the service that will be queried.
* @return an ResultSet containing the elements retrieved by the given SPARQL query.
*/ | // Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// public static String[] files2AbsolutePath(File... files) {
// String[] paths = new String[files.length];
// for(int i = 0; i < files.length; i++) {
// paths[i] = files[i].getAbsolutePath();
// }
// return paths;
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
//
// private String url = null;
//
// public ServerAddress(String url) {
// this.url = url;
// }
//
// public String getURL() {
// return url;
// }
//
// public String getQueryURL() {
// return url;
// }
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/tdb/TDB.java
import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction;
* @param dir directory containing the database file.
* @param lang the RDF streams syntax.
* @param inputStreams URLs of the files containing the RDF content to be loaded into the database file.
*/
public static void bulkload(String dir, Lang lang, InputStream... inputStreams) {
List<InputStream> streams = Arrays.asList(inputStreams);
SequenceInputStream sInputStream = new SequenceInputStream(Collections.enumeration(streams));
bulkload(dir, lang, sInputStream);
}
/**
* Load a list of files into a database located in a given directory.
*
* @param dir directory containing the database file. *
* @param lang the RDF streams syntax.
* @param inputStream URLs of the files containing the RDF content to be loaded into the database file.
*/
public static void bulkload(String dir, Lang lang, InputStream inputStream) {
DatasetGraph dataset = TDBFactory.createDatasetGraph(dir);
RDFDataMgr.read(dataset, inputStream, lang);
dataset.close();
}
/**
* Query a given KBox endpoint.
*
* @param sparql a valid SPARQL query.
* @param address the ServerAddress of the service that will be queried.
* @return an ResultSet containing the elements retrieved by the given SPARQL query.
*/ | public static ResultSet queryService(String sparql, ServerAddress address) { |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/console/ConsoleInstallInputStreamFactory.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/stream/InputStreamInstaller.java
// public class InputStreamInstaller extends InputStream {
//
// private InputStream inputStream = null;
// private InstallStreamListener listener = null;
// private boolean started = false;
//
// public InputStreamInstaller(InputStream inputStream, InstallStreamListener listener) {
// this.inputStream = inputStream;
// this.listener = listener;
// }
//
// @Override
// public void close() throws IOException {
// inputStream.close();
// listener.stop();
// }
//
// @Override
// public boolean markSupported() {
// return inputStream.markSupported();
// }
//
// @Override
// public int read(byte[] b) throws IOException {
// streaming();
// int read = inputStream.read(b);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void mark(int readlimit) {
// inputStream.mark(readlimit);
// }
//
// @Override
// public long skip(long n) throws IOException {
// return inputStream.skip(n);
// }
//
// @Override
// public int read(byte[] b, int off, int len) throws IOException {
// streaming();
// int read = inputStream.read(b, off, len);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void reset() throws IOException {
// inputStream.reset();
// }
//
// @Override
// public int available() throws IOException {
// return inputStream.available();
// }
//
// @Override
// public int read() throws IOException {
// streaming();
// return inputStream.read();
// }
//
// private void streaming() {
// if(!started) {
// listener.start();
// started = true;
// }
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.kibe.stream.InputStreamInstaller;
import org.aksw.kbox.utils.URLUtils; | package org.aksw.kbox.kibe.console;
public class ConsoleInstallInputStreamFactory implements InputStreamFactory {
private final static String MESSAGE = "Installing";
@Override
public InputStream get(URL url) throws IOException { | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/stream/InputStreamInstaller.java
// public class InputStreamInstaller extends InputStream {
//
// private InputStream inputStream = null;
// private InstallStreamListener listener = null;
// private boolean started = false;
//
// public InputStreamInstaller(InputStream inputStream, InstallStreamListener listener) {
// this.inputStream = inputStream;
// this.listener = listener;
// }
//
// @Override
// public void close() throws IOException {
// inputStream.close();
// listener.stop();
// }
//
// @Override
// public boolean markSupported() {
// return inputStream.markSupported();
// }
//
// @Override
// public int read(byte[] b) throws IOException {
// streaming();
// int read = inputStream.read(b);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void mark(int readlimit) {
// inputStream.mark(readlimit);
// }
//
// @Override
// public long skip(long n) throws IOException {
// return inputStream.skip(n);
// }
//
// @Override
// public int read(byte[] b, int off, int len) throws IOException {
// streaming();
// int read = inputStream.read(b, off, len);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void reset() throws IOException {
// inputStream.reset();
// }
//
// @Override
// public int available() throws IOException {
// return inputStream.available();
// }
//
// @Override
// public int read() throws IOException {
// streaming();
// return inputStream.read();
// }
//
// private void streaming() {
// if(!started) {
// listener.start();
// started = true;
// }
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/console/ConsoleInstallInputStreamFactory.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.kibe.stream.InputStreamInstaller;
import org.aksw.kbox.utils.URLUtils;
package org.aksw.kbox.kibe.console;
public class ConsoleInstallInputStreamFactory implements InputStreamFactory {
private final static String MESSAGE = "Installing";
@Override
public InputStream get(URL url) throws IOException { | ConsoleStreamListener listener = new ConsoleStreamListener(MESSAGE + " " + url, URLUtils.getContentLength(url)); |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/console/ConsoleInstallInputStreamFactory.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/stream/InputStreamInstaller.java
// public class InputStreamInstaller extends InputStream {
//
// private InputStream inputStream = null;
// private InstallStreamListener listener = null;
// private boolean started = false;
//
// public InputStreamInstaller(InputStream inputStream, InstallStreamListener listener) {
// this.inputStream = inputStream;
// this.listener = listener;
// }
//
// @Override
// public void close() throws IOException {
// inputStream.close();
// listener.stop();
// }
//
// @Override
// public boolean markSupported() {
// return inputStream.markSupported();
// }
//
// @Override
// public int read(byte[] b) throws IOException {
// streaming();
// int read = inputStream.read(b);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void mark(int readlimit) {
// inputStream.mark(readlimit);
// }
//
// @Override
// public long skip(long n) throws IOException {
// return inputStream.skip(n);
// }
//
// @Override
// public int read(byte[] b, int off, int len) throws IOException {
// streaming();
// int read = inputStream.read(b, off, len);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void reset() throws IOException {
// inputStream.reset();
// }
//
// @Override
// public int available() throws IOException {
// return inputStream.available();
// }
//
// @Override
// public int read() throws IOException {
// streaming();
// return inputStream.read();
// }
//
// private void streaming() {
// if(!started) {
// listener.start();
// started = true;
// }
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.kibe.stream.InputStreamInstaller;
import org.aksw.kbox.utils.URLUtils; | package org.aksw.kbox.kibe.console;
public class ConsoleInstallInputStreamFactory implements InputStreamFactory {
private final static String MESSAGE = "Installing";
@Override
public InputStream get(URL url) throws IOException {
ConsoleStreamListener listener = new ConsoleStreamListener(MESSAGE + " " + url, URLUtils.getContentLength(url)); | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/stream/InputStreamInstaller.java
// public class InputStreamInstaller extends InputStream {
//
// private InputStream inputStream = null;
// private InstallStreamListener listener = null;
// private boolean started = false;
//
// public InputStreamInstaller(InputStream inputStream, InstallStreamListener listener) {
// this.inputStream = inputStream;
// this.listener = listener;
// }
//
// @Override
// public void close() throws IOException {
// inputStream.close();
// listener.stop();
// }
//
// @Override
// public boolean markSupported() {
// return inputStream.markSupported();
// }
//
// @Override
// public int read(byte[] b) throws IOException {
// streaming();
// int read = inputStream.read(b);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void mark(int readlimit) {
// inputStream.mark(readlimit);
// }
//
// @Override
// public long skip(long n) throws IOException {
// return inputStream.skip(n);
// }
//
// @Override
// public int read(byte[] b, int off, int len) throws IOException {
// streaming();
// int read = inputStream.read(b, off, len);
// listener.update(read);
// return read;
// }
//
// @Override
// public synchronized void reset() throws IOException {
// inputStream.reset();
// }
//
// @Override
// public int available() throws IOException {
// return inputStream.available();
// }
//
// @Override
// public int read() throws IOException {
// streaming();
// return inputStream.read();
// }
//
// private void streaming() {
// if(!started) {
// listener.start();
// started = true;
// }
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/console/ConsoleInstallInputStreamFactory.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.kibe.stream.InputStreamInstaller;
import org.aksw.kbox.utils.URLUtils;
package org.aksw.kbox.kibe.console;
public class ConsoleInstallInputStreamFactory implements InputStreamFactory {
private final static String MESSAGE = "Installing";
@Override
public InputStream get(URL url) throws IOException {
ConsoleStreamListener listener = new ConsoleStreamListener(MESSAGE + " " + url, URLUtils.getContentLength(url)); | InputStreamInstaller installer = new InputStreamInstaller(url.openStream(), listener); |
AKSW/KBox | kbox.kibe/src/main/java/org/aksw/kbox/kibe/KNSServerFactory.java | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KBoxKNSServer.java
// public class KBoxKNSServer extends KNSServer {
//
// private KNSTable table = null;
//
// public KBoxKNSServer(URL url) throws Exception {
// super(url);
// this.table = new KNSTable(url);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public boolean visit(KNSVisitor visitor) throws IOException {
// return visit(table, visitor);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s) of a given Knowledge Name Service (KNS).
// *
// * @param knsServerURL the {@link RNService}'s {@link URL}.
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws {@link IOException} if any error occurs during the operation.
// */
// public boolean visit(URL knsServerURL, KNSVisitor visitor) throws IOException {
// KNSTable table = new KNSTable(knsServerURL);
// return visit(table, visitor);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s) of a given Knowledge Name Service (KNS).
// *
// * @param table a {@link KNSTable}.
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws {@link IOException} if any error occurs during the operation.
// */
// public boolean visit(KNSTable table, KNSVisitor visitor) throws IOException {
// return table.visit(visitor);
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
| import java.io.Reader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.aksw.kbox.kns.KBoxKNSServer;
import org.aksw.kbox.kns.KNSServer;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; | package org.aksw.kbox.kibe;
public class KNSServerFactory {
public static KNSServer get(String json) throws MalformedURLException, Exception {
JSONParser jsonParser = new JSONParser();
Reader stringReader = new StringReader(json);
JSONObject jsonObject = (JSONObject) jsonParser.parse(stringReader);
String url = (String) jsonObject.get("url");
KNSServer server = null;
if(jsonObject.containsKey("sparql")) {
JSONObject paramMap = (JSONObject) jsonObject.get("mapping");
Map<String, String> mappings = new HashMap<String, String>();
if(paramMap != null) {
for(int i = 0; i < paramMap.keySet().size(); i++){
String key = (String) paramMap.keySet().toArray()[i];
String value = (String) paramMap.values().toArray()[i];
mappings.put(key, value);
}
}
String sparql = (String) jsonObject.get("sparql");
server = new SPARQLKNSServer(url, sparql, mappings);
return server;
} | // Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KBoxKNSServer.java
// public class KBoxKNSServer extends KNSServer {
//
// private KNSTable table = null;
//
// public KBoxKNSServer(URL url) throws Exception {
// super(url);
// this.table = new KNSTable(url);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public boolean visit(KNSVisitor visitor) throws IOException {
// return visit(table, visitor);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s) of a given Knowledge Name Service (KNS).
// *
// * @param knsServerURL the {@link RNService}'s {@link URL}.
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws {@link IOException} if any error occurs during the operation.
// */
// public boolean visit(URL knsServerURL, KNSVisitor visitor) throws IOException {
// KNSTable table = new KNSTable(knsServerURL);
// return visit(table, visitor);
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s) of a given Knowledge Name Service (KNS).
// *
// * @param table a {@link KNSTable}.
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws {@link IOException} if any error occurs during the operation.
// */
// public boolean visit(KNSTable table, KNSVisitor visitor) throws IOException {
// return table.visit(visitor);
// }
// }
//
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSServer.java
// public abstract class KNSServer {
//
// private URL serverURL = null;
//
// public KNSServer(URL url) throws Exception {
// this.serverURL = url;
// }
//
// /**
// * Iterate over all Knowledge Names ({@link KN}s).
// *
// * @param visitor a {@link KNSVisitor}.
// *
// * @return true if the {@link KNSVisitor#visit(KN)} method return true and false otherwise.
// *
// * @throws IOException if any error occurs during the operation.
// */
// public abstract boolean visit(KNSVisitor visitor) throws Exception;
//
// public URL getURL() {
// return serverURL;
// }
// }
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/KNSServerFactory.java
import java.io.Reader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.aksw.kbox.kns.KBoxKNSServer;
import org.aksw.kbox.kns.KNSServer;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
package org.aksw.kbox.kibe;
public class KNSServerFactory {
public static KNSServer get(String json) throws MalformedURLException, Exception {
JSONParser jsonParser = new JSONParser();
Reader stringReader = new StringReader(json);
JSONObject jsonObject = (JSONObject) jsonParser.parse(stringReader);
String url = (String) jsonObject.get("url");
KNSServer server = null;
if(jsonObject.containsKey("sparql")) {
JSONObject paramMap = (JSONObject) jsonObject.get("mapping");
Map<String, String> mappings = new HashMap<String, String>();
if(paramMap != null) {
for(int i = 0; i < paramMap.keySet().size(); i++){
String key = (String) paramMap.keySet().toArray()[i];
String value = (String) paramMap.values().toArray()[i];
mappings.put(key, value);
}
}
String sparql = (String) jsonObject.get("sparql");
server = new SPARQLKNSServer(url, sparql, mappings);
return server;
} | server = new KBoxKNSServer(new URL(url)); |
AKSW/KBox | kbox.fusca/src/main/java/org/aksw/kbox/fusca/Server.java | // Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/exception/ServerStartException.java
// public class ServerStartException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8495102644748797751L;
//
// public ServerStartException(String message, Exception e) {
// super(message, e);
// }
// }
| import org.aksw.kbox.fusca.exception.ServerStartException;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.query.ARQ;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory; | package org.aksw.kbox.fusca;
/**
*
* @author @author {@linkplain http://emarx.org}
*
*/
public class Server {
private int port = 3030;
private DatasetGraph dsg = null;
private String subDomain = null;
private String pagePath = null;
private Listener listener = null;
public Server(int port, String pagePath, String subDomain, long timeout, Model model, Listener listener) {
this(port, pagePath, subDomain, model, listener);
ARQ.getContext().set(ARQ.queryTimeout, Long.toString(timeout));
}
public Server(int port, String pagePath, String subDomain, Model model, Listener listener) {
this.port = port;
this.subDomain = subDomain;
this.pagePath = pagePath;
Dataset dataset = DatasetFactory.create(model);
this.dsg = dataset.asDatasetGraph();
this.listener = listener;
}
public Server(int port, String pagePath, String subDomain, String datasetPath) {
this.port = port;
this.subDomain = subDomain;
this.pagePath = pagePath;
this.dsg = TDBFactory.createDatasetGraph(datasetPath);
}
| // Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/exception/ServerStartException.java
// public class ServerStartException extends Exception {
//
// /**
// *
// */
// private static final long serialVersionUID = -8495102644748797751L;
//
// public ServerStartException(String message, Exception e) {
// super(message, e);
// }
// }
// Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/Server.java
import org.aksw.kbox.fusca.exception.ServerStartException;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.query.ARQ;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
package org.aksw.kbox.fusca;
/**
*
* @author @author {@linkplain http://emarx.org}
*
*/
public class Server {
private int port = 3030;
private DatasetGraph dsg = null;
private String subDomain = null;
private String pagePath = null;
private Listener listener = null;
public Server(int port, String pagePath, String subDomain, long timeout, Model model, Listener listener) {
this(port, pagePath, subDomain, model, listener);
ARQ.getContext().set(ARQ.queryTimeout, Long.toString(timeout));
}
public Server(int port, String pagePath, String subDomain, Model model, Listener listener) {
this.port = port;
this.subDomain = subDomain;
this.pagePath = pagePath;
Dataset dataset = DatasetFactory.create(model);
this.dsg = dataset.asDatasetGraph();
this.listener = listener;
}
public Server(int port, String pagePath, String subDomain, String datasetPath) {
this.port = port;
this.subDomain = subDomain;
this.pagePath = pagePath;
this.dsg = TDBFactory.createDatasetGraph(datasetPath);
}
| public void start() throws ServerStartException { |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/InstallFactory.java | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AppInstall.java
// public interface AppInstall {
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the URL of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL resource, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resources the URL to the resources that are going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL[] resource, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the URL of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL resource, URL dest, String format, String version, InputStreamFactory factory) throws Exception;
//
//
// /**
// * Install the given resources in a given URL.
// *
// * @param resources the URL of the resources that are going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL[] resources, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception;
//
// public void install(URL resource, File dest, InputStreamFactory isFactory) throws Exception;
//
// public void install(URL[] resource, File dest, InputStreamFactory isFactory) throws Exception;
//
// public void validate(URL url, String format, String version) throws Exception;
//
// public void register(URL url, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the InputStream of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(InputStream source, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param sources the InputStreams of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(InputStream sources[], URL dest, String format, String version) throws Exception;
//
// public void install(InputStream source, File target) throws Exception;
//
// public void install(InputStream[] sources, File target) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
| import java.util.HashMap;
import java.util.Map;
import org.aksw.kbox.apple.AppInstall;
import org.aksw.kbox.apple.ResourceAppInstall; | package org.aksw.kbox.kns;
public class InstallFactory {
private Map<String, AppInstall> methods = new HashMap<String, AppInstall>();
public AppInstall get(KN kn) {
String decoder = kn.getTargets().get(0).getInstall();
if(decoder == null) { | // Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AppInstall.java
// public interface AppInstall {
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the URL of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL resource, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resources the URL to the resources that are going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL[] resource, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the URL of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL resource, URL dest, String format, String version, InputStreamFactory factory) throws Exception;
//
//
// /**
// * Install the given resources in a given URL.
// *
// * @param resources the URL of the resources that are going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(URL[] resources, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception;
//
// public void install(URL resource, File dest, InputStreamFactory isFactory) throws Exception;
//
// public void install(URL[] resource, File dest, InputStreamFactory isFactory) throws Exception;
//
// public void validate(URL url, String format, String version) throws Exception;
//
// public void register(URL url, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param resource the InputStream of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(InputStream source, URL dest, String format, String version) throws Exception;
//
// /**
// * Install a given resource in a given URL.
// *
// * @param sources the InputStreams of the resource that is going to be published.
// * @param dest the URL where the resource is going to be published.
// * @param format the format.
// * @param version the version.
// *
// * @throws Exception
// */
// public void install(InputStream sources[], URL dest, String format, String version) throws Exception;
//
// public void install(InputStream source, File target) throws Exception;
//
// public void install(InputStream[] sources, File target) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/ResourceAppInstall.java
// public class ResourceAppInstall extends AbstractAppInstall {
// @Override
// public void install(InputStream source, File target) throws Exception {
// StreamUtils.stream(source, target);
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/InstallFactory.java
import java.util.HashMap;
import java.util.Map;
import org.aksw.kbox.apple.AppInstall;
import org.aksw.kbox.apple.ResourceAppInstall;
package org.aksw.kbox.kns;
public class InstallFactory {
private Map<String, AppInstall> methods = new HashMap<String, AppInstall>();
public AppInstall get(KN kn) {
String decoder = kn.getTargets().get(0).getInstall();
if(decoder == null) { | return new ResourceAppInstall(); |
AKSW/KBox | kbox.kns/src/main/java/org/aksw/kbox/kns/KNSResolverVisitor.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.net.URL;
import org.aksw.kbox.utils.URLUtils;
import org.apache.log4j.Logger; | package org.aksw.kbox.kns;
public class KNSResolverVisitor implements KNSVisitor {
private final static Logger logger = Logger.getLogger(KNSResolverVisitor.class);
private URL resourceURL = null;
private KN resolvedKN = null;
private String format = null;
private String version = null;
public KNSResolverVisitor(URL resourceURL) {
this.resourceURL = resourceURL;
}
public KNSResolverVisitor(URL resourceURL, String format, String version) {
this(resourceURL);
this.format = format;
this.version = version;
}
public KN getResolvedKN() {
return resolvedKN;
}
@Override
public boolean visit(KN kn) throws Exception {
if(kn.equals(resourceURL.toString(), format, version)) {
URL target = kn.getTargets().get(0).getURL(); | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/KNSResolverVisitor.java
import java.net.URL;
import org.aksw.kbox.utils.URLUtils;
import org.apache.log4j.Logger;
package org.aksw.kbox.kns;
public class KNSResolverVisitor implements KNSVisitor {
private final static Logger logger = Logger.getLogger(KNSResolverVisitor.class);
private URL resourceURL = null;
private KN resolvedKN = null;
private String format = null;
private String version = null;
public KNSResolverVisitor(URL resourceURL) {
this.resourceURL = resourceURL;
}
public KNSResolverVisitor(URL resourceURL, String format, String version) {
this(resourceURL);
this.format = format;
this.version = version;
}
public KN getResolvedKN() {
return resolvedKN;
}
@Override
public boolean visit(KN kn) throws Exception {
if(kn.equals(resourceURL.toString(), format, version)) {
URL target = kn.getTargets().get(0).getURL(); | if(!URLUtils.checkStatus(target, 404)) { |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception { | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception { | install(resources, dest, format, version, new DefaultInputStreamFactory()); |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception {
install(resources, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version)
throws Exception {
install(resource, dest, format, version, new DefaultInputStreamFactory());
}
@Override | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception {
install(resources, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version)
throws Exception {
install(resource, dest, format, version, new DefaultInputStreamFactory());
}
@Override | public void install(URL resource, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception { |
AKSW/KBox | kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils; | package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception {
install(resources, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version)
throws Exception {
install(resource, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception { | // Path: kbox.core/src/main/java/org/aksw/kbox/InputStreamFactory.java
// public interface InputStreamFactory {
// public InputStream get(URL url) throws Exception;
// }
//
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/stream/DefaultInputStreamFactory.java
// public class DefaultInputStreamFactory implements InputStreamFactory {
//
// @Override
// public InputStream get(URL url) throws IOException {
// return url.openStream();
// }
//
// }
//
// Path: kbox.core/src/main/java/org/aksw/kbox/utils/URLUtils.java
// public class URLUtils {
//
// private static Set<String> protocolsWithHost = new HashSet<String>(
// Arrays.asList( new String[]{ "file", "ftp", "http", "https" } )
// );
//
// public static URL[] stringToURL(String... urls) throws Exception {
// URL[] urlArray = new URL[urls.length];
// for(int i=0; i < urls.length; i++) {
// urlArray[i] = new URL(urls[i]);
// }
// return urlArray;
// }
//
// public static boolean checkStatus(URL url, int code) throws IOException {
// URLConnection conn = url.openConnection();
// if(conn instanceof HttpURLConnection) {
// HttpURLConnection huc = (HttpURLConnection) conn;
// huc.setRequestMethod("HEAD");
// conn.connect();
// return huc.getResponseCode() == code;
// }
// return false;
// }
//
// public static URL[] fileToURL(File... files) throws MalformedURLException {
// URL[] urls = new URL[files.length];
// int i = 0;
// for(File file : files) {
// urls[i] = file.toURI().toURL();
// i++;
// }
// return urls;
// }
//
// public static long getContentLength(URL url) throws IOException {
// URLConnection conn = url.openConnection();
// Long contentLength = conn.getContentLengthLong();
// if(contentLength != null && contentLength >= 0) {
// return contentLength;
// }
// String contentLengthValue = conn.getHeaderField("content-length");
// if(contentLengthValue != null) {
// return Long.valueOf(contentLengthValue);
// }
// return -1;
// }
//
// public static URL getURLForward(URL url) throws Exception {
// URLConnection con = url.openConnection();
// String location = con.getHeaderField("Location");
// if(location != null) {
// return new URL(location);
// }
// return url;
// }
//
// public static boolean hasValidURLHost(URI uri) {
// return protocolsWithHost.contains(uri.getScheme());
// }
//
// public static String getContentType(URL url) throws Exception {
// URL forwardURL = getURLForward(url);
// HttpURLConnection connection = (HttpURLConnection) forwardURL.openConnection();
// connection.setRequestMethod("HEAD");
// connection.connect();
// return connection.getContentType();
// }
// }
// Path: kbox.apple/src/main/java/org/aksw/kbox/apple/AbstractAppInstall.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.InvalidParameterException;
import org.aksw.kbox.InputStreamFactory;
import org.aksw.kbox.apple.stream.DefaultInputStreamFactory;
import org.aksw.kbox.utils.URLUtils;
import org.apache.commons.compress.utils.IOUtils;
package org.aksw.kbox.apple;
/**
*
* @author {@linkplain http://emarx.org}
*
*/
public abstract class AbstractAppInstall extends AppPathBinder implements AppInstall, PathBinder {
public void install(URL[] resources, URL dest, String format, String version)
throws Exception {
install(resources, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version)
throws Exception {
install(resource, dest, format, version, new DefaultInputStreamFactory());
}
@Override
public void install(URL resource, URL dest, String format, String version, InputStreamFactory isFactory) throws Exception { | URL forwardURL = URLUtils.getURLForward(resource); |
AKSW/KBox | kbox.core/src/main/java/org/aksw/kbox/CustomParams.java | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/AssertionUtils.java
// public class AssertionUtils {
// public static <T extends Exception> void notNull(T exception, Object... objects) throws T {
// for(Object object : objects) {
// if(object == null) {
// throw exception;
// }
// }
// }
// }
| import java.io.File;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
import org.aksw.kbox.utils.AssertionUtils;
import org.mapdb.DB;
import org.mapdb.DBMaker;
import org.mapdb.HTreeMap; | package org.aksw.kbox;
/**
* This class implements a persistent parameter map.
*
* @author {@linkplain http://emarx.org}
*
*/
public class CustomParams implements Serializable, Visitor<CustomParamVisitor> {
/**
*
*/
private static final long serialVersionUID = 8598003281170345448L;
private String context;
private String path;
public CustomParams(String path, String context) { | // Path: kbox.core/src/main/java/org/aksw/kbox/utils/AssertionUtils.java
// public class AssertionUtils {
// public static <T extends Exception> void notNull(T exception, Object... objects) throws T {
// for(Object object : objects) {
// if(object == null) {
// throw exception;
// }
// }
// }
// }
// Path: kbox.core/src/main/java/org/aksw/kbox/CustomParams.java
import java.io.File;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
import org.aksw.kbox.utils.AssertionUtils;
import org.mapdb.DB;
import org.mapdb.DBMaker;
import org.mapdb.HTreeMap;
package org.aksw.kbox;
/**
* This class implements a persistent parameter map.
*
* @author {@linkplain http://emarx.org}
*
*/
public class CustomParams implements Serializable, Visitor<CustomParamVisitor> {
/**
*
*/
private static final long serialVersionUID = 8598003281170345448L;
private String context;
private String path;
public CustomParams(String path, String context) { | AssertionUtils.notNull(new IllegalArgumentException("context"), context); |
Gericop/Android-Support-Preference-V7-Fix | preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuListItemHolder.java | // Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int DIALOG = 1;
//
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int HORIZONTAL = 0;
| import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.CheckedTextView;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.DIALOG;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.HORIZONTAL; | package com.takisoft.preferencex.widget;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class SimpleMenuListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public CheckedTextView mCheckedTextView;
private SimpleMenuPopupWindow mWindow;
public SimpleMenuListItemHolder(View itemView) {
super(itemView);
mCheckedTextView = itemView.findViewById(android.R.id.text1);
itemView.setOnClickListener(this);
}
public void bind(SimpleMenuPopupWindow window, int position) {
mWindow = window;
mCheckedTextView.setText(mWindow.getEntries()[position]);
mCheckedTextView.setChecked(position == mWindow.getSelectedIndex()); | // Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int DIALOG = 1;
//
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int HORIZONTAL = 0;
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuListItemHolder.java
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.CheckedTextView;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.DIALOG;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.HORIZONTAL;
package com.takisoft.preferencex.widget;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class SimpleMenuListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public CheckedTextView mCheckedTextView;
private SimpleMenuPopupWindow mWindow;
public SimpleMenuListItemHolder(View itemView) {
super(itemView);
mCheckedTextView = itemView.findViewById(android.R.id.text1);
itemView.setOnClickListener(this);
}
public void bind(SimpleMenuPopupWindow window, int position) {
mWindow = window;
mCheckedTextView.setText(mWindow.getEntries()[position]);
mCheckedTextView.setChecked(position == mWindow.getSelectedIndex()); | mCheckedTextView.setMaxLines(mWindow.getMode() == DIALOG ? Integer.MAX_VALUE : 1); |
Gericop/Android-Support-Preference-V7-Fix | preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuListItemHolder.java | // Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int DIALOG = 1;
//
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int HORIZONTAL = 0;
| import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.CheckedTextView;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.DIALOG;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.HORIZONTAL; | package com.takisoft.preferencex.widget;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class SimpleMenuListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public CheckedTextView mCheckedTextView;
private SimpleMenuPopupWindow mWindow;
public SimpleMenuListItemHolder(View itemView) {
super(itemView);
mCheckedTextView = itemView.findViewById(android.R.id.text1);
itemView.setOnClickListener(this);
}
public void bind(SimpleMenuPopupWindow window, int position) {
mWindow = window;
mCheckedTextView.setText(mWindow.getEntries()[position]);
mCheckedTextView.setChecked(position == mWindow.getSelectedIndex());
mCheckedTextView.setMaxLines(mWindow.getMode() == DIALOG ? Integer.MAX_VALUE : 1);
| // Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int DIALOG = 1;
//
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuPopupWindow.java
// public static final int HORIZONTAL = 0;
// Path: preferencex-simplemenu/src/main/java/com/takisoft/preferencex/widget/SimpleMenuListItemHolder.java
import android.os.Build;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.CheckedTextView;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.DIALOG;
import static com.takisoft.preferencex.widget.SimpleMenuPopupWindow.HORIZONTAL;
package com.takisoft.preferencex.widget;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class SimpleMenuListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public CheckedTextView mCheckedTextView;
private SimpleMenuPopupWindow mWindow;
public SimpleMenuListItemHolder(View itemView) {
super(itemView);
mCheckedTextView = itemView.findViewById(android.R.id.text1);
itemView.setOnClickListener(this);
}
public void bind(SimpleMenuPopupWindow window, int position) {
mWindow = window;
mCheckedTextView.setText(mWindow.getEntries()[position]);
mCheckedTextView.setChecked(position == mWindow.getSelectedIndex());
mCheckedTextView.setMaxLines(mWindow.getMode() == DIALOG ? Integer.MAX_VALUE : 1);
| int padding = mWindow.listPadding[mWindow.getMode()][HORIZONTAL]; |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/CountCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/26 下午3:40.
*/
public interface CountCallback {
void done(int count); | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/CountCallback.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/26 下午3:40.
*/
public interface CountCallback {
void done(int count); | void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/DeleteCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/8 下午3:40.
*/
public interface DeleteCallback {
void done(); | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/DeleteCallback.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/8 下午3:40.
*/
public interface DeleteCallback {
void done(); | void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/JBFile.java | // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException; | package com.javabaas;
/**
* Created by xueshukai on 15/10/9 下午5:31.
*/
public class JBFile extends JBObject {
private String className = "_File";
private String path;
private byte[] data;
private File file;
private String name;
public JBFile() {
}
public JBFile(File file) {
this.file = file;
}
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
| // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/JBFile.java
import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException;
package com.javabaas;
/**
* Created by xueshukai on 15/10/9 下午5:31.
*/
public class JBFile extends JBObject {
private String className = "_File";
private String path;
private byte[] data;
private File file;
private String name;
public JBFile() {
}
public JBFile(File file) {
this.file = file;
}
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
| public void saveInBackground(final FileUploadCallback callback) { |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/JBFile.java | // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException; | package com.javabaas;
/**
* Created by xueshukai on 15/10/9 下午5:31.
*/
public class JBFile extends JBObject {
private String className = "_File";
private String path;
private byte[] data;
private File file;
private String name;
public JBFile() {
}
public JBFile(File file) {
this.file = file;
}
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
public void saveInBackground(final FileUploadCallback callback) { | // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/JBFile.java
import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException;
package com.javabaas;
/**
* Created by xueshukai on 15/10/9 下午5:31.
*/
public class JBFile extends JBObject {
private String className = "_File";
private String path;
private byte[] data;
private File file;
private String name;
public JBFile() {
}
public JBFile(File file) {
this.file = file;
}
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
public void saveInBackground(final FileUploadCallback callback) { | getUploadToken(new ResponseListener<CustomResponse>() { |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/JBFile.java | // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException; | }
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
public void saveInBackground(final FileUploadCallback callback) {
getUploadToken(new ResponseListener<CustomResponse>() {
@Override
public void onResponse(CustomResponse entity) {
if (uploader != null)
uploader.upload(entity ,JBFile.this,callback);
}
@Override | // Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
// public interface FileUploadCallback {
// void done(JBFile jbFile);
// void error(JBException e);
// void onProgress(double percent);
// }
//
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
// public interface ResponseListener<T> {
// void onResponse(T entity);
//
// void onError(JBException e);
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/JBFile.java
import java.io.File;
import com.javabaas.callback.FileUploadCallback;
import com.javabaas.callback.ResponseListener;
import com.javabaas.exception.JBException;
}
public JBFile(byte[] bytes) {
this.data = bytes;
}
public static JBFile createWithoutData(String id){
JBFile jbObject = new JBFile();
jbObject.setId(id);
return jbObject;
}
public File getFile(){
return file;
}
@Override
public String getClassName() {
return className;
}
public void saveInBackground(final FileUploadCallback callback) {
getUploadToken(new ResponseListener<CustomResponse>() {
@Override
public void onResponse(CustomResponse entity) {
if (uploader != null)
uploader.upload(entity ,JBFile.this,callback);
}
@Override | public void onError(JBException e) { |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/RequestCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 16/1/26 下午3:08.
*/
public interface RequestCallback {
void done(); | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/RequestCallback.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 16/1/26 下午3:08.
*/
public interface RequestCallback {
void done(); | void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/FileUploadCallback.java | // Path: source/src/main/java/com/javabaas/JBFile.java
// public class JBFile extends JBObject {
// private String className = "_File";
//
// private String path;
// private byte[] data;
// private File file;
// private String name;
//
// public JBFile() {
// }
//
// public JBFile(File file) {
// this.file = file;
// }
//
// public JBFile(byte[] bytes) {
// this.data = bytes;
// }
//
// public static JBFile createWithoutData(String id){
// JBFile jbObject = new JBFile();
// jbObject.setId(id);
// return jbObject;
// }
//
// public File getFile(){
// return file;
// }
//
// @Override
// public String getClassName() {
// return className;
// }
//
// public void saveInBackground(final FileUploadCallback callback) {
// getUploadToken(new ResponseListener<CustomResponse>() {
// @Override
// public void onResponse(CustomResponse entity) {
// if (uploader != null)
// uploader.upload(entity ,JBFile.this,callback);
// }
//
// @Override
// public void onError(JBException e) {
// callback.error(e);
// }
// });
// }
//
// private void getUploadToken(ResponseListener<CustomResponse> listener) {
// JBCloud.getObjectManager(null).customJsonRequest(JBCloud.applicationContext, false , listener, "/api/file/getToken?fileName="+filename+"&platform=" + platform, IObjectManager.Method.GET, null);
// }
//
// private static IUploader uploader = null;
// private static String platform , filename;
// public static void setUploader(IUploader uploader){
// JBFile.uploader = uploader;
// }
// static {
// if (uploader == null){
// uploader = new QiNiuUploader();
// platform = "qiniu";
// filename = "android_file";
// }
// }
// public static void setPlatform(String platform){
// JBFile.platform = platform;
// }
//
// public static void setFilename(String filename){
// JBFile.filename = filename;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public byte[] getData() {
// return data;
// }
//
// public void setData(byte[] data) {
// this.data = data;
// }
//
// public static JBFile withFile(File file) {
// return new JBFile(file);
// }
//
// public static JBFile withByte(byte[] bytes){
// return new JBFile(bytes);
// }
//
// public String getUrl() {
// return (String) get("url");
// }
//
// public String mimeType() {
// return null;
// }
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.JBFile;
import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 16/1/4 下午12:50.
*/
public interface FileUploadCallback {
void done(JBFile jbFile); | // Path: source/src/main/java/com/javabaas/JBFile.java
// public class JBFile extends JBObject {
// private String className = "_File";
//
// private String path;
// private byte[] data;
// private File file;
// private String name;
//
// public JBFile() {
// }
//
// public JBFile(File file) {
// this.file = file;
// }
//
// public JBFile(byte[] bytes) {
// this.data = bytes;
// }
//
// public static JBFile createWithoutData(String id){
// JBFile jbObject = new JBFile();
// jbObject.setId(id);
// return jbObject;
// }
//
// public File getFile(){
// return file;
// }
//
// @Override
// public String getClassName() {
// return className;
// }
//
// public void saveInBackground(final FileUploadCallback callback) {
// getUploadToken(new ResponseListener<CustomResponse>() {
// @Override
// public void onResponse(CustomResponse entity) {
// if (uploader != null)
// uploader.upload(entity ,JBFile.this,callback);
// }
//
// @Override
// public void onError(JBException e) {
// callback.error(e);
// }
// });
// }
//
// private void getUploadToken(ResponseListener<CustomResponse> listener) {
// JBCloud.getObjectManager(null).customJsonRequest(JBCloud.applicationContext, false , listener, "/api/file/getToken?fileName="+filename+"&platform=" + platform, IObjectManager.Method.GET, null);
// }
//
// private static IUploader uploader = null;
// private static String platform , filename;
// public static void setUploader(IUploader uploader){
// JBFile.uploader = uploader;
// }
// static {
// if (uploader == null){
// uploader = new QiNiuUploader();
// platform = "qiniu";
// filename = "android_file";
// }
// }
// public static void setPlatform(String platform){
// JBFile.platform = platform;
// }
//
// public static void setFilename(String filename){
// JBFile.filename = filename;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public byte[] getData() {
// return data;
// }
//
// public void setData(byte[] data) {
// this.data = data;
// }
//
// public static JBFile withFile(File file) {
// return new JBFile(file);
// }
//
// public static JBFile withByte(byte[] bytes){
// return new JBFile(bytes);
// }
//
// public String getUrl() {
// return (String) get("url");
// }
//
// public String mimeType() {
// return null;
// }
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/FileUploadCallback.java
import com.javabaas.JBFile;
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 16/1/4 下午12:50.
*/
public interface FileUploadCallback {
void done(JBFile jbFile); | void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/FileSaveCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/9 下午5:46.
*/
public interface FileSaveCallback {
/**
* 上传成功后会回调的方法
* @param url 上传文件在七牛服务器上存储的url
*/
void done(String url);
| // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/FileSaveCallback.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/9 下午5:46.
*/
public interface FileSaveCallback {
/**
* 上传成功后会回调的方法
* @param url 上传文件在七牛服务器上存储的url
*/
void done(String url);
| void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/ResponseListener.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/9 下午5:49.
*/
public interface ResponseListener<T> {
void onResponse(T entity);
| // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/ResponseListener.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/10/9 下午5:49.
*/
public interface ResponseListener<T> {
void onResponse(T entity);
| void onError(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/CloudCallback.java | // Path: source/src/main/java/com/javabaas/ResponseEntity.java
// public class ResponseEntity {
// private int code;
// private String message;
// private Map<String,Object> data;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public Map<String, Object> getData() {
// return data;
// }
//
// public void setData(Map<String, Object> data) {
// this.data = data;
// }
//
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.ResponseEntity;
import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/12/30 上午11:07.
*/
public interface CloudCallback {
void done(ResponseEntity responseEntity); | // Path: source/src/main/java/com/javabaas/ResponseEntity.java
// public class ResponseEntity {
// private int code;
// private String message;
// private Map<String,Object> data;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public Map<String, Object> getData() {
// return data;
// }
//
// public void setData(Map<String, Object> data) {
// this.data = data;
// }
//
// }
//
// Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/CloudCallback.java
import com.javabaas.ResponseEntity;
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/12/30 上午11:07.
*/
public interface CloudCallback {
void done(ResponseEntity responseEntity); | void error(JBException e , ResponseEntity responseEntity); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/FindCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import java.util.List;
import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 15/9/29 下午2:53.
*/
public interface FindCallback<T> {
void done(List<T> result); | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/FindCallback.java
import java.util.List;
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 15/9/29 下午2:53.
*/
public interface FindCallback<T> {
void done(List<T> result); | void error(JBException e); |
JavaBaas/JavaBaas_SDK_Android | source/src/main/java/com/javabaas/callback/GetInstallationIdCallback.java | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
| import com.javabaas.exception.JBException; | package com.javabaas.callback;
/**
* Created by xueshukai on 16/2/24 上午11:07.
*/
public interface GetInstallationIdCallback {
void done(String id); | // Path: source/src/main/java/com/javabaas/exception/JBException.java
// public class JBException extends Exception {
// /**
// * 认证失败
// */
// public static int AUTH_FAILURE_ERROR = 1;
//
// /**
// * 网络错误
// */
// public static int NETWORK_ERROR = 2;
//
// /**
// * 解析错误
// */
// public static int PARSE_ERROR = 3;
//
// /**
// * 服务器错误
// */
// public static int SERVER_ERROR = 4;
//
// /**
// * 云方法错误
// */
// public static int CLOUD_ERROR = 5;
//
// /**
// * 上传错误
// */
// public static int UPLOAD_ERROR = 6;
//
// //responseErrorCode
// public static int SESSION_TOKEN_ERROR_CODE = 1310;
//
// public int errorCode;
// public int responseErrorCode;
// public String responseErrorMsg;
//
// public JBException() {
// }
//
// public JBException(String detailMessage) {
// super(detailMessage);
// }
//
// public JBException(int errorCode , String detailMessage) {
// super(detailMessage);
// this.errorCode = errorCode;
// }
//
// public int getErrorCode() {
// return errorCode;
// }
//
// public int getResponseErrorCode() {
// return responseErrorCode;
// }
//
// public String getResponseErrorMsg() {
// return responseErrorMsg;
// }
// }
// Path: source/src/main/java/com/javabaas/callback/GetInstallationIdCallback.java
import com.javabaas.exception.JBException;
package com.javabaas.callback;
/**
* Created by xueshukai on 16/2/24 上午11:07.
*/
public interface GetInstallationIdCallback {
void done(String id); | void error(JBException e); |
hawtio/hawtio | tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/TestMojo.java | // Path: tooling/hawtio-junit/src/main/java/io/hawt/junit/JUnitService.java
// public interface JUnitService {
//
// List<Method> findTestMethods(Class<?> clazz) throws Exception;
//
// List<Method> filterTestMethods(List<Method> methods, String filter);
//
// Method findBefore(Class<?> clazz) throws Exception;
//
// Method findBeforeClass(Class<?> clazz) throws Exception;
//
// Method findAfter(Class<?> clazz) throws Exception;
//
// Method findAfterClass(Class<?> clazz) throws Exception;
// }
| import java.io.Console;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.List;
import java.util.Set;
import io.hawt.junit.DefaultJUnitService;
import io.hawt.junit.JUnitService;
import io.hawt.util.ReflectionHelper;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope; | package io.hawt.maven;
@Mojo(name = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.PROCESS_TEST_CLASSES)
public class TestMojo extends CamelMojo {
@Parameter(property = "hawtio.className")
private String className;
@Parameter(property = "hawtio.testName")
private String testName;
/**
* The directory containing generated test classes of the project being tested. This will be included at the
* beginning of the test classpath.
*/
@Parameter( defaultValue = "${project.build.testOutputDirectory}" )
protected File testClassesDirectory;
| // Path: tooling/hawtio-junit/src/main/java/io/hawt/junit/JUnitService.java
// public interface JUnitService {
//
// List<Method> findTestMethods(Class<?> clazz) throws Exception;
//
// List<Method> filterTestMethods(List<Method> methods, String filter);
//
// Method findBefore(Class<?> clazz) throws Exception;
//
// Method findBeforeClass(Class<?> clazz) throws Exception;
//
// Method findAfter(Class<?> clazz) throws Exception;
//
// Method findAfterClass(Class<?> clazz) throws Exception;
// }
// Path: tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/TestMojo.java
import java.io.Console;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.List;
import java.util.Set;
import io.hawt.junit.DefaultJUnitService;
import io.hawt.junit.JUnitService;
import io.hawt.util.ReflectionHelper;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
package io.hawt.maven;
@Mojo(name = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.PROCESS_TEST_CLASSES)
public class TestMojo extends CamelMojo {
@Parameter(property = "hawtio.className")
private String className;
@Parameter(property = "hawtio.testName")
private String testName;
/**
* The directory containing generated test classes of the project being tested. This will be included at the
* beginning of the test classpath.
*/
@Parameter( defaultValue = "${project.build.testOutputDirectory}" )
protected File testClassesDirectory;
| private JUnitService jUnitService = new DefaultJUnitService(); |
hawtio/hawtio | hawtio-log-osgi/src/main/java/io/hawt/log/osgi/MavenCoordinates.java | // Path: hawtio-log/src/main/java/io/hawt/log/support/MavenCoordinates.java
// public static void appendMavenCoordinateFromPomProperties(InputStream is, StringBuilder buffer) throws IOException {
// Properties props = new Properties();
// try {
// props.load(is);
// String groupId = props.getProperty("groupId");
// String artifactId = props.getProperty("artifactId");
// String version = props.getProperty("version");
// if (groupId != null && artifactId != null & version != null) {
// if (buffer.length() > 0) {
// buffer.append(" ");
// }
// buffer.append(groupId).append(":").append(artifactId).append(":").append(version);
// }
// } finally {
// is.close();
// }
// }
| import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import static io.hawt.log.support.MavenCoordinates.appendMavenCoordinateFromPomProperties; | try {
bundleId = Long.parseLong(bundleIdStr);
} catch (NumberFormatException e) {
return null;
}
return getMavenCoordinates(bundleId);
}
public static Bundle getBundle(long bundleId) {
Bundle logBundle = FrameworkUtil.getBundle(Logs.class);
BundleContext bundleContext = logBundle != null ? logBundle.getBundleContext() : null;
Bundle bundle = bundleContext != null ? bundleContext.getBundle(bundleId) : null;
return bundle;
}
public static String getMavenCoordinates(long bundleId) {
Bundle bundle = getBundle(bundleId);
if (bundle == null) {
// Not sure why can't we find the bundleId?
return null;
}
String id = Long.toString(bundle.getBundleId()) + ":" + Long.toString(bundle.getLastModified());
String maven = MAVEN_COORDINATES.get(id);
if (maven == null) {
if (bundle.getState() >= Bundle.RESOLVED) {
try {
Enumeration<URL> e = bundle.findEntries("META-INF/maven/", "pom.properties", true);
StringBuilder buf = new StringBuilder();
while (e != null && e.hasMoreElements()) {
URL url = e.nextElement(); | // Path: hawtio-log/src/main/java/io/hawt/log/support/MavenCoordinates.java
// public static void appendMavenCoordinateFromPomProperties(InputStream is, StringBuilder buffer) throws IOException {
// Properties props = new Properties();
// try {
// props.load(is);
// String groupId = props.getProperty("groupId");
// String artifactId = props.getProperty("artifactId");
// String version = props.getProperty("version");
// if (groupId != null && artifactId != null & version != null) {
// if (buffer.length() > 0) {
// buffer.append(" ");
// }
// buffer.append(groupId).append(":").append(artifactId).append(":").append(version);
// }
// } finally {
// is.close();
// }
// }
// Path: hawtio-log-osgi/src/main/java/io/hawt/log/osgi/MavenCoordinates.java
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import static io.hawt.log.support.MavenCoordinates.appendMavenCoordinateFromPomProperties;
try {
bundleId = Long.parseLong(bundleIdStr);
} catch (NumberFormatException e) {
return null;
}
return getMavenCoordinates(bundleId);
}
public static Bundle getBundle(long bundleId) {
Bundle logBundle = FrameworkUtil.getBundle(Logs.class);
BundleContext bundleContext = logBundle != null ? logBundle.getBundleContext() : null;
Bundle bundle = bundleContext != null ? bundleContext.getBundle(bundleId) : null;
return bundle;
}
public static String getMavenCoordinates(long bundleId) {
Bundle bundle = getBundle(bundleId);
if (bundle == null) {
// Not sure why can't we find the bundleId?
return null;
}
String id = Long.toString(bundle.getBundleId()) + ":" + Long.toString(bundle.getLastModified());
String maven = MAVEN_COORDINATES.get(id);
if (maven == null) {
if (bundle.getState() >= Bundle.RESOLVED) {
try {
Enumeration<URL> e = bundle.findEntries("META-INF/maven/", "pom.properties", true);
StringBuilder buf = new StringBuilder();
while (e != null && e.hasMoreElements()) {
URL url = e.nextElement(); | appendMavenCoordinateFromPomProperties(url.openStream(), buf); |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | // Path: hawtio-util/src/main/java/io/hawt/util/Predicate.java
// public interface Predicate<T> {
// boolean evaluate(T value);
// }
//
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/ClassLoaderProvider.java
// public interface ClassLoaderProvider {
//
// /**
// * Returns the ClassLoader or null if one is not available
// */
// ClassLoader getClassLoader();
// }
| import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import io.hawt.util.Predicate;
import io.hawt.util.ReflectionHelper;
import io.hawt.util.Strings;
import io.hawt.util.introspect.ClassLoaderProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /**
* Copyright (C) 2013 the original author or authors.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* 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 io.hawt.util.introspect.support;
/**
* A helper class to scan classes on the classpath
*/
public class ClassScanner {
private static final transient Logger LOG = LoggerFactory.getLogger(ClassScanner.class);
// lets skip some classes which can cause ugly WARN logging when doing package scanning
private static final String[] SKIP_CLASSES = new String[]{"org.apache.log4j.net.ZeroConfSupport"};
private final ClassLoader[] classLoaders;
private WeakHashMap<String, CacheValue> cache = new WeakHashMap<String, CacheValue>();
private WeakHashMap<Package, CacheValue> packageCache = new WeakHashMap<Package, CacheValue>(); | // Path: hawtio-util/src/main/java/io/hawt/util/Predicate.java
// public interface Predicate<T> {
// boolean evaluate(T value);
// }
//
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/ClassLoaderProvider.java
// public interface ClassLoaderProvider {
//
// /**
// * Returns the ClassLoader or null if one is not available
// */
// ClassLoader getClassLoader();
// }
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import io.hawt.util.Predicate;
import io.hawt.util.ReflectionHelper;
import io.hawt.util.Strings;
import io.hawt.util.introspect.ClassLoaderProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Copyright (C) 2013 the original author or authors.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* 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 io.hawt.util.introspect.support;
/**
* A helper class to scan classes on the classpath
*/
public class ClassScanner {
private static final transient Logger LOG = LoggerFactory.getLogger(ClassScanner.class);
// lets skip some classes which can cause ugly WARN logging when doing package scanning
private static final String[] SKIP_CLASSES = new String[]{"org.apache.log4j.net.ZeroConfSupport"};
private final ClassLoader[] classLoaders;
private WeakHashMap<String, CacheValue> cache = new WeakHashMap<String, CacheValue>();
private WeakHashMap<Package, CacheValue> packageCache = new WeakHashMap<Package, CacheValue>(); | private Map<String, ClassLoaderProvider> classLoaderProviderMap = new HashMap<String, ClassLoaderProvider>(); |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | // Path: hawtio-util/src/main/java/io/hawt/util/Predicate.java
// public interface Predicate<T> {
// boolean evaluate(T value);
// }
//
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/ClassLoaderProvider.java
// public interface ClassLoaderProvider {
//
// /**
// * Returns the ClassLoader or null if one is not available
// */
// ClassLoader getClassLoader();
// }
| import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import io.hawt.util.Predicate;
import io.hawt.util.ReflectionHelper;
import io.hawt.util.Strings;
import io.hawt.util.introspect.ClassLoaderProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
addClassNamesInDirectoryWithMethodsAnnotatedWith(answer, file, annotationClass, packageName + file.getName() + ".");
} else if (file.isFile()) {
String name = file.getName();
if (name.endsWith(".class")) {
String className = packageName + (name.substring(0, name.length() - 6).replace('$', '.'));
Class<?> aClass = optionallyFindClass(className);
if (aClass != null && ReflectionHelper.hasMethodWithAnnotation(aClass, annotationClass, true)) {
answer.add(className);
}
}
}
}
}
}
protected Class<? extends Annotation> optionallyFindAnnotationClass(String annotationClassName) {
final Class<? extends Annotation> annotationClass = optionallyFindClass(annotationClassName).asSubclass(Annotation.class);
if (annotationClass != null && Annotation.class.isAssignableFrom(annotationClass)) {
return annotationClass;
}
return null;
}
public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName, Integer limit, Map<Package, ClassLoader[]> packages) {
final Class<? extends Annotation> annotationClass = optionallyFindAnnotationClass(annotationClassName);
if (annotationClass != null) { | // Path: hawtio-util/src/main/java/io/hawt/util/Predicate.java
// public interface Predicate<T> {
// boolean evaluate(T value);
// }
//
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/ClassLoaderProvider.java
// public interface ClassLoaderProvider {
//
// /**
// * Returns the ClassLoader or null if one is not available
// */
// ClassLoader getClassLoader();
// }
// Path: hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import io.hawt.util.Predicate;
import io.hawt.util.ReflectionHelper;
import io.hawt.util.Strings;
import io.hawt.util.introspect.ClassLoaderProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
addClassNamesInDirectoryWithMethodsAnnotatedWith(answer, file, annotationClass, packageName + file.getName() + ".");
} else if (file.isFile()) {
String name = file.getName();
if (name.endsWith(".class")) {
String className = packageName + (name.substring(0, name.length() - 6).replace('$', '.'));
Class<?> aClass = optionallyFindClass(className);
if (aClass != null && ReflectionHelper.hasMethodWithAnnotation(aClass, annotationClass, true)) {
answer.add(className);
}
}
}
}
}
}
protected Class<? extends Annotation> optionallyFindAnnotationClass(String annotationClassName) {
final Class<? extends Annotation> annotationClass = optionallyFindClass(annotationClassName).asSubclass(Annotation.class);
if (annotationClass != null && Annotation.class.isAssignableFrom(annotationClass)) {
return annotationClass;
}
return null;
}
public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName, Integer limit, Map<Package, ClassLoader[]> packages) {
final Class<? extends Annotation> annotationClass = optionallyFindAnnotationClass(annotationClassName);
if (annotationClass != null) { | Predicate<String> filter = new Predicate<String>() { |
hawtio/hawtio | hawtio-log/src/main/java/io/hawt/log/log4j/ThrowableFormatter.java | // Path: hawtio-log/src/main/java/io/hawt/log/support/Objects.java
// public final class Objects {
//
// public static boolean isBlank(String text) {
// return text == null || text.trim().length() == 0;
// }
//
// /**
// * A helper method for comparing objects for equality while handling nulls
// */
// public static boolean equal(Object a, Object b) {
// if (a == b) {
// return true;
// }
// return a != null && b != null && a.equals(b);
// }
//
// /**
// * A helper method for performing an ordered comparison on the objects
// * handling nulls and objects which do not handle sorting gracefully
// *
// * @param a the first object
// * @param b the second object
// */
// @SuppressWarnings("unchecked")
// public static int compare(Object a, Object b) {
// if (a == b) {
// return 0;
// }
// if (a == null) {
// return -1;
// }
// if (b == null) {
// return 1;
// }
// if (a instanceof Comparable) {
// Comparable comparable = (Comparable)a;
// return comparable.compareTo(b);
// }
// int answer = a.getClass().getName().compareTo(b.getClass().getName());
// if (answer == 0) {
// answer = a.hashCode() - b.hashCode();
// }
// return answer;
// }
//
// public static boolean contains(String matchesText, String... values) {
// for (String v : values) {
// if (v != null && v.contains(matchesText)) {
// return true;
// }
// }
// return false;
// }
// }
| import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.CodeSource;
import java.util.HashMap;
import java.util.Map;
import io.hawt.log.support.Objects; | for (int i = 0; i < elements.length; i++) {
lines[i + 1] = formatElement(elements[i], classMap);
}
return lines;
} catch (Exception ex) {
}
}
return null;
}
/**
* Format one element from stack trace.
*
* @param element element, may not be null.
* @param classMap map of class name to location.
* @return string representation of element.
*/
private String formatElement(final Object element, final Map classMap) {
StringBuffer buf = new StringBuffer("\tat ");
buf.append(element);
try {
String className = getClassNameMethod.invoke(element, (Object[])null).toString();
Object classDetails = classMap.get(className);
if (classDetails != null) {
buf.append(classDetails);
} else {
Class cls = findClass(className);
int detailStart = buf.length();
buf.append('[');
String mavenCoordinates = MavenCoordHelper.getMavenCoordinates(cls); | // Path: hawtio-log/src/main/java/io/hawt/log/support/Objects.java
// public final class Objects {
//
// public static boolean isBlank(String text) {
// return text == null || text.trim().length() == 0;
// }
//
// /**
// * A helper method for comparing objects for equality while handling nulls
// */
// public static boolean equal(Object a, Object b) {
// if (a == b) {
// return true;
// }
// return a != null && b != null && a.equals(b);
// }
//
// /**
// * A helper method for performing an ordered comparison on the objects
// * handling nulls and objects which do not handle sorting gracefully
// *
// * @param a the first object
// * @param b the second object
// */
// @SuppressWarnings("unchecked")
// public static int compare(Object a, Object b) {
// if (a == b) {
// return 0;
// }
// if (a == null) {
// return -1;
// }
// if (b == null) {
// return 1;
// }
// if (a instanceof Comparable) {
// Comparable comparable = (Comparable)a;
// return comparable.compareTo(b);
// }
// int answer = a.getClass().getName().compareTo(b.getClass().getName());
// if (answer == 0) {
// answer = a.hashCode() - b.hashCode();
// }
// return answer;
// }
//
// public static boolean contains(String matchesText, String... values) {
// for (String v : values) {
// if (v != null && v.contains(matchesText)) {
// return true;
// }
// }
// return false;
// }
// }
// Path: hawtio-log/src/main/java/io/hawt/log/log4j/ThrowableFormatter.java
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.CodeSource;
import java.util.HashMap;
import java.util.Map;
import io.hawt.log.support.Objects;
for (int i = 0; i < elements.length; i++) {
lines[i + 1] = formatElement(elements[i], classMap);
}
return lines;
} catch (Exception ex) {
}
}
return null;
}
/**
* Format one element from stack trace.
*
* @param element element, may not be null.
* @param classMap map of class name to location.
* @return string representation of element.
*/
private String formatElement(final Object element, final Map classMap) {
StringBuffer buf = new StringBuffer("\tat ");
buf.append(element);
try {
String className = getClassNameMethod.invoke(element, (Object[])null).toString();
Object classDetails = classMap.get(className);
if (classDetails != null) {
buf.append(classDetails);
} else {
Class cls = findClass(className);
int detailStart = buf.length();
buf.append('[');
String mavenCoordinates = MavenCoordHelper.getMavenCoordinates(cls); | if (!Objects.isBlank(mavenCoordinates)) { |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/Zips.java | // Path: hawtio-util/src/main/java/io/hawt/util/IOHelper.java
// public static int copy(final Reader input, final Writer output) throws IOException {
// return copy(input, output, BUFFER_SIZE);
// }
| import static io.hawt.util.Closeables.closeQuietly;
import static io.hawt.util.IOHelper.copy;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.slf4j.Logger; | }
if (log.isDebugEnabled()) {
log.debug("zipping file " + entry);
}
}
}
zos.closeEntry();
}
}
}
protected static boolean matches(FileFilter filter, File f) {
return filter == null || filter.accept(f);
}
/**
* Unzips the given input stream of a ZIP to the given directory
*/
public static void unzip(InputStream in, File toDir) throws IOException {
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in));
try {
ZipEntry entry = zis.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
String entryName = entry.getName();
File toFile = new File(toDir, entryName);
toFile.getParentFile().mkdirs();
OutputStream os = new FileOutputStream(toFile);
try {
try { | // Path: hawtio-util/src/main/java/io/hawt/util/IOHelper.java
// public static int copy(final Reader input, final Writer output) throws IOException {
// return copy(input, output, BUFFER_SIZE);
// }
// Path: hawtio-util/src/main/java/io/hawt/util/Zips.java
import static io.hawt.util.Closeables.closeQuietly;
import static io.hawt.util.IOHelper.copy;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.slf4j.Logger;
}
if (log.isDebugEnabled()) {
log.debug("zipping file " + entry);
}
}
}
zos.closeEntry();
}
}
}
protected static boolean matches(FileFilter filter, File f) {
return filter == null || filter.accept(f);
}
/**
* Unzips the given input stream of a ZIP to the given directory
*/
public static void unzip(InputStream in, File toDir) throws IOException {
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in));
try {
ZipEntry entry = zis.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
String entryName = entry.getName();
File toFile = new File(toDir, entryName);
toFile.getParentFile().mkdirs();
OutputStream os = new FileOutputStream(toFile);
try {
try { | copy(zis, os); |
vrk-kpa/REST-adapter-service | src/src/main/java/fi/vrk/xroad/restadapterservice/Application.java | // Path: src/src/main/java/fi/vrk/xroad/restadapterservice/filter/ConsumerURIFilter.java
// @Slf4j
// public class ConsumerURIFilter implements Filter {
//
// @Override
// public void init(FilterConfig fc) throws ServletException {
// log.info("Consumer URI filter initialized.");
// }
//
// @Override
// public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException {
// HttpServletRequest request = (HttpServletRequest) req;
// String servletName = "Consumer";
// String oldURI = request.getRequestURI().substring(request.getContextPath().length() + 1);
// log.debug("Incoming request : \"{}\"", oldURI);
//
// if (oldURI.length() > servletName.length()) {
// String resourcePath = oldURI.substring(oldURI.indexOf('/'));
// if (!"/".equals(resourcePath)) {
// // Path must end with "/"
// if (!resourcePath.endsWith("/")) {
// resourcePath += "/";
// }
// log.debug("Resource path : \"{}\"", resourcePath);
// request.setAttribute("resourcePath", resourcePath);
// } else {
// log.trace("Found resource path \"{}\" is not valid.", resourcePath);
// }
// } else {
// log.trace("No resource path found.");
// }
// req.getRequestDispatcher("Consumer").forward(req, res);
// }
//
// @Override
// public void destroy() {
// // Nothing to do here.
// }
// }
| import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.DispatcherType;
import java.util.Arrays;
import java.util.EnumSet;
import fi.vrk.xroad.restadapterservice.filter.ConsumerURIFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer; | /*
* The MIT License
* Copyright © 2017 Population Register Centre (VRK)
*
* 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 fi.vrk.xroad.restadapterservice;
/**
* Rest adapter service application entry point
*/
@Configuration
@Slf4j
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean consumerGatewayBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new ConsumerGateway(), "/Consumer/*");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
public ServletRegistrationBean providerGatewayBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new ProviderGateway(), "/Provider");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
public FilterRegistrationBean consumerURIFilterBean() {
FilterRegistrationBean bean = new FilterRegistrationBean(); | // Path: src/src/main/java/fi/vrk/xroad/restadapterservice/filter/ConsumerURIFilter.java
// @Slf4j
// public class ConsumerURIFilter implements Filter {
//
// @Override
// public void init(FilterConfig fc) throws ServletException {
// log.info("Consumer URI filter initialized.");
// }
//
// @Override
// public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException {
// HttpServletRequest request = (HttpServletRequest) req;
// String servletName = "Consumer";
// String oldURI = request.getRequestURI().substring(request.getContextPath().length() + 1);
// log.debug("Incoming request : \"{}\"", oldURI);
//
// if (oldURI.length() > servletName.length()) {
// String resourcePath = oldURI.substring(oldURI.indexOf('/'));
// if (!"/".equals(resourcePath)) {
// // Path must end with "/"
// if (!resourcePath.endsWith("/")) {
// resourcePath += "/";
// }
// log.debug("Resource path : \"{}\"", resourcePath);
// request.setAttribute("resourcePath", resourcePath);
// } else {
// log.trace("Found resource path \"{}\" is not valid.", resourcePath);
// }
// } else {
// log.trace("No resource path found.");
// }
// req.getRequestDispatcher("Consumer").forward(req, res);
// }
//
// @Override
// public void destroy() {
// // Nothing to do here.
// }
// }
// Path: src/src/main/java/fi/vrk/xroad/restadapterservice/Application.java
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.DispatcherType;
import java.util.Arrays;
import java.util.EnumSet;
import fi.vrk.xroad.restadapterservice.filter.ConsumerURIFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/*
* The MIT License
* Copyright © 2017 Population Register Centre (VRK)
*
* 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 fi.vrk.xroad.restadapterservice;
/**
* Rest adapter service application entry point
*/
@Configuration
@Slf4j
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean consumerGatewayBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new ConsumerGateway(), "/Consumer/*");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
public ServletRegistrationBean providerGatewayBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new ProviderGateway(), "/Provider");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
public FilterRegistrationBean consumerURIFilterBean() {
FilterRegistrationBean bean = new FilterRegistrationBean(); | bean.setFilter(new ConsumerURIFilter()); |
mmastrac/adventure | com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/ActionDirective.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
| import java.util.List;
import com.grack.adventure.parser.SourceLine; | package com.grack.adventure.parser.program;
public class ActionDirective extends Directive {
private final String name; | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
// Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/ActionDirective.java
import java.util.List;
import com.grack.adventure.parser.SourceLine;
package com.grack.adventure.parser.program;
public class ActionDirective extends Directive {
private final String name; | private final List<SourceLine> code; |
mmastrac/adventure | com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/AtDirective.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
| import java.util.List;
import com.grack.adventure.parser.SourceLine; | package com.grack.adventure.parser.program;
public class AtDirective {
private final String place; | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
// Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/AtDirective.java
import java.util.List;
import com.grack.adventure.parser.SourceLine;
package com.grack.adventure.parser.program;
public class AtDirective {
private final String place; | private final List<SourceLine> code; |
mmastrac/adventure | com.grack.adventure.logic/src/test/java/com/grack/adventure/util/RestartableTypeFilteringListIteratorTest.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/util/RestartableTypeFilteringListIterator.java
// public class RestartableTypeFilteringListIterator<U, T extends U> implements Iterator<T> {
// private final Predicate<? super U> isOfT;
// private int index;
// private boolean needNext = true;
// private final List<U> list;
//
// public RestartableTypeFilteringListIterator(List<U> list, Predicate<? super U> isOfT) {
// this(list, isOfT, 0);
// }
//
// public RestartableTypeFilteringListIterator(List<U> list, Predicate<? super U> isOfT, int startIndex) {
// this.list = list;
// this.isOfT = isOfT;
// this.index = startIndex;
// }
//
// private void prepareNext() {
// if (needNext) {
// needNext = false;
//
// for (; index < list.size(); index++) {
// if (isOfT.apply(list.get(index))) {
// return;
// }
// }
//
// index = list.size();
// }
// }
//
// public boolean hasNext() {
// prepareNext();
// return index < list.size();
// }
//
// @SuppressWarnings("unchecked")
// public T next() {
// prepareNext();
// if (index >= list.size())
// throw new IllegalStateException("Past end of list");
// needNext = true;
// return (T) list.get(index++);
// }
//
// public int getNextIndex() {
// return index;
// }
//
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import com.grack.adventure.util.RestartableTypeFilteringListIterator; | package com.grack.adventure.util;
public class RestartableTypeFilteringListIteratorTest {
@Test
public void filterNumbers() {
List<Number> list = Lists.newArrayList();
list.add((int) 1);
list.add((double) 1);
list.add((int) 2);
| // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/util/RestartableTypeFilteringListIterator.java
// public class RestartableTypeFilteringListIterator<U, T extends U> implements Iterator<T> {
// private final Predicate<? super U> isOfT;
// private int index;
// private boolean needNext = true;
// private final List<U> list;
//
// public RestartableTypeFilteringListIterator(List<U> list, Predicate<? super U> isOfT) {
// this(list, isOfT, 0);
// }
//
// public RestartableTypeFilteringListIterator(List<U> list, Predicate<? super U> isOfT, int startIndex) {
// this.list = list;
// this.isOfT = isOfT;
// this.index = startIndex;
// }
//
// private void prepareNext() {
// if (needNext) {
// needNext = false;
//
// for (; index < list.size(); index++) {
// if (isOfT.apply(list.get(index))) {
// return;
// }
// }
//
// index = list.size();
// }
// }
//
// public boolean hasNext() {
// prepareNext();
// return index < list.size();
// }
//
// @SuppressWarnings("unchecked")
// public T next() {
// prepareNext();
// if (index >= list.size())
// throw new IllegalStateException("Past end of list");
// needNext = true;
// return (T) list.get(index++);
// }
//
// public int getNextIndex() {
// return index;
// }
//
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
// Path: com.grack.adventure.logic/src/test/java/com/grack/adventure/util/RestartableTypeFilteringListIteratorTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import com.grack.adventure.util.RestartableTypeFilteringListIterator;
package com.grack.adventure.util;
public class RestartableTypeFilteringListIteratorTest {
@Test
public void filterNumbers() {
List<Number> list = Lists.newArrayList();
list.add((int) 1);
list.add((double) 1);
list.add((int) 2);
| RestartableTypeFilteringListIterator<Number, Integer> iterator = |
mmastrac/adventure | com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/LabelDirective.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
| import java.util.List;
import com.grack.adventure.parser.SourceLine; | package com.grack.adventure.parser.program;
public class LabelDirective extends Directive {
private final String name; | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/SourceLine.java
// public class SourceLine {
// private final MinorOpcode opcode;
//
// private final List<String> args;
//
// public SourceLine(MinorOpcode opcode, List<String> args) {
// this.opcode = opcode;
// this.args = args;
// }
//
// public MinorOpcode getOpcode() {
// return opcode;
// }
//
// public List<String> getArgs() {
// return args;
// }
//
// @Override
// public String toString() {
// if (args == null)
// return opcode.toString();
//
// return opcode + " " + args;
// }
// }
// Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/parser/program/LabelDirective.java
import java.util.List;
import com.grack.adventure.parser.SourceLine;
package com.grack.adventure.parser.program;
public class LabelDirective extends Directive {
private final String name; | private final List<SourceLine> code; |
mmastrac/adventure | com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/entity/VerbEntity.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/Constants.java
// public class Constants {
// /**
// * Set on STATUS if the player moved since the last time this was cleared.
// */
// public static final int STATUS_MOVED = 0;
//
// /**
// * Only show the short description for places if the player has not been
// * here before.
// */
// public static final int STATUS_BRIEF = 1;
//
// /**
// * Never show the long descriptions for places unless LOOKING is set.
// */
// public static final int STATUS_FAST = 2;
//
// /**
// * Show the full description for a place.
// */
// public static final int STATUS_LOOKING = 3;
//
// /**
// * Specifies that the interpreter should attempt to combine the previous and
// * next INPUT.
// */
// public static final int STATUS_PLSCLRFY = 4;
//
// /**
// * Set on STATUS if the player picked up or dropped anything since this bit
// * was cleared.
// */
// public static final int STATUS_JUGGLED = 5;
//
// /**
// * Set on a PLACE if the player has been here before.
// */
// public static final int PLACE_BEEN = 1;
//
// /**
// * Set on an OBJECT if it appears in the location and the location with ID -
// * 1.
// */
// public static final int OBJECT_DUAL = 3;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an OBJECT. Set on all OBJECTs.
// */
// public static final int XOBJECT = 15;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was a VERB. Set on all VERBs.
// */
// public static final int XVERB = 14;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an PLACE. Set on all PLACEes.
// */
// public static final int XPLACE = 13;
//
// /**
// * Flag/value set when input is considered an unknown word.
// */
// public static final int ARG_BADWORD = 12;
//
// /**
// * Special entity ID of the badword.
// */
// public static final int ARG_VALUE_BADWORD = 9999;
//
// /**
// * The ID of an object's location if it's being held.
// */
// public static final int OBJECT_LOCATION_INHAND = -1;
// }
| import com.grack.adventure.kernel.Constants; | package com.grack.adventure.kernel.entity;
public class VerbEntity extends Entity {
public VerbEntity(String name) {
super(name);
}
@Override
public int getDefaultFlags() { | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/Constants.java
// public class Constants {
// /**
// * Set on STATUS if the player moved since the last time this was cleared.
// */
// public static final int STATUS_MOVED = 0;
//
// /**
// * Only show the short description for places if the player has not been
// * here before.
// */
// public static final int STATUS_BRIEF = 1;
//
// /**
// * Never show the long descriptions for places unless LOOKING is set.
// */
// public static final int STATUS_FAST = 2;
//
// /**
// * Show the full description for a place.
// */
// public static final int STATUS_LOOKING = 3;
//
// /**
// * Specifies that the interpreter should attempt to combine the previous and
// * next INPUT.
// */
// public static final int STATUS_PLSCLRFY = 4;
//
// /**
// * Set on STATUS if the player picked up or dropped anything since this bit
// * was cleared.
// */
// public static final int STATUS_JUGGLED = 5;
//
// /**
// * Set on a PLACE if the player has been here before.
// */
// public static final int PLACE_BEEN = 1;
//
// /**
// * Set on an OBJECT if it appears in the location and the location with ID -
// * 1.
// */
// public static final int OBJECT_DUAL = 3;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an OBJECT. Set on all OBJECTs.
// */
// public static final int XOBJECT = 15;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was a VERB. Set on all VERBs.
// */
// public static final int XVERB = 14;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an PLACE. Set on all PLACEes.
// */
// public static final int XPLACE = 13;
//
// /**
// * Flag/value set when input is considered an unknown word.
// */
// public static final int ARG_BADWORD = 12;
//
// /**
// * Special entity ID of the badword.
// */
// public static final int ARG_VALUE_BADWORD = 9999;
//
// /**
// * The ID of an object's location if it's being held.
// */
// public static final int OBJECT_LOCATION_INHAND = -1;
// }
// Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/entity/VerbEntity.java
import com.grack.adventure.kernel.Constants;
package com.grack.adventure.kernel.entity;
public class VerbEntity extends Entity {
public VerbEntity(String name) {
super(name);
}
@Override
public int getDefaultFlags() { | return 1 << Constants.XVERB; |
mmastrac/adventure | com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/entity/PlaceEntity.java | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/Constants.java
// public class Constants {
// /**
// * Set on STATUS if the player moved since the last time this was cleared.
// */
// public static final int STATUS_MOVED = 0;
//
// /**
// * Only show the short description for places if the player has not been
// * here before.
// */
// public static final int STATUS_BRIEF = 1;
//
// /**
// * Never show the long descriptions for places unless LOOKING is set.
// */
// public static final int STATUS_FAST = 2;
//
// /**
// * Show the full description for a place.
// */
// public static final int STATUS_LOOKING = 3;
//
// /**
// * Specifies that the interpreter should attempt to combine the previous and
// * next INPUT.
// */
// public static final int STATUS_PLSCLRFY = 4;
//
// /**
// * Set on STATUS if the player picked up or dropped anything since this bit
// * was cleared.
// */
// public static final int STATUS_JUGGLED = 5;
//
// /**
// * Set on a PLACE if the player has been here before.
// */
// public static final int PLACE_BEEN = 1;
//
// /**
// * Set on an OBJECT if it appears in the location and the location with ID -
// * 1.
// */
// public static final int OBJECT_DUAL = 3;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an OBJECT. Set on all OBJECTs.
// */
// public static final int XOBJECT = 15;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was a VERB. Set on all VERBs.
// */
// public static final int XVERB = 14;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an PLACE. Set on all PLACEes.
// */
// public static final int XPLACE = 13;
//
// /**
// * Flag/value set when input is considered an unknown word.
// */
// public static final int ARG_BADWORD = 12;
//
// /**
// * Special entity ID of the badword.
// */
// public static final int ARG_VALUE_BADWORD = 9999;
//
// /**
// * The ID of an object's location if it's being held.
// */
// public static final int OBJECT_LOCATION_INHAND = -1;
// }
| import java.util.List;
import com.grack.adventure.kernel.Constants; | package com.grack.adventure.kernel.entity;
public class PlaceEntity extends Entity {
private final String shortDesc;
private final List<String> states;
public PlaceEntity(String name, String shortDesc, List<String> states) {
super(name);
this.shortDesc = shortDesc;
this.states = states;
}
@Override
public int getDefaultFlags() { | // Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/Constants.java
// public class Constants {
// /**
// * Set on STATUS if the player moved since the last time this was cleared.
// */
// public static final int STATUS_MOVED = 0;
//
// /**
// * Only show the short description for places if the player has not been
// * here before.
// */
// public static final int STATUS_BRIEF = 1;
//
// /**
// * Never show the long descriptions for places unless LOOKING is set.
// */
// public static final int STATUS_FAST = 2;
//
// /**
// * Show the full description for a place.
// */
// public static final int STATUS_LOOKING = 3;
//
// /**
// * Specifies that the interpreter should attempt to combine the previous and
// * next INPUT.
// */
// public static final int STATUS_PLSCLRFY = 4;
//
// /**
// * Set on STATUS if the player picked up or dropped anything since this bit
// * was cleared.
// */
// public static final int STATUS_JUGGLED = 5;
//
// /**
// * Set on a PLACE if the player has been here before.
// */
// public static final int PLACE_BEEN = 1;
//
// /**
// * Set on an OBJECT if it appears in the location and the location with ID -
// * 1.
// */
// public static final int OBJECT_DUAL = 3;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an OBJECT. Set on all OBJECTs.
// */
// public static final int XOBJECT = 15;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was a VERB. Set on all VERBs.
// */
// public static final int XVERB = 14;
//
// /**
// * Set on ARG1 or ARG2 to indicate that it holds an object. Set on STATUS to
// * indicate that the first word was an PLACE. Set on all PLACEes.
// */
// public static final int XPLACE = 13;
//
// /**
// * Flag/value set when input is considered an unknown word.
// */
// public static final int ARG_BADWORD = 12;
//
// /**
// * Special entity ID of the badword.
// */
// public static final int ARG_VALUE_BADWORD = 9999;
//
// /**
// * The ID of an object's location if it's being held.
// */
// public static final int OBJECT_LOCATION_INHAND = -1;
// }
// Path: com.grack.adventure.logic/src/main/java/com/grack/adventure/kernel/entity/PlaceEntity.java
import java.util.List;
import com.grack.adventure.kernel.Constants;
package com.grack.adventure.kernel.entity;
public class PlaceEntity extends Entity {
private final String shortDesc;
private final List<String> states;
public PlaceEntity(String name, String shortDesc, List<String> states) {
super(name);
this.shortDesc = shortDesc;
this.states = states;
}
@Override
public int getDefaultFlags() { | return 1 << Constants.XPLACE; |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
| import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern; | package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer()); | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern;
package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer()); | addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer()); |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
| import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern; | package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer());
addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer()); | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern;
package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer());
addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer()); | addDeserializer(ObjectId.class, new BsonObjectIdDeserializer()); |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
| import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern; | package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer());
addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
addDeserializer(Pattern.class, new BsonRegexDeserializer()); | // Path: src/main/java/de/undercouch/bson4jackson/types/JavaScript.java
// public class JavaScript {
// /**
// * The actual code
// */
// protected final String _code;
//
// /**
// * The scope (may be null)
// */
// protected final Map<String, Object> _scope;
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// */
// public JavaScript(String code) {
// this(code, null);
// }
//
// /**
// * Constructs a new JavaScript object
// * @param code the actual code
// * @param scope the scope (may be null)
// */
// public JavaScript(String code, Map<String, Object> scope) {
// _code = code;
// _scope = scope;
// }
//
// /**
// * @return the actual code
// */
// public String getCode() {
// return _code;
// }
//
// /**
// * @return the scope (may be null)
// */
// public Map<String, Object> getScope() {
// return _scope;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/ObjectId.java
// public class ObjectId {
// private final int timestamp;
// private final int counter;
// private final int randomValue1;
// private final short randomValue2;
//
// /**
// * Constructs a new identifier
// * @param timestamp the timestamp
// * @param counter the counter
// * @param randomValue1 a random value
// * @param randomValue2 a random value
// */
// public ObjectId(int timestamp, int counter, int randomValue1, short randomValue2) {
// this.timestamp = timestamp;
// this.counter = counter;
// this.randomValue1 = randomValue1;
// this.randomValue2 = randomValue2;
// }
//
// /**
// * Constructs a new identifier from legacy parameters
// * @param time the timestamp
// * @param machine the machine ID
// * @param inc the counter
// * @deprecated this constructor uses the legacy format of {@link ObjectId}.
// * Please use the modern {@link #ObjectId(int, int, int, short)} instead.
// */
// @Deprecated
// public ObjectId(int time, int machine, int inc) {
// this.timestamp = time;
// this.randomValue1 = (machine >> 8) & 0xFFFFFF;
// this.randomValue2 = (short)((machine & 0xFF) << 8 | (inc >> 24) & 0xFF);
// this.counter = inc & 0xFFFFFF;
// }
//
// /**
// * @return the timestamp
// * @deprecated Use {@link #getTimestamp()} instead
// */
// @Deprecated
// public int getTime() {
// return timestamp;
// }
//
// /**
// * @return the timestamp
// */
// public int getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the machine ID
// * @deprecated This method will be removed in a subsequent version of
// * bson4jackson. There is no replacement
// */
// @Deprecated
// public int getMachine() {
// return (randomValue1 & 0xFFFFFF) << 8 | (randomValue2 >> 8) & 0xFF;
// }
//
// /**
// * @return the counter
// * @deprecated Use {@link #getCounter()}
// */
// @Deprecated
// public int getInc() {
// return (randomValue2 & 0xFF) << 24 | counter;
// }
//
// /**
// * @return the counter
// */
// public int getCounter() {
// return counter;
// }
//
// /**
// * @return a random value
// */
// public int getRandomValue1() {
// return randomValue1;
// }
//
// /**
// * @return a random value
// */
// public short getRandomValue2() {
// return randomValue2;
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/types/Timestamp.java
// public class Timestamp {
// /**
// * The increment
// */
// protected final int _inc;
//
// /**
// * The actual timestamp
// */
// protected final int _time;
//
// /**
// * Constructs a new timestamp object
// * @param time the actual timestamp
// * @param inc the increment
// */
// public Timestamp(int time, int inc) {
// _inc = inc;
// _time = time;
// }
//
// /**
// * @return the increment
// */
// public int getInc() {
// return _inc;
// }
//
// /**
// * @return the actual timestamp
// */
// public int getTime() {
// return _time;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof Timestamp)) {
// return false;
// }
// Timestamp t = (Timestamp)o;
// return (_inc == t._inc && _time == t._time);
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + _inc;
// result = prime * result + _time;
// return result;
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
import com.fasterxml.jackson.databind.module.SimpleDeserializers;
import de.undercouch.bson4jackson.types.JavaScript;
import de.undercouch.bson4jackson.types.ObjectId;
import de.undercouch.bson4jackson.types.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern;
package de.undercouch.bson4jackson.deserializers;
/**
* BSON deserializers
* @author Michel Kraemer
* @since 2.3.2
*/
public class BsonDeserializers extends SimpleDeserializers {
private static final long serialVersionUID = 261492073508673840L;
/**
* Default constructor
*/
public BsonDeserializers() {
addDeserializer(Date.class, new BsonDateDeserializer());
addDeserializer(Calendar.class, new BsonCalendarDeserializer());
addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
addDeserializer(Pattern.class, new BsonRegexDeserializer()); | addDeserializer(Timestamp.class, new BsonTimestampDeserializer()); |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/BsonFactory.java | // Path: src/main/java/de/undercouch/bson4jackson/io/UnsafeByteArrayInputStream.java
// public class UnsafeByteArrayInputStream extends InputStream {
// /**
// * The buffer to serve
// */
// protected final byte[] _buf;
//
// /**
// * The current position in the buffer
// */
// protected int _pos;
//
// /**
// * The index one greater than the last byte to serve
// */
// protected int _count;
//
// /**
// * The current marked position
// */
// protected int _mark;
//
// /**
// * Creates a new stream that serves the whole given array
// * @param buf the array to serve
// */
// public UnsafeByteArrayInputStream(byte[] buf) {
// this(buf, 0, buf.length);
// }
//
// /**
// * Creates a new stream that serves part of the given array
// * @param buf the array to serve
// * @param off the index of the first byte to serve
// * @param len the number of bytes to serve
// */
// public UnsafeByteArrayInputStream(byte[] buf, int off, int len) {
// _buf = buf;
// _pos = off;
// _count = Math.min(off + len, buf.length);
// _mark = off;
// }
//
// @Override
// public int read() {
// return _pos >= _count ? -1 : (_buf[_pos++] & 0xFF);
// }
//
// @Override
// public int read(byte[] b, int off, int len) {
// if (_pos >= _count) {
// return -1;
// }
//
// int avail = _count - _pos;
// int cnt = Math.min(len, avail);
// System.arraycopy(_buf, _pos, b, off, cnt);
// _pos += cnt;
// return cnt;
// }
//
// @Override
// public long skip(long n) {
// if (n <= 0) {
// return 0;
// }
//
// int avail = _count - _pos;
// if (avail <= 0) {
// return 0;
// }
// if (avail < n) {
// n = avail;
// }
// _pos += n;
// return n;
// }
//
// @Override
// public int available() {
// return _count - _pos;
// }
//
// @Override
// public boolean markSupported() {
// return true;
// }
//
// @Override
// public void mark(int readlimit) {
// _mark = _pos;
// }
//
// @Override
// public void reset() {
// _pos = _mark;
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
// }
| import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.core.io.IOContext;
import de.undercouch.bson4jackson.io.UnsafeByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URL; |
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(byte[] data, int offset, int len, IOContext ctxt) {
return _createParser(data, offset, len, ctxt);
}
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(InputStream in, IOContext ctxt) {
return _createParser(in, ctxt);
}
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(Reader r, IOContext ctxt) {
return _createParser(r, ctxt);
}
@Override
protected BsonParser _createParser(byte[] data, int offset, int len, IOContext ctxt) { | // Path: src/main/java/de/undercouch/bson4jackson/io/UnsafeByteArrayInputStream.java
// public class UnsafeByteArrayInputStream extends InputStream {
// /**
// * The buffer to serve
// */
// protected final byte[] _buf;
//
// /**
// * The current position in the buffer
// */
// protected int _pos;
//
// /**
// * The index one greater than the last byte to serve
// */
// protected int _count;
//
// /**
// * The current marked position
// */
// protected int _mark;
//
// /**
// * Creates a new stream that serves the whole given array
// * @param buf the array to serve
// */
// public UnsafeByteArrayInputStream(byte[] buf) {
// this(buf, 0, buf.length);
// }
//
// /**
// * Creates a new stream that serves part of the given array
// * @param buf the array to serve
// * @param off the index of the first byte to serve
// * @param len the number of bytes to serve
// */
// public UnsafeByteArrayInputStream(byte[] buf, int off, int len) {
// _buf = buf;
// _pos = off;
// _count = Math.min(off + len, buf.length);
// _mark = off;
// }
//
// @Override
// public int read() {
// return _pos >= _count ? -1 : (_buf[_pos++] & 0xFF);
// }
//
// @Override
// public int read(byte[] b, int off, int len) {
// if (_pos >= _count) {
// return -1;
// }
//
// int avail = _count - _pos;
// int cnt = Math.min(len, avail);
// System.arraycopy(_buf, _pos, b, off, cnt);
// _pos += cnt;
// return cnt;
// }
//
// @Override
// public long skip(long n) {
// if (n <= 0) {
// return 0;
// }
//
// int avail = _count - _pos;
// if (avail <= 0) {
// return 0;
// }
// if (avail < n) {
// n = avail;
// }
// _pos += n;
// return n;
// }
//
// @Override
// public int available() {
// return _count - _pos;
// }
//
// @Override
// public boolean markSupported() {
// return true;
// }
//
// @Override
// public void mark(int readlimit) {
// _mark = _pos;
// }
//
// @Override
// public void reset() {
// _pos = _mark;
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/BsonFactory.java
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.core.io.IOContext;
import de.undercouch.bson4jackson.io.UnsafeByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(byte[] data, int offset, int len, IOContext ctxt) {
return _createParser(data, offset, len, ctxt);
}
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(InputStream in, IOContext ctxt) {
return _createParser(in, ctxt);
}
/**
* @deprecated Removed in Jackson 2.4
*/
@Deprecated
@SuppressWarnings("javadoc")
protected BsonParser _createJsonParser(Reader r, IOContext ctxt) {
return _createParser(r, ctxt);
}
@Override
protected BsonParser _createParser(byte[] data, int offset, int len, IOContext ctxt) { | return _createParser(new UnsafeByteArrayInputStream(data, offset, len), ctxt); |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/BsonModule.java | // Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
// public class BsonDeserializers extends SimpleDeserializers {
// private static final long serialVersionUID = 261492073508673840L;
//
// /**
// * Default constructor
// */
// public BsonDeserializers() {
// addDeserializer(Date.class, new BsonDateDeserializer());
// addDeserializer(Calendar.class, new BsonCalendarDeserializer());
// addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
// addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
// addDeserializer(Pattern.class, new BsonRegexDeserializer());
// addDeserializer(Timestamp.class, new BsonTimestampDeserializer());
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/serializers/BsonSerializers.java
// public class BsonSerializers extends SimpleSerializers {
// private static final long serialVersionUID = -1327629614239143170L;
//
// /**
// * Default constructor
// */
// public BsonSerializers() {
// addSerializer(Date.class, new BsonDateSerializer());
// addSerializer(Calendar.class, new BsonCalendarSerializer());
// addSerializer(JavaScript.class, new BsonJavaScriptSerializer());
// addSerializer(ObjectId.class, new BsonObjectIdSerializer());
// addSerializer(Pattern.class, new BsonRegexSerializer());
// addSerializer(Symbol.class, new BsonSymbolSerializer());
// addSerializer(Timestamp.class, new BsonTimestampSerializer());
// addSerializer(UUID.class, new BsonUuidSerializer());
// }
// }
| import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import de.undercouch.bson4jackson.deserializers.BsonDeserializers;
import de.undercouch.bson4jackson.serializers.BsonSerializers; | package de.undercouch.bson4jackson;
/**
* Module that configures Jackson to be able to correctly handle all BSON types
* @author James Roper
* @since 1.3
*/
public class BsonModule extends Module {
@Override
public String getModuleName() {
return "BsonModule";
}
@Override
public Version version() {
return new Version(2, 9, 2, "", "de.undercouch", "bson4jackson");
}
@Override
public void setupModule(SetupContext context) { | // Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
// public class BsonDeserializers extends SimpleDeserializers {
// private static final long serialVersionUID = 261492073508673840L;
//
// /**
// * Default constructor
// */
// public BsonDeserializers() {
// addDeserializer(Date.class, new BsonDateDeserializer());
// addDeserializer(Calendar.class, new BsonCalendarDeserializer());
// addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
// addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
// addDeserializer(Pattern.class, new BsonRegexDeserializer());
// addDeserializer(Timestamp.class, new BsonTimestampDeserializer());
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/serializers/BsonSerializers.java
// public class BsonSerializers extends SimpleSerializers {
// private static final long serialVersionUID = -1327629614239143170L;
//
// /**
// * Default constructor
// */
// public BsonSerializers() {
// addSerializer(Date.class, new BsonDateSerializer());
// addSerializer(Calendar.class, new BsonCalendarSerializer());
// addSerializer(JavaScript.class, new BsonJavaScriptSerializer());
// addSerializer(ObjectId.class, new BsonObjectIdSerializer());
// addSerializer(Pattern.class, new BsonRegexSerializer());
// addSerializer(Symbol.class, new BsonSymbolSerializer());
// addSerializer(Timestamp.class, new BsonTimestampSerializer());
// addSerializer(UUID.class, new BsonUuidSerializer());
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/BsonModule.java
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import de.undercouch.bson4jackson.deserializers.BsonDeserializers;
import de.undercouch.bson4jackson.serializers.BsonSerializers;
package de.undercouch.bson4jackson;
/**
* Module that configures Jackson to be able to correctly handle all BSON types
* @author James Roper
* @since 1.3
*/
public class BsonModule extends Module {
@Override
public String getModuleName() {
return "BsonModule";
}
@Override
public Version version() {
return new Version(2, 9, 2, "", "de.undercouch", "bson4jackson");
}
@Override
public void setupModule(SetupContext context) { | context.addSerializers(new BsonSerializers()); |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/BsonModule.java | // Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
// public class BsonDeserializers extends SimpleDeserializers {
// private static final long serialVersionUID = 261492073508673840L;
//
// /**
// * Default constructor
// */
// public BsonDeserializers() {
// addDeserializer(Date.class, new BsonDateDeserializer());
// addDeserializer(Calendar.class, new BsonCalendarDeserializer());
// addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
// addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
// addDeserializer(Pattern.class, new BsonRegexDeserializer());
// addDeserializer(Timestamp.class, new BsonTimestampDeserializer());
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/serializers/BsonSerializers.java
// public class BsonSerializers extends SimpleSerializers {
// private static final long serialVersionUID = -1327629614239143170L;
//
// /**
// * Default constructor
// */
// public BsonSerializers() {
// addSerializer(Date.class, new BsonDateSerializer());
// addSerializer(Calendar.class, new BsonCalendarSerializer());
// addSerializer(JavaScript.class, new BsonJavaScriptSerializer());
// addSerializer(ObjectId.class, new BsonObjectIdSerializer());
// addSerializer(Pattern.class, new BsonRegexSerializer());
// addSerializer(Symbol.class, new BsonSymbolSerializer());
// addSerializer(Timestamp.class, new BsonTimestampSerializer());
// addSerializer(UUID.class, new BsonUuidSerializer());
// }
// }
| import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import de.undercouch.bson4jackson.deserializers.BsonDeserializers;
import de.undercouch.bson4jackson.serializers.BsonSerializers; | package de.undercouch.bson4jackson;
/**
* Module that configures Jackson to be able to correctly handle all BSON types
* @author James Roper
* @since 1.3
*/
public class BsonModule extends Module {
@Override
public String getModuleName() {
return "BsonModule";
}
@Override
public Version version() {
return new Version(2, 9, 2, "", "de.undercouch", "bson4jackson");
}
@Override
public void setupModule(SetupContext context) {
context.addSerializers(new BsonSerializers()); | // Path: src/main/java/de/undercouch/bson4jackson/deserializers/BsonDeserializers.java
// public class BsonDeserializers extends SimpleDeserializers {
// private static final long serialVersionUID = 261492073508673840L;
//
// /**
// * Default constructor
// */
// public BsonDeserializers() {
// addDeserializer(Date.class, new BsonDateDeserializer());
// addDeserializer(Calendar.class, new BsonCalendarDeserializer());
// addDeserializer(JavaScript.class, new BsonJavaScriptDeserializer());
// addDeserializer(ObjectId.class, new BsonObjectIdDeserializer());
// addDeserializer(Pattern.class, new BsonRegexDeserializer());
// addDeserializer(Timestamp.class, new BsonTimestampDeserializer());
// }
// }
//
// Path: src/main/java/de/undercouch/bson4jackson/serializers/BsonSerializers.java
// public class BsonSerializers extends SimpleSerializers {
// private static final long serialVersionUID = -1327629614239143170L;
//
// /**
// * Default constructor
// */
// public BsonSerializers() {
// addSerializer(Date.class, new BsonDateSerializer());
// addSerializer(Calendar.class, new BsonCalendarSerializer());
// addSerializer(JavaScript.class, new BsonJavaScriptSerializer());
// addSerializer(ObjectId.class, new BsonObjectIdSerializer());
// addSerializer(Pattern.class, new BsonRegexSerializer());
// addSerializer(Symbol.class, new BsonSymbolSerializer());
// addSerializer(Timestamp.class, new BsonTimestampSerializer());
// addSerializer(UUID.class, new BsonUuidSerializer());
// }
// }
// Path: src/main/java/de/undercouch/bson4jackson/BsonModule.java
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import de.undercouch.bson4jackson.deserializers.BsonDeserializers;
import de.undercouch.bson4jackson.serializers.BsonSerializers;
package de.undercouch.bson4jackson;
/**
* Module that configures Jackson to be able to correctly handle all BSON types
* @author James Roper
* @since 1.3
*/
public class BsonModule extends Module {
@Override
public String getModuleName() {
return "BsonModule";
}
@Override
public Version version() {
return new Version(2, 9, 2, "", "de.undercouch", "bson4jackson");
}
@Override
public void setupModule(SetupContext context) {
context.addSerializers(new BsonSerializers()); | context.addDeserializers(new BsonDeserializers()); |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo; | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
// Path: src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo; | private AssetObjectService assetObjectService; |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo;
private AssetObjectService assetObjectService;
@Before
public void setUp() throws Exception {
final AssetManagementServiceImpl assetManagementService = new AssetManagementServiceImpl();
assetRepo = mock(AssetRepo.class);
assetObjectService = mock(AssetObjectService.class);
ReflectionTestUtils.setField(assetManagementService, "assetRepo", assetRepo);
ReflectionTestUtils.setField(assetManagementService, "assetObjectService", assetObjectService);
this.assetManagementService = assetManagementService;
}
@Test
public void testSaveMetadata() throws Exception {
| // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
// Path: src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo;
private AssetObjectService assetObjectService;
@Before
public void setUp() throws Exception {
final AssetManagementServiceImpl assetManagementService = new AssetManagementServiceImpl();
assetRepo = mock(AssetRepo.class);
assetObjectService = mock(AssetObjectService.class);
ReflectionTestUtils.setField(assetManagementService, "assetRepo", assetRepo);
ReflectionTestUtils.setField(assetManagementService, "assetObjectService", assetObjectService);
this.assetManagementService = assetManagementService;
}
@Test
public void testSaveMetadata() throws Exception {
| Asset asset = new WorldAsset(); |
moorkop/mccy-engine | src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java | // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
| import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo;
private AssetObjectService assetObjectService;
@Before
public void setUp() throws Exception {
final AssetManagementServiceImpl assetManagementService = new AssetManagementServiceImpl();
assetRepo = mock(AssetRepo.class);
assetObjectService = mock(AssetObjectService.class);
ReflectionTestUtils.setField(assetManagementService, "assetRepo", assetRepo);
ReflectionTestUtils.setField(assetManagementService, "assetObjectService", assetObjectService);
this.assetManagementService = assetManagementService;
}
@Test
public void testSaveMetadata() throws Exception {
| // Path: src/main/java/me/itzg/mccy/model/Asset.java
// @Document(indexName = DocumentCommon.INDEX, type = Asset.TYPE)
// @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property = "type")
// public abstract class Asset<DT> {
// public static final String TYPE = "asset";
//
// @Id
// @NotNull
// private String id;
//
// @NotNull
// private AssetCategory category;
//
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String nativeId;
// @NotNull
// private String name;
// private String description;
// private URL homepage;
// private boolean visibleToAll;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private String owner;
// private ComparableVersion version;
// private ComparableVersion compatibleMcVersion;
// private List<ServerType> compatibleMcTypes;
// @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
// private List<String> authors;
//
// @JsonIgnore // so that mapping of 'details' doesn't collide
// public abstract DT getDetails();
//
// public String getNativeId() {
// return nativeId;
// }
//
// public void setNativeId(String nativeId) {
// this.nativeId = nativeId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public URL getHomepage() {
// return homepage;
// }
//
// public void setHomepage(URL homepage) {
// this.homepage = homepage;
// }
//
// public boolean isVisibleToAll() {
// return visibleToAll;
// }
//
// public void setVisibleToAll(boolean visibleToAll) {
// this.visibleToAll = visibleToAll;
// }
//
// public String getOwner() {
// return owner;
// }
//
// public void setOwner(String owner) {
// this.owner = owner;
// }
//
// public ComparableVersion getVersion() {
// return version;
// }
//
// public void setVersion(ComparableVersion version) {
// this.version = version;
// }
//
// public ComparableVersion getCompatibleMcVersion() {
// return compatibleMcVersion;
// }
//
// public void setCompatibleMcVersion(ComparableVersion compatibleMcVersion) {
// this.compatibleMcVersion = compatibleMcVersion;
// }
//
// public List<ServerType> getCompatibleMcTypes() {
// return compatibleMcTypes;
// }
//
// public void setCompatibleMcTypes(List<ServerType> compatibleMcTypes) {
// this.compatibleMcTypes = compatibleMcTypes;
// }
//
// public List<String> getAuthors() {
// return authors;
// }
//
// public void setAuthors(List<String> authors) {
// this.authors = authors;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public AssetCategory getCategory() {
// return category;
// }
//
// public void setCategory(AssetCategory category) {
// this.category = category;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/model/WorldAsset.java
// public class WorldAsset extends Asset<WorldDescriptor> {
//
// private WorldDescriptor worldDetails;
//
// @Override
// public WorldDescriptor getDetails() {
// return worldDetails;
// }
//
// public WorldDescriptor getWorldDetails() {
// return worldDetails;
// }
//
// public void setWorldDetails(WorldDescriptor worldDetails) {
// this.worldDetails = worldDetails;
// }
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetManagementService.java
// public interface AssetManagementService {
// void saveMetadata(AssetCategory category, String assetId, Asset asset);
//
// void delete(AssetCategory category, String assetId);
//
// List<Asset> suggest(AssetCategory category, String query);
// }
//
// Path: src/main/java/me/itzg/mccy/services/assets/AssetObjectService.java
// public interface AssetObjectService {
// void store(MultipartFile objectFile, String parentAssetId, AssetObjectPurpose purpose) throws IOException;
//
// Resource retrieve(String assetId) throws FileNotFoundException;
//
// void deleteObjectsOfAsset(String assetId);
// }
// Path: src/test/java/me/itzg/mccy/services/assets/impl/AssetManagementServiceImplTest.java
import me.itzg.mccy.model.Asset;
import me.itzg.mccy.model.AssetCategory;
import me.itzg.mccy.model.WorldAsset;
import me.itzg.mccy.repos.AssetRepo;
import me.itzg.mccy.services.assets.AssetManagementService;
import me.itzg.mccy.services.assets.AssetObjectService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package me.itzg.mccy.services.assets.impl;
/**
* @author Geoff Bourne
* @since 0.2
*/
public class AssetManagementServiceImplTest {
private AssetManagementService assetManagementService;
private AssetRepo assetRepo;
private AssetObjectService assetObjectService;
@Before
public void setUp() throws Exception {
final AssetManagementServiceImpl assetManagementService = new AssetManagementServiceImpl();
assetRepo = mock(AssetRepo.class);
assetObjectService = mock(AssetObjectService.class);
ReflectionTestUtils.setField(assetManagementService, "assetRepo", assetRepo);
ReflectionTestUtils.setField(assetManagementService, "assetObjectService", assetObjectService);
this.assetManagementService = assetManagementService;
}
@Test
public void testSaveMetadata() throws Exception {
| Asset asset = new WorldAsset(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.