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
|
|---|---|---|---|---|---|---|
galan/verjson
|
src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
|
NoopStep noop;
|
galan/verjson
|
src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
NoopStep noop;
@Before
public void before() {
ss = new DefaultStepSequencer();
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
NoopStep noop;
@Before
public void before() {
ss = new DefaultStepSequencer();
|
validate = new DummyValidation(null);
|
galan/verjson
|
src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
NoopStep noop;
@Before
public void before() {
ss = new DefaultStepSequencer();
validate = new DummyValidation(null);
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/IncrementVersionStep.java
// public class IncrementVersionStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// Long version = MetaWrapper.getVersion(node);
// MetaWrapper.setVersion(node, version++);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/AbstractStepSequencerParent.java
import org.junit.Before;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.step.IncrementVersionStep;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Abstract parent for StepSequencer tests
*
* @author daniel
*/
public class AbstractStepSequencerParent extends AbstractTestParent {
DefaultStepSequencer ss;
Validation validate;
Transformation transform;
IncrementVersionStep increment;
NoopStep noop;
@Before
public void before() {
ss = new DefaultStepSequencer();
validate = new DummyValidation(null);
|
transform = new DummyTransformation();
|
galan/verjson
|
src/main/java/de/galan/verjson/step/transformation/Transformation.java
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
|
import com.fasterxml.jackson.databind.JsonNode;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
|
package de.galan.verjson.step.transformation;
/**
* Transforms a serialized object from one version to the next, using the underlying json representation. Static helper
* methods are available in the Transformations class.
*
* @author daniel
*/
public abstract class Transformation implements Step {
@Override
public void process(JsonNode node) {
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
import com.fasterxml.jackson.databind.JsonNode;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
package de.galan.verjson.step.transformation;
/**
* Transforms a serialized object from one version to the next, using the underlying json representation. Static helper
* methods are available in the Transformations class.
*
* @author daniel
*/
public abstract class Transformation implements Step {
@Override
public void process(JsonNode node) {
|
transform(MetaWrapper.getData(node));
|
galan/verjson
|
src/main/java/de/galan/verjson/core/ProxyStepComparator.java
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/main/java/de/galan/verjson/core/ProxyStepComparator.java
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
|
order.add(Transformation.class);
|
galan/verjson
|
src/main/java/de/galan/verjson/core/ProxyStepComparator.java
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
order.add(Transformation.class);
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/main/java/de/galan/verjson/core/ProxyStepComparator.java
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
order.add(Transformation.class);
|
order.add(Validation.class);
|
galan/verjson
|
src/main/java/de/galan/verjson/core/ProxyStepComparator.java
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
order.add(Transformation.class);
order.add(Validation.class);
}
@Override
public int compare(ProxyStep s1, ProxyStep s2) {
int result = ObjectUtils.compare(s1.getSourceVersion(), s2.getSourceVersion());
if (result == 0) {
|
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/main/java/de/galan/verjson/core/ProxyStepComparator.java
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import com.google.common.collect.Lists;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* Sorts {@link ProxyStep}s, small sourceVersions before larger. Order inside a sourceVersion: Validation,
* Transformation, other.
*
* @author daniel
*/
public class ProxyStepComparator implements Comparator<ProxyStep> {
List<Class<?>> order = Lists.newArrayList();
public ProxyStepComparator() {
order.add(Transformation.class);
order.add(Validation.class);
}
@Override
public int compare(ProxyStep s1, ProxyStep s2) {
int result = ObjectUtils.compare(s1.getSourceVersion(), s2.getSourceVersion());
if (result == 0) {
|
Class<? extends Step> c1 = s1.getStep().getClass();
|
galan/verjson
|
src/test/java/de/galan/verjson/util/TransformationsTest.java
|
// Path: src/main/java/de/galan/verjson/util/Transformations.java
// public final class Transformations {
//
// /** Returns the given node as ObjectNode (cast). */
// public static ObjectNode obj(JsonNode node) {
// return node != null ? (ObjectNode)node : null;
// }
//
//
// /** Returns the field from a ObjectNode as ObjectNode */
// public static ObjectNode getObj(ObjectNode obj, String fieldName) {
// return obj != null ? obj(obj.get(fieldName)) : null;
// }
//
//
// /** Removes the field from a ObjectNode and returns it as ObjectNode */
// public static ObjectNode getObjAndRemove(ObjectNode obj, String fieldName) {
// ObjectNode result = null;
// if (obj != null) {
// result = obj(remove(obj, fieldName));
// }
// return result;
// }
//
//
// /** Creates a ArrayNode from the given elements, returns null if no elements are provided */
// public static ArrayNode createArray(JsonNode... nodes) {
// return createArray(false, nodes);
// }
//
//
// /**
// * Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and
// * fallbackToEmptyArray is true, null if false.
// */
// public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) {
// ArrayNode array = null;
// for (JsonNode element: nodes) {
// if (element != null) {
// if (array == null) {
// array = new ArrayNode(JsonNodeFactory.instance);
// }
// array.add(element);
// }
// }
// if ((array == null) && fallbackToEmptyArray) {
// array = new ArrayNode(JsonNodeFactory.instance);
// }
// return array;
// }
//
//
// /** Returns the given element as ArrayNode (cast). */
// public static ArrayNode array(JsonNode node) {
// return node != null ? (ArrayNode)node : null;
// }
//
//
// /** Returns the field from a ObjectNode as ArrayNode */
// public static ArrayNode getArray(ObjectNode obj, String fieldName) {
// return obj == null ? null : array(obj.get(fieldName));
// }
//
//
// /** Removes the field from a ObjectNode and returns it as ArrayNode */
// public static ArrayNode getArrayAndRemove(ObjectNode obj, String fieldName) {
// ArrayNode result = null;
// if (obj != null) {
// result = array(remove(obj, fieldName));
// }
// return result;
// }
//
//
// /** Removes the field with the given name from the given ObjectNode */
// public static JsonNode remove(ObjectNode obj, String fieldName) {
// JsonNode result = null;
// if (obj != null) {
// result = obj.remove(fieldName);
// }
// return result;
// }
//
//
// /** Renames a field in a ObjectNode from the oldFieldName to the newFieldName */
// public static void rename(ObjectNode obj, String oldFieldName, String newFieldName) {
// if (obj != null && isNotBlank(oldFieldName) && isNotBlank(newFieldName)) {
// JsonNode node = remove(obj, oldFieldName);
// if (node != null) {
// obj.set(newFieldName, node);
// }
// }
// }
//
// }
|
import static de.galan.verjson.util.Transformations.*;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.galan.commons.test.AbstractTestParent;
|
rename(null, "x", "x");
}
@Test
public void renameNothing() throws Exception {
ObjectNode obj = createObj().put("a", "b").get();
rename(obj, null, null);
rename(obj, "", null);
rename(obj, null, "");
rename(obj, "", "");
rename(obj, "x", null);
rename(obj, "", "a");
rename(obj, "x", "x");
assertThat(obj.get("a").asText()).isEqualTo("b");
assertThat(obj.size()).isEqualTo(1);
}
@Test
public void testRename() throws Exception {
ObjectNode obj = createObj().put("a", "b").get();
rename(obj, "a", "y");
assertThat(obj.get("y").asText()).isEqualTo("b");
assertThat(obj.size()).isEqualTo(1);
}
@Test
public void create() {
|
// Path: src/main/java/de/galan/verjson/util/Transformations.java
// public final class Transformations {
//
// /** Returns the given node as ObjectNode (cast). */
// public static ObjectNode obj(JsonNode node) {
// return node != null ? (ObjectNode)node : null;
// }
//
//
// /** Returns the field from a ObjectNode as ObjectNode */
// public static ObjectNode getObj(ObjectNode obj, String fieldName) {
// return obj != null ? obj(obj.get(fieldName)) : null;
// }
//
//
// /** Removes the field from a ObjectNode and returns it as ObjectNode */
// public static ObjectNode getObjAndRemove(ObjectNode obj, String fieldName) {
// ObjectNode result = null;
// if (obj != null) {
// result = obj(remove(obj, fieldName));
// }
// return result;
// }
//
//
// /** Creates a ArrayNode from the given elements, returns null if no elements are provided */
// public static ArrayNode createArray(JsonNode... nodes) {
// return createArray(false, nodes);
// }
//
//
// /**
// * Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and
// * fallbackToEmptyArray is true, null if false.
// */
// public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) {
// ArrayNode array = null;
// for (JsonNode element: nodes) {
// if (element != null) {
// if (array == null) {
// array = new ArrayNode(JsonNodeFactory.instance);
// }
// array.add(element);
// }
// }
// if ((array == null) && fallbackToEmptyArray) {
// array = new ArrayNode(JsonNodeFactory.instance);
// }
// return array;
// }
//
//
// /** Returns the given element as ArrayNode (cast). */
// public static ArrayNode array(JsonNode node) {
// return node != null ? (ArrayNode)node : null;
// }
//
//
// /** Returns the field from a ObjectNode as ArrayNode */
// public static ArrayNode getArray(ObjectNode obj, String fieldName) {
// return obj == null ? null : array(obj.get(fieldName));
// }
//
//
// /** Removes the field from a ObjectNode and returns it as ArrayNode */
// public static ArrayNode getArrayAndRemove(ObjectNode obj, String fieldName) {
// ArrayNode result = null;
// if (obj != null) {
// result = array(remove(obj, fieldName));
// }
// return result;
// }
//
//
// /** Removes the field with the given name from the given ObjectNode */
// public static JsonNode remove(ObjectNode obj, String fieldName) {
// JsonNode result = null;
// if (obj != null) {
// result = obj.remove(fieldName);
// }
// return result;
// }
//
//
// /** Renames a field in a ObjectNode from the oldFieldName to the newFieldName */
// public static void rename(ObjectNode obj, String oldFieldName, String newFieldName) {
// if (obj != null && isNotBlank(oldFieldName) && isNotBlank(newFieldName)) {
// JsonNode node = remove(obj, oldFieldName);
// if (node != null) {
// obj.set(newFieldName, node);
// }
// }
// }
//
// }
// Path: src/test/java/de/galan/verjson/util/TransformationsTest.java
import static de.galan.verjson.util.Transformations.*;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.galan.commons.test.AbstractTestParent;
rename(null, "x", "x");
}
@Test
public void renameNothing() throws Exception {
ObjectNode obj = createObj().put("a", "b").get();
rename(obj, null, null);
rename(obj, "", null);
rename(obj, null, "");
rename(obj, "", "");
rename(obj, "x", null);
rename(obj, "", "a");
rename(obj, "x", "x");
assertThat(obj.get("a").asText()).isEqualTo("b");
assertThat(obj.size()).isEqualTo(1);
}
@Test
public void testRename() throws Exception {
ObjectNode obj = createObj().put("a", "b").get();
rename(obj, "a", "y");
assertThat(obj.get("y").asText()).isEqualTo("b");
assertThat(obj.size()).isEqualTo(1);
}
@Test
public void create() {
|
new Transformations(); // code-coverage
|
galan/verjson
|
src/test/java/de/galan/verjson/samples/v3/Example3Versions.java
|
// Path: src/main/java/de/galan/verjson/core/Versions.java
// public class Versions {
//
// private ListMultimap<Long, Step> steps;
// private String namespace;
// private Map<Class<?>, JsonSerializer<?>> serializers;
// private Map<Class<?>, JsonDeserializer<?>> deserializers;
// private SetMultimap<Class<?>, Pair<Class<?>, String>> polys;
// private boolean includeTimestamp;
//
//
// public Versions() {
// this(null);
// }
//
//
// public Versions(String namespace) {
// setNamespace(namespace);
// steps = ArrayListMultimap.create();
// serializers = Maps.newHashMap();
// deserializers = Maps.newHashMap();
// polys = HashMultimap.create();
// includeTimestamp = true;
// }
//
//
// public void setNamespace(String namespace) {
// this.namespace = namespace;
// }
//
//
// public String getNamespace() {
// return namespace;
// }
//
//
// public void configure() {
// // can be overriden
// }
//
//
// public ListMultimap<Long, Step> getSteps() {
// return steps;
// }
//
//
// public Versions add(Long sourceVersion, Step step) {
// if (step != null) {
// getSteps().put(sourceVersion, step);
// }
// return this;
// }
//
//
// public <T> void registerSubclass(Class<T> parentClass, Class<? extends T> childClass, String typeName) {
// getRegisteredSubclasses().put(parentClass, new Pair<Class<?>, String>(childClass, typeName));
// }
//
//
// public SetMultimap<Class<?>, Pair<Class<?>, String>> getRegisteredSubclasses() {
// return polys;
// }
//
//
// public <T> Versions registerSerializer(JsonSerializer<T> serializer) {
// if (serializer != null) {
// serializers.put(serializer.getClass(), serializer);
// }
// return this;
// }
//
//
// public <T> Versions registerDeserializer(JsonDeserializer<T> deserializer) {
// if (deserializer != null) {
// deserializers.put(deserializer.getClass(), deserializer);
// }
// return this;
// }
//
//
// public Collection<JsonSerializer<?>> getSerializer() {
// return serializers.values();
// }
//
//
// public Collection<JsonDeserializer<?>> getDeserializer() {
// return deserializers.values();
// }
//
//
// public boolean isIncludeTimestamp() {
// return includeTimestamp;
// }
//
//
// /** A timestamp is added to the meta-data, this can be avoided by setting this property to false */
// public void setIncludeTimestamp(boolean includeTimestamp) {
// this.includeTimestamp = includeTimestamp;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/samples/v2/Example2Transformation.java
// public class Example2Transformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// ObjectNode obj = obj(node);
// // remove first
// remove(obj, "first");
// // rename second
// rename(obj, "second", "segundo");
// // keep third and fourth
// // convert fifth
// ArrayNode fifth = getArrayAndRemove(obj, "fifth");
// if (fifth != null) {
// StringBuilder builder = new StringBuilder();
// for (JsonNode elem: fifth) {
// builder.append(elem.asText());
// }
// obj.put("fifth", builder.toString());
// }
// // convert sixth
// ObjectNode sixth = getObjAndRemove(obj, "sixth");
// rename(sixth, "one", "uno");
// remove(sixth, "two");
// // rename SubB
// rename(obj(obj.get("subB")), "bbb", "ccc");
// obj.set("sixth", createArray(sixth));
// }
//
// }
|
import de.galan.verjson.core.Versions;
import de.galan.verjson.samples.v2.Example2Transformation;
|
package de.galan.verjson.samples.v3;
/**
* Versions for third version
*
* @author daniel
*/
public class Example3Versions extends Versions {
@Override
public void configure() {
registerSubclass(Example3Sub.class, Example3SubA.class, "suba");
registerSubclass(Example3Sub.class, Example3SubB.class, "subb");
|
// Path: src/main/java/de/galan/verjson/core/Versions.java
// public class Versions {
//
// private ListMultimap<Long, Step> steps;
// private String namespace;
// private Map<Class<?>, JsonSerializer<?>> serializers;
// private Map<Class<?>, JsonDeserializer<?>> deserializers;
// private SetMultimap<Class<?>, Pair<Class<?>, String>> polys;
// private boolean includeTimestamp;
//
//
// public Versions() {
// this(null);
// }
//
//
// public Versions(String namespace) {
// setNamespace(namespace);
// steps = ArrayListMultimap.create();
// serializers = Maps.newHashMap();
// deserializers = Maps.newHashMap();
// polys = HashMultimap.create();
// includeTimestamp = true;
// }
//
//
// public void setNamespace(String namespace) {
// this.namespace = namespace;
// }
//
//
// public String getNamespace() {
// return namespace;
// }
//
//
// public void configure() {
// // can be overriden
// }
//
//
// public ListMultimap<Long, Step> getSteps() {
// return steps;
// }
//
//
// public Versions add(Long sourceVersion, Step step) {
// if (step != null) {
// getSteps().put(sourceVersion, step);
// }
// return this;
// }
//
//
// public <T> void registerSubclass(Class<T> parentClass, Class<? extends T> childClass, String typeName) {
// getRegisteredSubclasses().put(parentClass, new Pair<Class<?>, String>(childClass, typeName));
// }
//
//
// public SetMultimap<Class<?>, Pair<Class<?>, String>> getRegisteredSubclasses() {
// return polys;
// }
//
//
// public <T> Versions registerSerializer(JsonSerializer<T> serializer) {
// if (serializer != null) {
// serializers.put(serializer.getClass(), serializer);
// }
// return this;
// }
//
//
// public <T> Versions registerDeserializer(JsonDeserializer<T> deserializer) {
// if (deserializer != null) {
// deserializers.put(deserializer.getClass(), deserializer);
// }
// return this;
// }
//
//
// public Collection<JsonSerializer<?>> getSerializer() {
// return serializers.values();
// }
//
//
// public Collection<JsonDeserializer<?>> getDeserializer() {
// return deserializers.values();
// }
//
//
// public boolean isIncludeTimestamp() {
// return includeTimestamp;
// }
//
//
// /** A timestamp is added to the meta-data, this can be avoided by setting this property to false */
// public void setIncludeTimestamp(boolean includeTimestamp) {
// this.includeTimestamp = includeTimestamp;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/samples/v2/Example2Transformation.java
// public class Example2Transformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// ObjectNode obj = obj(node);
// // remove first
// remove(obj, "first");
// // rename second
// rename(obj, "second", "segundo");
// // keep third and fourth
// // convert fifth
// ArrayNode fifth = getArrayAndRemove(obj, "fifth");
// if (fifth != null) {
// StringBuilder builder = new StringBuilder();
// for (JsonNode elem: fifth) {
// builder.append(elem.asText());
// }
// obj.put("fifth", builder.toString());
// }
// // convert sixth
// ObjectNode sixth = getObjAndRemove(obj, "sixth");
// rename(sixth, "one", "uno");
// remove(sixth, "two");
// // rename SubB
// rename(obj(obj.get("subB")), "bbb", "ccc");
// obj.set("sixth", createArray(sixth));
// }
//
// }
// Path: src/test/java/de/galan/verjson/samples/v3/Example3Versions.java
import de.galan.verjson.core.Versions;
import de.galan.verjson.samples.v2.Example2Transformation;
package de.galan.verjson.samples.v3;
/**
* Versions for third version
*
* @author daniel
*/
public class Example3Versions extends Versions {
@Override
public void configure() {
registerSubclass(Example3Sub.class, Example3SubA.class, "suba");
registerSubclass(Example3Sub.class, Example3SubB.class, "subb");
|
add(1L, new Example2Transformation());
|
galan/verjson
|
src/test/java/de/galan/verjson/core/StepSequencerTest.java
|
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Map;
import org.junit.Test;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
|
package de.galan.verjson.core;
/**
* CUT StepSequencer
*
* @author daniel
*/
public class StepSequencerTest extends AbstractStepSequencerParent {
@Test
public void empty() throws Exception {
|
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
// Path: src/test/java/de/galan/verjson/core/StepSequencerTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Map;
import org.junit.Test;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
package de.galan.verjson.core;
/**
* CUT StepSequencer
*
* @author daniel
*/
public class StepSequencerTest extends AbstractStepSequencerParent {
@Test
public void empty() throws Exception {
|
ListMultimap<Long, Step> input = ArrayListMultimap.create();
|
galan/verjson
|
src/test/java/de/galan/verjson/core/StepSequencerTest.java
|
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Map;
import org.junit.Test;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
|
package de.galan.verjson.core;
/**
* CUT StepSequencer
*
* @author daniel
*/
public class StepSequencerTest extends AbstractStepSequencerParent {
@Test
public void empty() throws Exception {
ListMultimap<Long, Step> input = ArrayListMultimap.create();
Map<Long, ProxyStep> output = ss.sequence(input);
assertThat(output).hasSize(1);
|
// Path: src/main/java/de/galan/verjson/step/NoopStep.java
// public class NoopStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
// Path: src/test/java/de/galan/verjson/core/StepSequencerTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Map;
import org.junit.Test;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import de.galan.verjson.step.NoopStep;
import de.galan.verjson.step.Step;
package de.galan.verjson.core;
/**
* CUT StepSequencer
*
* @author daniel
*/
public class StepSequencerTest extends AbstractStepSequencerParent {
@Test
public void empty() throws Exception {
ListMultimap<Long, Step> input = ArrayListMultimap.create();
Map<Long, ProxyStep> output = ss.sequence(input);
assertThat(output).hasSize(1);
|
assertThat(output.get(1L).getStep().getClass()).isEqualTo(NoopStep.class);
|
galan/verjson
|
src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
|
Validation validation;
|
galan/verjson
|
src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
|
Transformation transformation;
|
galan/verjson
|
src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
|
OtherStep other;
|
galan/verjson
|
src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
OtherStep other;
@Before
public void before() {
psc = new ProxyStepComparator();
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
OtherStep other;
@Before
public void before() {
psc = new ProxyStepComparator();
|
validation = new DummyValidation(null);
|
galan/verjson
|
src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
|
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
|
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
OtherStep other;
@Before
public void before() {
psc = new ProxyStepComparator();
validation = new DummyValidation(null);
|
// Path: src/test/java/de/galan/verjson/DummyTransformation.java
// public class DummyTransformation extends Transformation {
//
// @Override
// protected void transform(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/DummyValidation.java
// public class DummyValidation extends Validation {
//
// public DummyValidation(String schema, String description) {
// super(schema, description);
// }
//
//
// public DummyValidation(String schema) {
// super(schema);
// }
//
//
// @Override
// public void process(JsonNode node) {
// // nothing
// }
//
//
// @Override
// public JsonSchema create(String schemaString) {
// return null;
// }
//
// }
//
// Path: src/test/java/de/galan/verjson/OtherStep.java
// public class OtherStep implements Step {
//
// @Override
// public void process(JsonNode node) {
// //nada
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/step/transformation/Transformation.java
// public abstract class Transformation implements Step {
//
// @Override
// public void process(JsonNode node) {
// transform(MetaWrapper.getData(node));
// }
//
//
// /** Transformation instructions to migrate to the next version */
// protected abstract void transform(JsonNode node);
//
// }
//
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
// public class Validation implements Step {
//
// protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
//
// String description;
// JsonSchema schema; // thread-safe
// static JsonSchemaFactory factory; // cached
//
//
// public Validation(String schema) {
// this(schema, null);
// }
//
//
// public Validation(String schema, String description) {
// this.description = description;
// this.schema = create(schema);
// }
//
//
// public String getDescription() {
// return description;
// }
//
//
// protected String getDescriptionAppendable() {
// return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
// }
//
//
// protected static synchronized JsonSchemaFactory getFactory() {
// if (factory == null) {
// factory = JsonSchemaFactory.byDefault();
// }
// return factory;
// }
//
//
// protected JsonSchemaFactory getJsonSchemaFactory() {
// return getFactory();
// }
//
//
// @Override
// public void process(JsonNode node) throws ProcessStepException {
// validate(MetaWrapper.getData(node));
// }
//
//
// protected JsonSchema getSchema() {
// return schema;
// }
//
//
// public void validate(JsonNode node) throws InvalidJsonException {
// ProcessingReport report = null;
// try {
// report = getSchema().validate(node);
// }
// catch (Throwable ex) {
// throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
// }
// if (!report.isSuccess()) {
//
// StringBuilder builder = new StringBuilder();
// builder.append("Could not validate JSON against schema");
// builder.append(getDescriptionAppendable());
// builder.append(":");
// builder.append(LS);
// List<ProcessingMessage> messages = Lists.newArrayList(report);
// for (int i = 0; i < messages.size(); i++) {
// builder.append("- ");
// builder.append(messages.get(i).getMessage());
// builder.append(i == (messages.size() - 1) ? EMPTY : LS);
// }
// throw new InvalidJsonException(builder.toString());
// }
// }
//
//
// public JsonSchema create(String schemaString) {
// JsonSchema jsonSchema = null;
// try {
// JsonNode schemaNode = JsonLoader.fromString(schemaString);
// if (!getJsonSchemaFactory().getSyntaxValidator().schemaIsValid(schemaNode)) {
// throw new InvalidSchemaException("JSON Schema is invalid" + getDescriptionAppendable());
// }
// jsonSchema = getJsonSchemaFactory().getJsonSchema(schemaNode);
// }
// catch (NullPointerException | IOException | ProcessingException ex) {
// throw new InvalidSchemaException("JSON Schema could not be loaded" + getDescriptionAppendable(), ex);
// }
// return jsonSchema;
// }
//
// }
// Path: src/test/java/de/galan/verjson/core/ProxyStepComparatorTest.java
import static org.assertj.core.api.Assertions.*;
import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists;
import org.junit.Before;
import org.junit.Test;
import de.galan.commons.test.AbstractTestParent;
import de.galan.verjson.DummyTransformation;
import de.galan.verjson.DummyValidation;
import de.galan.verjson.OtherStep;
import de.galan.verjson.step.Step;
import de.galan.verjson.step.transformation.Transformation;
import de.galan.verjson.step.validation.Validation;
package de.galan.verjson.core;
/**
* CUT ProxyStepComparator
*
* @author daniel
*/
public class ProxyStepComparatorTest extends AbstractTestParent {
ProxyStepComparator psc;
Validation validation;
Transformation transformation;
OtherStep other;
@Before
public void before() {
psc = new ProxyStepComparator();
validation = new DummyValidation(null);
|
transformation = new DummyTransformation();
|
galan/verjson
|
src/main/java/de/galan/verjson/step/validation/Validation.java
|
// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
//
// public ProcessStepException(String message) {
// super(message);
// }
//
//
// public ProcessStepException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
|
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
|
package de.galan.verjson.step.validation;
/**
* Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
*
* @author daniel
*/
public class Validation implements Step {
protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
String description;
JsonSchema schema; // thread-safe
static JsonSchemaFactory factory; // cached
public Validation(String schema) {
this(schema, null);
}
public Validation(String schema, String description) {
this.description = description;
this.schema = create(schema);
}
public String getDescription() {
return description;
}
protected String getDescriptionAppendable() {
return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
}
protected static synchronized JsonSchemaFactory getFactory() {
if (factory == null) {
factory = JsonSchemaFactory.byDefault();
}
return factory;
}
protected JsonSchemaFactory getJsonSchemaFactory() {
return getFactory();
}
@Override
|
// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
//
// public ProcessStepException(String message) {
// super(message);
// }
//
//
// public ProcessStepException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
package de.galan.verjson.step.validation;
/**
* Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
*
* @author daniel
*/
public class Validation implements Step {
protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
String description;
JsonSchema schema; // thread-safe
static JsonSchemaFactory factory; // cached
public Validation(String schema) {
this(schema, null);
}
public Validation(String schema, String description) {
this.description = description;
this.schema = create(schema);
}
public String getDescription() {
return description;
}
protected String getDescriptionAppendable() {
return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
}
protected static synchronized JsonSchemaFactory getFactory() {
if (factory == null) {
factory = JsonSchemaFactory.byDefault();
}
return factory;
}
protected JsonSchemaFactory getJsonSchemaFactory() {
return getFactory();
}
@Override
|
public void process(JsonNode node) throws ProcessStepException {
|
galan/verjson
|
src/main/java/de/galan/verjson/step/validation/Validation.java
|
// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
//
// public ProcessStepException(String message) {
// super(message);
// }
//
//
// public ProcessStepException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
|
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
|
package de.galan.verjson.step.validation;
/**
* Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
*
* @author daniel
*/
public class Validation implements Step {
protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
String description;
JsonSchema schema; // thread-safe
static JsonSchemaFactory factory; // cached
public Validation(String schema) {
this(schema, null);
}
public Validation(String schema, String description) {
this.description = description;
this.schema = create(schema);
}
public String getDescription() {
return description;
}
protected String getDescriptionAppendable() {
return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
}
protected static synchronized JsonSchemaFactory getFactory() {
if (factory == null) {
factory = JsonSchemaFactory.byDefault();
}
return factory;
}
protected JsonSchemaFactory getJsonSchemaFactory() {
return getFactory();
}
@Override
public void process(JsonNode node) throws ProcessStepException {
|
// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
//
// public ProcessStepException(String message) {
// super(message);
// }
//
//
// public ProcessStepException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
//
// /** Perform action on wrapped root node */
// public void process(JsonNode node) throws ProcessStepException;
//
// }
//
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
//
// public static final String ID_VERSION = "$v";
// public static final String ID_NAMESPACE = "$ns";
// public static final String ID_DATA = "$d";
// public static final String ID_TIMESTAMP = "$ts";
//
// /** Incremental version */
// @JsonProperty(ID_VERSION)
// private long version;
//
// /** Namespace for the data object */
// @JsonProperty(ID_NAMESPACE)
// private String namespace;
//
// /** Timestamp when the object was serialized */
// @JsonProperty(ID_TIMESTAMP)
// private Date timestamp;
//
// /** Actual payload */
// @JsonProperty(ID_DATA)
// private Object data;
//
//
// public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// this.version = version;
// this.namespace = namespace;
// this.data = data;
// this.timestamp = timestamp;
// }
//
//
// /** Returns the data node from a wrapped JsonNode */
// public static JsonNode getData(JsonNode node) {
// return getObj(obj(node), MetaWrapper.ID_DATA);
// }
//
//
// /** Returns the namespace from a wrapped JsonNode */
// public static String getNamespace(JsonNode node) {
// JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// return (nodeNs != null) ? nodeNs.asText() : null;
// }
//
//
// /** Returns the source version from a wrapped JsonNode */
// public static Long getVersion(JsonNode node) {
// return obj(node).get(ID_VERSION).asLong();
// }
//
//
// /** Sets the version on a wrapped JsonNode */
// public static void setVersion(JsonNode node, Long version) {
// obj(node).put(ID_VERSION, version);
// }
//
//
// /** Returns the timestamp from a wrapped JsonNode */
// public static Date getTimestamp(JsonNode node) {
// String text = obj(node).get(ID_TIMESTAMP).asText();
// return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// }
//
// }
// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
package de.galan.verjson.step.validation;
/**
* Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
*
* @author daniel
*/
public class Validation implements Step {
protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();
String description;
JsonSchema schema; // thread-safe
static JsonSchemaFactory factory; // cached
public Validation(String schema) {
this(schema, null);
}
public Validation(String schema, String description) {
this.description = description;
this.schema = create(schema);
}
public String getDescription() {
return description;
}
protected String getDescriptionAppendable() {
return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
}
protected static synchronized JsonSchemaFactory getFactory() {
if (factory == null) {
factory = JsonSchemaFactory.byDefault();
}
return factory;
}
protected JsonSchemaFactory getJsonSchemaFactory() {
return getFactory();
}
@Override
public void process(JsonNode node) throws ProcessStepException {
|
validate(MetaWrapper.getData(node));
|
MineMaarten/IGW-mod
|
src/igwmod/IGWMod.java
|
// Path: src/igwmod/lib/Constants.java
// public class Constants{
// public static final String MOD_ID = "igwmod";
// private static final String MASSIVE = "@MASSIVE@";
// private static final String MAJOR = "@MAJOR@";
// private static final String MINOR = "@MINOR@";
// private static final String BUILD = "@BUILD_NUMBER@";
// private static final String MC_VERSION = "@MC_VERSION@";
// // public static final String WIKI_PAGE_LOCATION = "https://github.com/MineMaarten/IGW-mod/archive/master.zip";// "http://www.minemaarten.com/wp-content/uploads/2013/12/WikiPages.zip";
// // public static final String ZIP_NAME = "igw";
// // public static final int CONNECTION_TIMEOUT = 3000;
// // public static final int READ_TIMEOUT = 5000;
// // public static final String INTERNET_UPDATE_CONFIG_KEY = "Update pages via internet";
// // public static final String USE_OFFLINE_WIKIPAGES_KEY = "Use offline wikipages";
// public static final int DEFAULT_KEYBIND_OPEN_GUI = Keyboard.KEY_I;
//
// public static final int TEXTURE_MAP_ID = 15595;
//
// public static String fullVersionString(){
//
// return String.format("%s-%s.%s.%s-%s", MC_VERSION, MASSIVE, MAJOR, MINOR, BUILD);
// }
// }
//
// Path: src/igwmod/network/NetworkHandler.java
// public class NetworkHandler{
//
// public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_ID);
// private static int discriminant;
//
// /*
// * The integer is the ID of the message, the Side is the side this message will be handled (received) on!
// */
// public static void init(){
//
// INSTANCE.registerMessage(MessageSendServerTab.class, MessageSendServerTab.class, discriminant++, Side.CLIENT);
// INSTANCE.registerMessage(MessageMultiHeader.class, MessageMultiHeader.class, discriminant++, Side.CLIENT);
// INSTANCE.registerMessage(MessageMultiPart.class, MessageMultiPart.class, discriminant++, Side.CLIENT);
// }
//
// /*
// * public static void INSTANCE.registerMessage(Class<? extends AbstractPacket<? extends IMessage>> clazz){ INSTANCE.registerMessage(clazz, clazz,
// * discriminant++, Side.SERVER, discriminant++, Side.SERVER); }
// */
//
// public static void sendToAll(IMessage message){
//
// INSTANCE.sendToAll(message);
// }
//
// public static void sendTo(IMessage message, EntityPlayerMP player){
// List<IMessage> messages = getSplitMessages(message);
// for(IMessage m : messages) {
// INSTANCE.sendTo(m, player);
// }
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationIntPacket message, World world, double distance){
//
// sendToAllAround(message, message.getTargetPoint(world, distance));
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationIntPacket message, World world){
//
// sendToAllAround(message, message.getTargetPoint(world));
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationDoublePacket message, World world){
//
// sendToAllAround(message, message.getTargetPoint(world));
// }
//
// public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point){
//
// INSTANCE.sendToAllAround(message, point);
// }
//
// public static void sendToDimension(IMessage message, int dimensionId){
//
// INSTANCE.sendToDimension(message, dimensionId);
// }
//
// public static void sendToServer(IMessage message){
//
// INSTANCE.sendToServer(message);
// }
//
// public static final int MAX_SIZE = 65530;
//
// private static List<IMessage> getSplitMessages(IMessage message){
// List<IMessage> messages = new ArrayList<IMessage>();
// ByteBuf buf = Unpooled.buffer();
// message.toBytes(buf);
// byte[] bytes = buf.array();
// if(bytes.length < MAX_SIZE) {
// messages.add(message);
// } else {
// messages.add(new MessageMultiHeader(bytes.length));
// int offset = 0;
// while(offset < bytes.length) {
// messages.add(new MessageMultiPart(Arrays.copyOfRange(bytes, offset, Math.min(offset + MAX_SIZE, bytes.length))));
// offset += MAX_SIZE;
// }
// }
// return messages;
// }
// }
|
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import igwmod.lib.Constants;
import igwmod.network.NetworkHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkCheckHandler;
import net.minecraftforge.fml.relauncher.Side;
|
textList.add(line);
line = br.readLine();
}
br.close();
if(textList != null) {
for(String s : textList) {
String[] entry = s.split("=");
if(entry[0].equals("optional")) {
if(Boolean.parseBoolean(entry[1])) return true;
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
String version = installedMods.get(Constants.MOD_ID);
if(version.equals("${version}")) return true;
return version != null && version.equals(Constants.fullVersionString());
} else {
return true;
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event){
event.getModMetadata().version = Constants.fullVersionString();
proxy.preInit(event);
|
// Path: src/igwmod/lib/Constants.java
// public class Constants{
// public static final String MOD_ID = "igwmod";
// private static final String MASSIVE = "@MASSIVE@";
// private static final String MAJOR = "@MAJOR@";
// private static final String MINOR = "@MINOR@";
// private static final String BUILD = "@BUILD_NUMBER@";
// private static final String MC_VERSION = "@MC_VERSION@";
// // public static final String WIKI_PAGE_LOCATION = "https://github.com/MineMaarten/IGW-mod/archive/master.zip";// "http://www.minemaarten.com/wp-content/uploads/2013/12/WikiPages.zip";
// // public static final String ZIP_NAME = "igw";
// // public static final int CONNECTION_TIMEOUT = 3000;
// // public static final int READ_TIMEOUT = 5000;
// // public static final String INTERNET_UPDATE_CONFIG_KEY = "Update pages via internet";
// // public static final String USE_OFFLINE_WIKIPAGES_KEY = "Use offline wikipages";
// public static final int DEFAULT_KEYBIND_OPEN_GUI = Keyboard.KEY_I;
//
// public static final int TEXTURE_MAP_ID = 15595;
//
// public static String fullVersionString(){
//
// return String.format("%s-%s.%s.%s-%s", MC_VERSION, MASSIVE, MAJOR, MINOR, BUILD);
// }
// }
//
// Path: src/igwmod/network/NetworkHandler.java
// public class NetworkHandler{
//
// public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_ID);
// private static int discriminant;
//
// /*
// * The integer is the ID of the message, the Side is the side this message will be handled (received) on!
// */
// public static void init(){
//
// INSTANCE.registerMessage(MessageSendServerTab.class, MessageSendServerTab.class, discriminant++, Side.CLIENT);
// INSTANCE.registerMessage(MessageMultiHeader.class, MessageMultiHeader.class, discriminant++, Side.CLIENT);
// INSTANCE.registerMessage(MessageMultiPart.class, MessageMultiPart.class, discriminant++, Side.CLIENT);
// }
//
// /*
// * public static void INSTANCE.registerMessage(Class<? extends AbstractPacket<? extends IMessage>> clazz){ INSTANCE.registerMessage(clazz, clazz,
// * discriminant++, Side.SERVER, discriminant++, Side.SERVER); }
// */
//
// public static void sendToAll(IMessage message){
//
// INSTANCE.sendToAll(message);
// }
//
// public static void sendTo(IMessage message, EntityPlayerMP player){
// List<IMessage> messages = getSplitMessages(message);
// for(IMessage m : messages) {
// INSTANCE.sendTo(m, player);
// }
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationIntPacket message, World world, double distance){
//
// sendToAllAround(message, message.getTargetPoint(world, distance));
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationIntPacket message, World world){
//
// sendToAllAround(message, message.getTargetPoint(world));
// }
//
// @SuppressWarnings("rawtypes")
// public static void sendToAllAround(LocationDoublePacket message, World world){
//
// sendToAllAround(message, message.getTargetPoint(world));
// }
//
// public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point){
//
// INSTANCE.sendToAllAround(message, point);
// }
//
// public static void sendToDimension(IMessage message, int dimensionId){
//
// INSTANCE.sendToDimension(message, dimensionId);
// }
//
// public static void sendToServer(IMessage message){
//
// INSTANCE.sendToServer(message);
// }
//
// public static final int MAX_SIZE = 65530;
//
// private static List<IMessage> getSplitMessages(IMessage message){
// List<IMessage> messages = new ArrayList<IMessage>();
// ByteBuf buf = Unpooled.buffer();
// message.toBytes(buf);
// byte[] bytes = buf.array();
// if(bytes.length < MAX_SIZE) {
// messages.add(message);
// } else {
// messages.add(new MessageMultiHeader(bytes.length));
// int offset = 0;
// while(offset < bytes.length) {
// messages.add(new MessageMultiPart(Arrays.copyOfRange(bytes, offset, Math.min(offset + MAX_SIZE, bytes.length))));
// offset += MAX_SIZE;
// }
// }
// return messages;
// }
// }
// Path: src/igwmod/IGWMod.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import igwmod.lib.Constants;
import igwmod.network.NetworkHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkCheckHandler;
import net.minecraftforge.fml.relauncher.Side;
textList.add(line);
line = br.readLine();
}
br.close();
if(textList != null) {
for(String s : textList) {
String[] entry = s.split("=");
if(entry[0].equals("optional")) {
if(Boolean.parseBoolean(entry[1])) return true;
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
String version = installedMods.get(Constants.MOD_ID);
if(version.equals("${version}")) return true;
return version != null && version.equals(Constants.fullVersionString());
} else {
return true;
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event){
event.getModMetadata().version = Constants.fullVersionString();
proxy.preInit(event);
|
NetworkHandler.init();
|
MineMaarten/IGW-mod
|
src/igwmod/gui/BrowseHistory.java
|
// Path: src/igwmod/gui/tabs/IWikiTab.java
// public interface IWikiTab{
// /**
// * The returned string will be displayed on the tooltip when you hover over the tab.
// * @return
// */
// public String getName();
//
// /**
// * Will be called by the GUI to render the tab. The render matrix will already be translated dependant on where this tab is.
// * @return When you return an ItemStack, this stack will be drawn rotating. Returning ItemStack.EMPTY is valid, nothing will be drawn (you will).
// */
// public ItemStack renderTabIcon(GuiWiki gui);
//
// /**
// * With this you can specify which spaces in the wikipage are prohibited for text to occur. This method is also used to add standard widgets,
// * like images that need to exist on every wikipage of this tab. Just add a {@link LocatedTexture} to this list and it will be rendered.
// * @return
// */
// public List<IReservedSpace> getReservedSpaces();
//
// /**
// * In here you should return the full list of pages. This will also define how people will be able to navigate through pages on this tab.
// * The most simplest way is to use {@link LinkedLocatedString}.
// * @param pageIndexes : This array will be null when every existing page is requested (used for search queries). When specific pages are
// * requested (as a result of a search query), this array will contain the indexes it wants of the list returner earlier. Return a list
// * with only the elements of the indexes given. This way, you can decide where you want to put pagelinks (spacings, only vertical or in pairs
// * of two) however you want. You're in charge on the location of each of the elements.
// * @return
// */
// public List<IPageLink> getPages(int[] pageIndexes);
//
// /**
// * The value returned defines how high the textfield will appear. On a basic page this is on the top of the screen, on the item/block & entity
// * page this is somewhere in the middle.
// * @return
// */
// public int getSearchBarAndScrollStartY();
//
// /**
// * Return the amount of page links that fit on one page (it will allow scrolling if there are more pages than that).
// * @return
// */
// public int pagesPerTab();
//
// /**
// * How many elements (page links) are being scrolled per scroll. This is usually 1, but for the Item/Blocks tab this is 2 (to move two items at once per scroll).
// * @return
// */
// public int pagesPerScroll();
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// */
// public void renderForeground(GuiWiki gui, int mouseX, int mouseY);
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// */
// public void renderBackground(GuiWiki gui, int mouseX, int mouseY);
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// * @param mouseKey
// */
// public void onMouseClick(GuiWiki gui, int mouseX, int mouseY, int mouseKey);
//
// /**
// * Called when navigated to a page of this tab. pageName is the actual path of the .txt file. metadata can be empty, or containing an itemstack or Class<? extends Entity>
// * @param gui
// * @param pageName
// * @param metadata
// */
// public void onPageChange(GuiWiki gui, String pageName, Object... metadata);
//
// }
|
import java.util.ArrayList;
import java.util.List;
import igwmod.gui.tabs.IWikiTab;
|
package igwmod.gui;
public class BrowseHistory{
public final String link;
|
// Path: src/igwmod/gui/tabs/IWikiTab.java
// public interface IWikiTab{
// /**
// * The returned string will be displayed on the tooltip when you hover over the tab.
// * @return
// */
// public String getName();
//
// /**
// * Will be called by the GUI to render the tab. The render matrix will already be translated dependant on where this tab is.
// * @return When you return an ItemStack, this stack will be drawn rotating. Returning ItemStack.EMPTY is valid, nothing will be drawn (you will).
// */
// public ItemStack renderTabIcon(GuiWiki gui);
//
// /**
// * With this you can specify which spaces in the wikipage are prohibited for text to occur. This method is also used to add standard widgets,
// * like images that need to exist on every wikipage of this tab. Just add a {@link LocatedTexture} to this list and it will be rendered.
// * @return
// */
// public List<IReservedSpace> getReservedSpaces();
//
// /**
// * In here you should return the full list of pages. This will also define how people will be able to navigate through pages on this tab.
// * The most simplest way is to use {@link LinkedLocatedString}.
// * @param pageIndexes : This array will be null when every existing page is requested (used for search queries). When specific pages are
// * requested (as a result of a search query), this array will contain the indexes it wants of the list returner earlier. Return a list
// * with only the elements of the indexes given. This way, you can decide where you want to put pagelinks (spacings, only vertical or in pairs
// * of two) however you want. You're in charge on the location of each of the elements.
// * @return
// */
// public List<IPageLink> getPages(int[] pageIndexes);
//
// /**
// * The value returned defines how high the textfield will appear. On a basic page this is on the top of the screen, on the item/block & entity
// * page this is somewhere in the middle.
// * @return
// */
// public int getSearchBarAndScrollStartY();
//
// /**
// * Return the amount of page links that fit on one page (it will allow scrolling if there are more pages than that).
// * @return
// */
// public int pagesPerTab();
//
// /**
// * How many elements (page links) are being scrolled per scroll. This is usually 1, but for the Item/Blocks tab this is 2 (to move two items at once per scroll).
// * @return
// */
// public int pagesPerScroll();
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// */
// public void renderForeground(GuiWiki gui, int mouseX, int mouseY);
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// */
// public void renderBackground(GuiWiki gui, int mouseX, int mouseY);
//
// /**
// *
// * @param gui
// * @param mouseX
// * @param mouseY
// * @param mouseKey
// */
// public void onMouseClick(GuiWiki gui, int mouseX, int mouseY, int mouseKey);
//
// /**
// * Called when navigated to a page of this tab. pageName is the actual path of the .txt file. metadata can be empty, or containing an itemstack or Class<? extends Entity>
// * @param gui
// * @param pageName
// * @param metadata
// */
// public void onPageChange(GuiWiki gui, String pageName, Object... metadata);
//
// }
// Path: src/igwmod/gui/BrowseHistory.java
import java.util.ArrayList;
import java.util.List;
import igwmod.gui.tabs.IWikiTab;
package igwmod.gui;
public class BrowseHistory{
public final String link;
|
public final IWikiTab tab;
|
MineMaarten/IGW-mod
|
src/igwmod/network/AbstractPacket.java
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
|
import igwmod.IGWMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
|
package igwmod.network;
/**
*
* @author MineMaarten
*/
public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>{
@Override
public REQ onMessage(REQ message, MessageContext ctx){
if(ctx.side == Side.SERVER) {
handleServerSide(message, ctx.getServerHandler().player);
} else {
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
// Path: src/igwmod/network/AbstractPacket.java
import igwmod.IGWMod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
package igwmod.network;
/**
*
* @author MineMaarten
*/
public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ>{
@Override
public REQ onMessage(REQ message, MessageContext ctx){
if(ctx.side == Side.SERVER) {
handleServerSide(message, ctx.getServerHandler().player);
} else {
|
handleClientSide(message, IGWMod.proxy.getPlayer());
|
MineMaarten/IGW-mod
|
src/igwmod/gui/LocatedTexture.java
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
//
// Path: src/igwmod/TessWrapper.java
// public class TessWrapper{
// public static void startDrawingTexturedQuads(){
// Tessellator.getInstance().getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX);
// }
//
// public static void addVertexWithUV(double x, double y, double z, double u, double v){
// Tessellator.getInstance().getBuffer().pos(x, y, z).tex(u, v).endVertex();
// }
//
// public static void draw(){
// Tessellator.getInstance().draw();
// }
// }
|
import igwmod.IGWMod;
import igwmod.TessWrapper;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
|
package igwmod.gui;
public class LocatedTexture implements IReservedSpace, IWidget{
public ResourceLocation texture;
public int x, y, width, height;
private int textureId;
public LocatedTexture(ResourceLocation texture, int x, int y, int width, int height){
this.texture = texture;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
if(texture.getResourcePath().startsWith("server")) {
try {
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
//
// Path: src/igwmod/TessWrapper.java
// public class TessWrapper{
// public static void startDrawingTexturedQuads(){
// Tessellator.getInstance().getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX);
// }
//
// public static void addVertexWithUV(double x, double y, double z, double u, double v){
// Tessellator.getInstance().getBuffer().pos(x, y, z).tex(u, v).endVertex();
// }
//
// public static void draw(){
// Tessellator.getInstance().draw();
// }
// }
// Path: src/igwmod/gui/LocatedTexture.java
import igwmod.IGWMod;
import igwmod.TessWrapper;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
package igwmod.gui;
public class LocatedTexture implements IReservedSpace, IWidget{
public ResourceLocation texture;
public int x, y, width, height;
private int textureId;
public LocatedTexture(ResourceLocation texture, int x, int y, int width, int height){
this.texture = texture;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
if(texture.getResourcePath().startsWith("server")) {
try {
|
BufferedImage image = ImageIO.read(new FileInputStream(new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + texture.getResourcePath().substring(7))));
|
MineMaarten/IGW-mod
|
src/igwmod/gui/LocatedTexture.java
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
//
// Path: src/igwmod/TessWrapper.java
// public class TessWrapper{
// public static void startDrawingTexturedQuads(){
// Tessellator.getInstance().getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX);
// }
//
// public static void addVertexWithUV(double x, double y, double z, double u, double v){
// Tessellator.getInstance().getBuffer().pos(x, y, z).tex(u, v).endVertex();
// }
//
// public static void draw(){
// Tessellator.getInstance().draw();
// }
// }
|
import igwmod.IGWMod;
import igwmod.TessWrapper;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
|
bufferedimage = ImageIO.read(inputstream);
}
width = (int)(bufferedimage.getWidth() * scale);
height = (int)(bufferedimage.getHeight() * scale);
} catch(Exception e) {
e.printStackTrace();
}
}
@Override
public Rectangle getReservedSpace(){
return new Rectangle(x, y, width, height);
}
@Override
public void renderBackground(GuiWiki gui, int mouseX, int mouseY){
if(texture.getResourcePath().startsWith("server")) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
} else {
gui.mc.getTextureManager().bindTexture(texture);
}
drawTexture(x, y, width, height);
}
@Override
public void renderForeground(GuiWiki gui, int mouseX, int mouseY){}
public static void drawTexture(int x, int y, int width, int heigth){
int minYCap = Math.max(0, GuiWiki.MIN_TEXT_Y - y);
int maxYCap = Math.min(heigth, GuiWiki.MAX_TEXT_Y - y);
|
// Path: src/igwmod/IGWMod.java
// @Mod(modid = Constants.MOD_ID, name = "In-Game Wiki Mod")
// public class IGWMod{
// @SidedProxy(clientSide = "igwmod.ClientProxy", serverSide = "igwmod.ServerProxy")
// public static IProxy proxy;
//
// @Instance(Constants.MOD_ID)
// public IGWMod instance;
//
// /**
// * This method is used to reject connection when the server has server info available for IGW-mod. Unless the properties.txt explicitly says
// * it's okay to connect without IGW-Mod, by setting "optional=true".
// * @param installedMods
// * @param side
// * @return
// */
// @NetworkCheckHandler
// public boolean onConnectRequest(Map<String, String> installedMods, Side side){
// if(side == Side.SERVER || proxy == null) return true;
// File serverFolder = new File(proxy.getSaveLocation() + File.separator + "igwmod" + File.separator);
// if(serverFolder.exists() || new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator).exists()) {//TODO remove legacy
// String str = proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + "properties.txt";
// File file = new File(str);
// if(!file.exists()) {
// file = new File(proxy.getSaveLocation() + File.separator + "igwmodServer" + File.separator + "properties.txt");//TODO remove legacy
// }
// if(file.exists()) {
// try {
// FileInputStream stream = new FileInputStream(file);
// BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// List<String> textList = new ArrayList<String>();
// String line = br.readLine();
// while(line != null) {
// textList.add(line);
// line = br.readLine();
// }
// br.close();
//
// if(textList != null) {
// for(String s : textList) {
// String[] entry = s.split("=");
// if(entry[0].equals("optional")) {
// if(Boolean.parseBoolean(entry[1])) return true;
// }
// }
// }
// } catch(Exception e) {
// e.printStackTrace();
// }
// }
// String version = installedMods.get(Constants.MOD_ID);
// if(version.equals("${version}")) return true;
// return version != null && version.equals(Constants.fullVersionString());
// } else {
// return true;
// }
//
// }
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event){
// event.getModMetadata().version = Constants.fullVersionString();
// proxy.preInit(event);
// NetworkHandler.init();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event){
//
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event){
// proxy.postInit();
// }
//
// @EventHandler
// public void processIMCRequests(FMLInterModComms.IMCEvent event){
// proxy.processIMC(event);
// }
// }
//
// Path: src/igwmod/TessWrapper.java
// public class TessWrapper{
// public static void startDrawingTexturedQuads(){
// Tessellator.getInstance().getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX);
// }
//
// public static void addVertexWithUV(double x, double y, double z, double u, double v){
// Tessellator.getInstance().getBuffer().pos(x, y, z).tex(u, v).endVertex();
// }
//
// public static void draw(){
// Tessellator.getInstance().draw();
// }
// }
// Path: src/igwmod/gui/LocatedTexture.java
import igwmod.IGWMod;
import igwmod.TessWrapper;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
bufferedimage = ImageIO.read(inputstream);
}
width = (int)(bufferedimage.getWidth() * scale);
height = (int)(bufferedimage.getHeight() * scale);
} catch(Exception e) {
e.printStackTrace();
}
}
@Override
public Rectangle getReservedSpace(){
return new Rectangle(x, y, width, height);
}
@Override
public void renderBackground(GuiWiki gui, int mouseX, int mouseY){
if(texture.getResourcePath().startsWith("server")) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
} else {
gui.mc.getTextureManager().bindTexture(texture);
}
drawTexture(x, y, width, height);
}
@Override
public void renderForeground(GuiWiki gui, int mouseX, int mouseY){}
public static void drawTexture(int x, int y, int width, int heigth){
int minYCap = Math.max(0, GuiWiki.MIN_TEXT_Y - y);
int maxYCap = Math.min(heigth, GuiWiki.MAX_TEXT_Y - y);
|
TessWrapper.startDrawingTexturedQuads();
|
MineMaarten/IGW-mod
|
src/igwmod/gui/LocatedStack.java
|
// Path: src/igwmod/api/WikiRegistry.java
// public class WikiRegistry{
//
// private static List<Map.Entry<String, ItemStack>> itemAndBlockPageEntries = new ArrayList<Map.Entry<String, ItemStack>>();
// private static Map<Class<? extends Entity>, String> entityPageEntries = new HashMap<Class<? extends Entity>, String>();
// public static List<IRecipeIntegrator> recipeIntegrators = new ArrayList<IRecipeIntegrator>();
// public static List<ITextInterpreter> textInterpreters = new ArrayList<ITextInterpreter>();
// private static IWikiHooks wikiHooks = new WikiHooks();
//
// public static void registerWikiTab(IWikiTab tab){
// if(tab instanceof ServerWikiTab) {
// for(IWikiTab t : GuiWiki.wikiTabs) {
// if(t instanceof ServerWikiTab) {
// GuiWiki.wikiTabs.remove(t);
// break;
// }
// }
// GuiWiki.wikiTabs.add(0, tab);
// } else {
// GuiWiki.wikiTabs.add(tab);
// }
// }
//
// public static void registerBlockAndItemPageEntry(ItemStack stack){
// if(stack.isEmpty() || stack.getItem() == null) throw new IllegalArgumentException("Can't register null items");
// registerBlockAndItemPageEntry(stack, stack.getUnlocalizedName().replace("tile.", "block/").replace("item.", "item/"));
// }
//
// public static void registerBlockAndItemPageEntry(Block block, String page){
// registerBlockAndItemPageEntry(new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE), page);
// }
//
// public static void registerBlockAndItemPageEntry(Item item, String page){
// registerBlockAndItemPageEntry(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE), page);
// }
//
// public static void registerBlockAndItemPageEntry(ItemStack stack, String page){
// itemAndBlockPageEntries.add(new AbstractMap.SimpleEntry(page, stack));
// }
//
// public static void registerEntityPageEntry(Class<? extends Entity> entityClass){
// // registerEntityPageEntry(entityClass, "entity/" + EntityList.CLASS_TO_NAME.get(entityClass));
// registerEntityPageEntry(entityClass, "entity/" + EntityList.getKey(entityClass).getResourcePath());
// }
//
// public static void registerEntityPageEntry(Class<? extends Entity> entityClass, String page){
// entityPageEntries.put(entityClass, page);
// }
//
// public static void registerRecipeIntegrator(IRecipeIntegrator recipeIntegrator){
// recipeIntegrators.add(recipeIntegrator);
// }
//
// public static void registerTextInterpreter(ITextInterpreter textInterpreter){
// textInterpreters.add(textInterpreter);
// }
//
// public static String getPageForItemStack(ItemStack stack){
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(entry.getValue().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(entry.getValue(), stack)) return entry.getKey();
// }
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(OreDictionary.itemMatches(entry.getValue(), stack, false)) return entry.getKey();
// }
// return null;
// }
//
// public static String getPageForEntityClass(Class<? extends Entity> entityClass){
// String page = entityPageEntries.get(entityClass);
// if(page != null) {
// return page;
// } else {
// ResourceLocation entityName = EntityList.getKey(entityClass);
// return entityName == null ? null : "entity/" + entityName.getResourcePath();
// }
// }
//
// public static List<ItemStack> getItemAndBlockPageEntries(){
// // List<ItemStack> entries = new ArrayList<ItemStack>();
// NonNullList<ItemStack> entries = NonNullList.create();
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(entry.getValue().getItemDamage() == OreDictionary.WILDCARD_VALUE) {
// entry.getValue().getItem().getSubItems(CreativeTabs.SEARCH, entries);
// } else {
// entries.add(entry.getValue());
// }
// }
// return entries;
// }
//
// public static List<Class<? extends Entity>> getEntityPageEntries(){
// List<Class<? extends Entity>> entries = new ArrayList<Class<? extends Entity>>();
// for(Class<? extends Entity> entityClass : entityPageEntries.keySet()) {
// entries.add(entityClass);
// }
// return entries;
// }
//
// public static IWikiHooks getWikiHooks(){
// return wikiHooks;
// }
// }
|
import java.awt.Rectangle;
import igwmod.api.WikiRegistry;
import net.minecraft.item.ItemStack;
|
package igwmod.gui;
public class LocatedStack implements IReservedSpace, IPageLink{
public final ItemStack stack;
public int x, y;
public LocatedStack(ItemStack stack, int x, int y){
this.stack = stack;
this.x = x;
this.y = y;
}
@Override
public Rectangle getReservedSpace(){
return new Rectangle((int)(x / GuiWiki.TEXT_SCALE), (int)(y / GuiWiki.TEXT_SCALE), (int)(16 / GuiWiki.TEXT_SCALE), (int)(16 / GuiWiki.TEXT_SCALE));
}
@Override
public boolean onMouseClick(GuiWiki gui, int x, int y){
return false;//Don't do anything, as pagelinking will be handled by the container call when a slot gets clicked.
}
@Override
public void renderBackground(GuiWiki gui, int mouseX, int mouseY){} //Rendering will be done by the GuiContainer.
@Override
public void renderForeground(GuiWiki gui, int mouseX, int mouseY){}
@Override
public String getName(){
return stack.getItem() == null ? "<STACK HAS NO ITEM!>" : stack.getDisplayName();
}
@Override
public String getLinkAddress(){
|
// Path: src/igwmod/api/WikiRegistry.java
// public class WikiRegistry{
//
// private static List<Map.Entry<String, ItemStack>> itemAndBlockPageEntries = new ArrayList<Map.Entry<String, ItemStack>>();
// private static Map<Class<? extends Entity>, String> entityPageEntries = new HashMap<Class<? extends Entity>, String>();
// public static List<IRecipeIntegrator> recipeIntegrators = new ArrayList<IRecipeIntegrator>();
// public static List<ITextInterpreter> textInterpreters = new ArrayList<ITextInterpreter>();
// private static IWikiHooks wikiHooks = new WikiHooks();
//
// public static void registerWikiTab(IWikiTab tab){
// if(tab instanceof ServerWikiTab) {
// for(IWikiTab t : GuiWiki.wikiTabs) {
// if(t instanceof ServerWikiTab) {
// GuiWiki.wikiTabs.remove(t);
// break;
// }
// }
// GuiWiki.wikiTabs.add(0, tab);
// } else {
// GuiWiki.wikiTabs.add(tab);
// }
// }
//
// public static void registerBlockAndItemPageEntry(ItemStack stack){
// if(stack.isEmpty() || stack.getItem() == null) throw new IllegalArgumentException("Can't register null items");
// registerBlockAndItemPageEntry(stack, stack.getUnlocalizedName().replace("tile.", "block/").replace("item.", "item/"));
// }
//
// public static void registerBlockAndItemPageEntry(Block block, String page){
// registerBlockAndItemPageEntry(new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE), page);
// }
//
// public static void registerBlockAndItemPageEntry(Item item, String page){
// registerBlockAndItemPageEntry(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE), page);
// }
//
// public static void registerBlockAndItemPageEntry(ItemStack stack, String page){
// itemAndBlockPageEntries.add(new AbstractMap.SimpleEntry(page, stack));
// }
//
// public static void registerEntityPageEntry(Class<? extends Entity> entityClass){
// // registerEntityPageEntry(entityClass, "entity/" + EntityList.CLASS_TO_NAME.get(entityClass));
// registerEntityPageEntry(entityClass, "entity/" + EntityList.getKey(entityClass).getResourcePath());
// }
//
// public static void registerEntityPageEntry(Class<? extends Entity> entityClass, String page){
// entityPageEntries.put(entityClass, page);
// }
//
// public static void registerRecipeIntegrator(IRecipeIntegrator recipeIntegrator){
// recipeIntegrators.add(recipeIntegrator);
// }
//
// public static void registerTextInterpreter(ITextInterpreter textInterpreter){
// textInterpreters.add(textInterpreter);
// }
//
// public static String getPageForItemStack(ItemStack stack){
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(entry.getValue().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(entry.getValue(), stack)) return entry.getKey();
// }
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(OreDictionary.itemMatches(entry.getValue(), stack, false)) return entry.getKey();
// }
// return null;
// }
//
// public static String getPageForEntityClass(Class<? extends Entity> entityClass){
// String page = entityPageEntries.get(entityClass);
// if(page != null) {
// return page;
// } else {
// ResourceLocation entityName = EntityList.getKey(entityClass);
// return entityName == null ? null : "entity/" + entityName.getResourcePath();
// }
// }
//
// public static List<ItemStack> getItemAndBlockPageEntries(){
// // List<ItemStack> entries = new ArrayList<ItemStack>();
// NonNullList<ItemStack> entries = NonNullList.create();
// for(Map.Entry<String, ItemStack> entry : itemAndBlockPageEntries) {
// if(entry.getValue().getItemDamage() == OreDictionary.WILDCARD_VALUE) {
// entry.getValue().getItem().getSubItems(CreativeTabs.SEARCH, entries);
// } else {
// entries.add(entry.getValue());
// }
// }
// return entries;
// }
//
// public static List<Class<? extends Entity>> getEntityPageEntries(){
// List<Class<? extends Entity>> entries = new ArrayList<Class<? extends Entity>>();
// for(Class<? extends Entity> entityClass : entityPageEntries.keySet()) {
// entries.add(entityClass);
// }
// return entries;
// }
//
// public static IWikiHooks getWikiHooks(){
// return wikiHooks;
// }
// }
// Path: src/igwmod/gui/LocatedStack.java
import java.awt.Rectangle;
import igwmod.api.WikiRegistry;
import net.minecraft.item.ItemStack;
package igwmod.gui;
public class LocatedStack implements IReservedSpace, IPageLink{
public final ItemStack stack;
public int x, y;
public LocatedStack(ItemStack stack, int x, int y){
this.stack = stack;
this.x = x;
this.y = y;
}
@Override
public Rectangle getReservedSpace(){
return new Rectangle((int)(x / GuiWiki.TEXT_SCALE), (int)(y / GuiWiki.TEXT_SCALE), (int)(16 / GuiWiki.TEXT_SCALE), (int)(16 / GuiWiki.TEXT_SCALE));
}
@Override
public boolean onMouseClick(GuiWiki gui, int x, int y){
return false;//Don't do anything, as pagelinking will be handled by the container call when a slot gets clicked.
}
@Override
public void renderBackground(GuiWiki gui, int mouseX, int mouseY){} //Rendering will be done by the GuiContainer.
@Override
public void renderForeground(GuiWiki gui, int mouseX, int mouseY){}
@Override
public String getName(){
return stack.getItem() == null ? "<STACK HAS NO ITEM!>" : stack.getDisplayName();
}
@Override
public String getLinkAddress(){
|
return WikiRegistry.getPageForItemStack(stack);
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/GeofenceReceiver.java
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/MainActivity.java
// public class MainActivity extends AppCompatActivity {
// private static final int LOCATION_REQUEST = 1;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// TextView mainTextView = (TextView) findViewById(R.id.textView);
// mainTextView.setText(Html.fromHtml(getString(R.string.main_textview)));
// mainTextView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.lexa.fakegps"));
// startActivity(intent);
// }
// });
//
// //Request location permission for geolocation/geofencing features
// if (ContextCompat.checkSelfPermission(this,
// android.Manifest.permission.ACCESS_FINE_LOCATION)
// != PackageManager.PERMISSION_GRANTED) {
//
// ActivityCompat.requestPermissions(this,
// new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
// LOCATION_REQUEST);
// }
//
// Button button = (Button) findViewById(R.id.btn_view_geofences);
// button.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(MainActivity.this, DBViewerActivity.class);
// startActivity(intent);
// }
// });
//
// FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.floatingActionButton);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(MainActivity.this, GeofenceTrackingActivity.class);
// startActivity(intent);
// }
// });
// }
// }
|
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.util.Log;
import com.accengage.samples.geofences.activities.MainActivity;
import com.ad4screen.sdk.Constants;
import java.util.Arrays;
|
package com.accengage.samples.geofences;
public class GeofenceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Bundle geofenceData = bundle.getBundle(Constants.EXTRA_GEOFENCE_PAYLOAD);
if (geofenceData != null) {
//Retrieve ids of geofences triggered :
String[] geofencesIds = geofenceData.getStringArray("ids");
//Retrieve transition code (1 == enter, 0 == exit)
int transitionCode = geofenceData.getInt("transition");
//Retrieve the geolocation that has triggered these geofences
//(Note : you will have to parse it as a JSONObject)
//Keys are : provider, latitude, longitude, altitude, accuracy, bearing, speed, time)
String location = geofenceData.getString("triggeringLocation");
if (location != null) {
Log.d("GeofenceReceiver", "location: " + location);
}
//Do anything you want, here we will show a notification
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/MainActivity.java
// public class MainActivity extends AppCompatActivity {
// private static final int LOCATION_REQUEST = 1;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// TextView mainTextView = (TextView) findViewById(R.id.textView);
// mainTextView.setText(Html.fromHtml(getString(R.string.main_textview)));
// mainTextView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(Intent.ACTION_VIEW);
// intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.lexa.fakegps"));
// startActivity(intent);
// }
// });
//
// //Request location permission for geolocation/geofencing features
// if (ContextCompat.checkSelfPermission(this,
// android.Manifest.permission.ACCESS_FINE_LOCATION)
// != PackageManager.PERMISSION_GRANTED) {
//
// ActivityCompat.requestPermissions(this,
// new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
// LOCATION_REQUEST);
// }
//
// Button button = (Button) findViewById(R.id.btn_view_geofences);
// button.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(MainActivity.this, DBViewerActivity.class);
// startActivity(intent);
// }
// });
//
// FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.floatingActionButton);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent = new Intent(MainActivity.this, GeofenceTrackingActivity.class);
// startActivity(intent);
// }
// });
// }
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/GeofenceReceiver.java
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.util.Log;
import com.accengage.samples.geofences.activities.MainActivity;
import com.ad4screen.sdk.Constants;
import java.util.Arrays;
package com.accengage.samples.geofences;
public class GeofenceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Bundle geofenceData = bundle.getBundle(Constants.EXTRA_GEOFENCE_PAYLOAD);
if (geofenceData != null) {
//Retrieve ids of geofences triggered :
String[] geofencesIds = geofenceData.getStringArray("ids");
//Retrieve transition code (1 == enter, 0 == exit)
int transitionCode = geofenceData.getInt("transition");
//Retrieve the geolocation that has triggered these geofences
//(Note : you will have to parse it as a JSONObject)
//Keys are : provider, latitude, longitude, altitude, accuracy, bearing, speed, time)
String location = geofenceData.getString("triggeringLocation");
if (location != null) {
Log.d("GeofenceReceiver", "location: " + location);
}
//Do anything you want, here we will show a notification
|
Intent notifIntent = new Intent(context, MainActivity.class);
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/MainActivity.java
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
|
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.accengage.samples.geofences.R;
import com.ad4screen.sdk.A4S;
|
package com.accengage.samples.geofences.activities;
public class MainActivity extends AppCompatActivity {
private static final int LOCATION_REQUEST = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/MainActivity.java
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.accengage.samples.geofences.R;
import com.ad4screen.sdk.A4S;
package com.accengage.samples.geofences.activities;
public class MainActivity extends AppCompatActivity {
private static final int LOCATION_REQUEST = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_main);
|
Accengage/accengage-android-sdk-samples
|
AccSample/app/src/main/java/com/accengage/samples/coffeesample/receivers/CustomsParametersReceiver.java
|
// Path: AccSample/app/src/main/java/com/accengage/samples/coffeesample/activities/SampleSettings.java
// @Tag(name = "CoffeeSettings")
// public class SampleSettings extends PreferenceActivity {
//
// private CheckBoxPreference mInappDisplayLock;
//
// @Override
// protected void onCreate(Bundle icicle) {
// super.onCreate(icicle);
//
// addPreferencesFromResource(R.xml.samplesettings);
// setTitle("View : CoffeeSettings");
// mInappDisplayLock = (CheckBoxPreference) findPreference("displayLocked");
//
// mInappDisplayLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
//
// @Override
// public boolean onPreferenceChange(Preference preference, Object newValue) {
// if(newValue.toString().equals("true")) {
// mInappDisplayLock.setChecked(true);
// A4S.get(SampleSettings.this).setInAppDisplayLocked(true);
// }
// else {
// mInappDisplayLock.setChecked(false);
// A4S.get(SampleSettings.this).setInAppDisplayLocked(false);
// }
// return false;
// }
// });
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// // This activity can be opened through url schema
// // Here we are parsing uri for parameters
// Intent intent = getIntent();
// if (intent != null && intent.getData() != null) {
// Uri uri = intent.getData();
// //Use datas here and display anything you want relative to these parameters.
// }
// }
//
// }
|
import java.util.Set;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.accengage.samples.coffeesample.activities.SampleSettings;
|
package com.accengage.samples.coffeesample.receivers;
/**
* Handle custom parameters as explained on
* @see http://docs.accengage.com/display/AND/Android#Android-RetrievingIn-App/Push/InboxandotherCustomParameterswithaBroadcastReceiver
* In this sample, this class is called as soon as an in-app or push is clicked
*
*/
public class CustomsParametersReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Set<String> cats = intent.getCategories();
Bundle bundle = intent.getExtras();
if(bundle != null) {
//Use category in order to know which case to handle
//You can retrieve the action too in order to know which action has been triggered
//All actions and categories available can be found inside com.ad4screen.sdk.Constants
for (String currentCat : cats) {
if(currentCat.equals(com.ad4screen.sdk.Constants.CATEGORY_PUSH_NOTIFICATIONS)) {
//Handle push custom parameters
handlePushCustomParameters(context, bundle);
}
if(currentCat.equals(com.ad4screen.sdk.Constants.CATEGORY_INAPP_NOTIFICATIONS)) {
//Handle in-app custom parameters
}
}
}
}
/**
* Handle and trigger an action on some custom parameters
* @param context
* @param bundle
*/
private void handlePushCustomParameters(Context context, Bundle bundle) {
//Get your key and do what you want
String myCustomParameter = bundle.getString("my-key");
//For instance, here we will open Settings activity if my-key value is settings
if(myCustomParameter != null && myCustomParameter.equals("settings")) {
|
// Path: AccSample/app/src/main/java/com/accengage/samples/coffeesample/activities/SampleSettings.java
// @Tag(name = "CoffeeSettings")
// public class SampleSettings extends PreferenceActivity {
//
// private CheckBoxPreference mInappDisplayLock;
//
// @Override
// protected void onCreate(Bundle icicle) {
// super.onCreate(icicle);
//
// addPreferencesFromResource(R.xml.samplesettings);
// setTitle("View : CoffeeSettings");
// mInappDisplayLock = (CheckBoxPreference) findPreference("displayLocked");
//
// mInappDisplayLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
//
// @Override
// public boolean onPreferenceChange(Preference preference, Object newValue) {
// if(newValue.toString().equals("true")) {
// mInappDisplayLock.setChecked(true);
// A4S.get(SampleSettings.this).setInAppDisplayLocked(true);
// }
// else {
// mInappDisplayLock.setChecked(false);
// A4S.get(SampleSettings.this).setInAppDisplayLocked(false);
// }
// return false;
// }
// });
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// // This activity can be opened through url schema
// // Here we are parsing uri for parameters
// Intent intent = getIntent();
// if (intent != null && intent.getData() != null) {
// Uri uri = intent.getData();
// //Use datas here and display anything you want relative to these parameters.
// }
// }
//
// }
// Path: AccSample/app/src/main/java/com/accengage/samples/coffeesample/receivers/CustomsParametersReceiver.java
import java.util.Set;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.accengage.samples.coffeesample.activities.SampleSettings;
package com.accengage.samples.coffeesample.receivers;
/**
* Handle custom parameters as explained on
* @see http://docs.accengage.com/display/AND/Android#Android-RetrievingIn-App/Push/InboxandotherCustomParameterswithaBroadcastReceiver
* In this sample, this class is called as soon as an in-app or push is clicked
*
*/
public class CustomsParametersReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Set<String> cats = intent.getCategories();
Bundle bundle = intent.getExtras();
if(bundle != null) {
//Use category in order to know which case to handle
//You can retrieve the action too in order to know which action has been triggered
//All actions and categories available can be found inside com.ad4screen.sdk.Constants
for (String currentCat : cats) {
if(currentCat.equals(com.ad4screen.sdk.Constants.CATEGORY_PUSH_NOTIFICATIONS)) {
//Handle push custom parameters
handlePushCustomParameters(context, bundle);
}
if(currentCat.equals(com.ad4screen.sdk.Constants.CATEGORY_INAPP_NOTIFICATIONS)) {
//Handle in-app custom parameters
}
}
}
}
/**
* Handle and trigger an action on some custom parameters
* @param context
* @param bundle
*/
private void handlePushCustomParameters(Context context, Bundle bundle) {
//Get your key and do what you want
String myCustomParameter = bundle.getString("my-key");
//For instance, here we will open Settings activity if my-key value is settings
if(myCustomParameter != null && myCustomParameter.equals("settings")) {
|
Intent intent = new Intent(context, SampleSettings.class);
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/GeofencesDetailsActivity.java
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
// public class Utils {
//
// public static int _ID = 0;
// public static int SERVER_ID = 1;
// public static int EXTERNAL_ID = 2;
// public static int NAME = 3;
// public static int LATITUDE = 4;
// public static int LONGITUDE = 5;
// public static int RADIUS = 6;
// public static int DETECTED_TIME = 7;
// public static int NOTIFIED_TIME = 8;
// public static int DETECTED_COUNT = 9;
// public static int DEVICE_LATITUDE = 10;
// public static int DEVICE_LONGITUDE = 11;
// public static int DISTANCE = 12;
//
// /**
// * Checks in the SharedPreferences how you chose the geofences to be displayed
// * @param context
// * @return selected option as a keyword
// */
// public static String getGeofenceSortingField(Context context) {
// SharedPreferences preferences = context.getSharedPreferences(
// DBPreferencesActivity.DBVIEW_PREFERENCES_FILE_NAME,
// Context.MODE_PRIVATE);
// String keyword = preferences.getString(context.getResources().getString(R.string.geofence_sorting_keyword), "");
// boolean descOrder = preferences.getBoolean(context.getResources().getString(R.string.geofence_sorting_order), false);
// if (descOrder) keyword += " DESC";
// return keyword;
// }
//
// /**
// * Calculates the optimal zoom to apply to the maps' camera when drawing a geofence using circle
// * @param circle you want to zoom to
// * @return the best zoom level
// */
// public static int getZoomLevel(Circle circle) {
// int zoomLevel = 11;
// if (circle != null) {
// double radius = circle.getRadius() + circle.getRadius() / 2;
// double scale = radius / 500;
// zoomLevel = (int) (15 - Math.log(scale) / Math.log(2));
// }
// return zoomLevel;
// }
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
|
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.widget.TextView;
import com.accengage.samples.geofences.Utils;
import com.accengage.samples.geofences.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
|
package com.accengage.samples.geofences.activities;
public class GeofencesDetailsActivity extends AppCompatActivity implements OnMapReadyCallback{
ArrayList<String> mGeofencesList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
// public class Utils {
//
// public static int _ID = 0;
// public static int SERVER_ID = 1;
// public static int EXTERNAL_ID = 2;
// public static int NAME = 3;
// public static int LATITUDE = 4;
// public static int LONGITUDE = 5;
// public static int RADIUS = 6;
// public static int DETECTED_TIME = 7;
// public static int NOTIFIED_TIME = 8;
// public static int DETECTED_COUNT = 9;
// public static int DEVICE_LATITUDE = 10;
// public static int DEVICE_LONGITUDE = 11;
// public static int DISTANCE = 12;
//
// /**
// * Checks in the SharedPreferences how you chose the geofences to be displayed
// * @param context
// * @return selected option as a keyword
// */
// public static String getGeofenceSortingField(Context context) {
// SharedPreferences preferences = context.getSharedPreferences(
// DBPreferencesActivity.DBVIEW_PREFERENCES_FILE_NAME,
// Context.MODE_PRIVATE);
// String keyword = preferences.getString(context.getResources().getString(R.string.geofence_sorting_keyword), "");
// boolean descOrder = preferences.getBoolean(context.getResources().getString(R.string.geofence_sorting_order), false);
// if (descOrder) keyword += " DESC";
// return keyword;
// }
//
// /**
// * Calculates the optimal zoom to apply to the maps' camera when drawing a geofence using circle
// * @param circle you want to zoom to
// * @return the best zoom level
// */
// public static int getZoomLevel(Circle circle) {
// int zoomLevel = 11;
// if (circle != null) {
// double radius = circle.getRadius() + circle.getRadius() / 2;
// double scale = radius / 500;
// zoomLevel = (int) (15 - Math.log(scale) / Math.log(2));
// }
// return zoomLevel;
// }
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/GeofencesDetailsActivity.java
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.widget.TextView;
import com.accengage.samples.geofences.Utils;
import com.accengage.samples.geofences.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
package com.accengage.samples.geofences.activities;
public class GeofencesDetailsActivity extends AppCompatActivity implements OnMapReadyCallback{
ArrayList<String> mGeofencesList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_geofences_details);
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/GeofencesDetailsActivity.java
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
// public class Utils {
//
// public static int _ID = 0;
// public static int SERVER_ID = 1;
// public static int EXTERNAL_ID = 2;
// public static int NAME = 3;
// public static int LATITUDE = 4;
// public static int LONGITUDE = 5;
// public static int RADIUS = 6;
// public static int DETECTED_TIME = 7;
// public static int NOTIFIED_TIME = 8;
// public static int DETECTED_COUNT = 9;
// public static int DEVICE_LATITUDE = 10;
// public static int DEVICE_LONGITUDE = 11;
// public static int DISTANCE = 12;
//
// /**
// * Checks in the SharedPreferences how you chose the geofences to be displayed
// * @param context
// * @return selected option as a keyword
// */
// public static String getGeofenceSortingField(Context context) {
// SharedPreferences preferences = context.getSharedPreferences(
// DBPreferencesActivity.DBVIEW_PREFERENCES_FILE_NAME,
// Context.MODE_PRIVATE);
// String keyword = preferences.getString(context.getResources().getString(R.string.geofence_sorting_keyword), "");
// boolean descOrder = preferences.getBoolean(context.getResources().getString(R.string.geofence_sorting_order), false);
// if (descOrder) keyword += " DESC";
// return keyword;
// }
//
// /**
// * Calculates the optimal zoom to apply to the maps' camera when drawing a geofence using circle
// * @param circle you want to zoom to
// * @return the best zoom level
// */
// public static int getZoomLevel(Circle circle) {
// int zoomLevel = 11;
// if (circle != null) {
// double radius = circle.getRadius() + circle.getRadius() / 2;
// double scale = radius / 500;
// zoomLevel = (int) (15 - Math.log(scale) / Math.log(2));
// }
// return zoomLevel;
// }
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
|
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.widget.TextView;
import com.accengage.samples.geofences.Utils;
import com.accengage.samples.geofences.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
|
package com.accengage.samples.geofences.activities;
public class GeofencesDetailsActivity extends AppCompatActivity implements OnMapReadyCallback{
ArrayList<String> mGeofencesList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geofences_details);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Intent i = getIntent();
mGeofencesList = i.getStringArrayListExtra("cursor");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
initTV();
}
private void initTV(){
TextView tv = (TextView) findViewById(R.id.geofence_name_value);
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
// public class Utils {
//
// public static int _ID = 0;
// public static int SERVER_ID = 1;
// public static int EXTERNAL_ID = 2;
// public static int NAME = 3;
// public static int LATITUDE = 4;
// public static int LONGITUDE = 5;
// public static int RADIUS = 6;
// public static int DETECTED_TIME = 7;
// public static int NOTIFIED_TIME = 8;
// public static int DETECTED_COUNT = 9;
// public static int DEVICE_LATITUDE = 10;
// public static int DEVICE_LONGITUDE = 11;
// public static int DISTANCE = 12;
//
// /**
// * Checks in the SharedPreferences how you chose the geofences to be displayed
// * @param context
// * @return selected option as a keyword
// */
// public static String getGeofenceSortingField(Context context) {
// SharedPreferences preferences = context.getSharedPreferences(
// DBPreferencesActivity.DBVIEW_PREFERENCES_FILE_NAME,
// Context.MODE_PRIVATE);
// String keyword = preferences.getString(context.getResources().getString(R.string.geofence_sorting_keyword), "");
// boolean descOrder = preferences.getBoolean(context.getResources().getString(R.string.geofence_sorting_order), false);
// if (descOrder) keyword += " DESC";
// return keyword;
// }
//
// /**
// * Calculates the optimal zoom to apply to the maps' camera when drawing a geofence using circle
// * @param circle you want to zoom to
// * @return the best zoom level
// */
// public static int getZoomLevel(Circle circle) {
// int zoomLevel = 11;
// if (circle != null) {
// double radius = circle.getRadius() + circle.getRadius() / 2;
// double scale = radius / 500;
// zoomLevel = (int) (15 - Math.log(scale) / Math.log(2));
// }
// return zoomLevel;
// }
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/GeofencesDetailsActivity.java
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.widget.TextView;
import com.accengage.samples.geofences.Utils;
import com.accengage.samples.geofences.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.ArrayList;
package com.accengage.samples.geofences.activities;
public class GeofencesDetailsActivity extends AppCompatActivity implements OnMapReadyCallback{
ArrayList<String> mGeofencesList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geofences_details);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Intent i = getIntent();
mGeofencesList = i.getStringArrayListExtra("cursor");
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
initTV();
}
private void initTV(){
TextView tv = (TextView) findViewById(R.id.geofence_name_value);
|
tv.setText(mGeofencesList.get(Utils.NAME));
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/BuildConfig.java
// public final class BuildConfig {
// public final static boolean DEBUG = Boolean.parseBoolean(null);
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
|
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.accengage.samples.geofences.BuildConfig;
import com.accengage.samples.geofences.R;
|
package com.accengage.samples.geofences.activities;
public class DBPreferencesActivity extends Activity {
public static final String KEY_PREFERENCE_ID = "key_preference_id";
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/BuildConfig.java
// public final class BuildConfig {
// public final static boolean DEBUG = Boolean.parseBoolean(null);
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.accengage.samples.geofences.BuildConfig;
import com.accengage.samples.geofences.R;
package com.accengage.samples.geofences.activities;
public class DBPreferencesActivity extends Activity {
public static final String KEY_PREFERENCE_ID = "key_preference_id";
|
public static final String DBVIEW_PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + ".dbview_preferences";
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/BuildConfig.java
// public final class BuildConfig {
// public final static boolean DEBUG = Boolean.parseBoolean(null);
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
|
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.accengage.samples.geofences.BuildConfig;
import com.accengage.samples.geofences.R;
|
package com.accengage.samples.geofences.activities;
public class DBPreferencesActivity extends Activity {
public static final String KEY_PREFERENCE_ID = "key_preference_id";
public static final String DBVIEW_PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + ".dbview_preferences";
public static final int GEOFENCE_PREFERENCES = 0;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int preferenceId = getIntent().getIntExtra(KEY_PREFERENCE_ID, GEOFENCE_PREFERENCES);
if (preferenceId == GEOFENCE_PREFERENCES) {
// Display geofence preferences fragment
getFragmentManager().beginTransaction()
|
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/BuildConfig.java
// public final class BuildConfig {
// public final static boolean DEBUG = Boolean.parseBoolean(null);
// }
//
// Path: AccGeofences/app/src/main/gen/com/accengage/samples/geofences/R.java
// public final class R {
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.accengage.samples.geofences.BuildConfig;
import com.accengage.samples.geofences.R;
package com.accengage.samples.geofences.activities;
public class DBPreferencesActivity extends Activity {
public static final String KEY_PREFERENCE_ID = "key_preference_id";
public static final String DBVIEW_PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + ".dbview_preferences";
public static final int GEOFENCE_PREFERENCES = 0;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int preferenceId = getIntent().getIntExtra(KEY_PREFERENCE_ID, GEOFENCE_PREFERENCES);
if (preferenceId == GEOFENCE_PREFERENCES) {
// Display geofence preferences fragment
getFragmentManager().beginTransaction()
|
.replace(android.R.id.content, new GeofencePreferencesFragment())
|
Accengage/accengage-android-sdk-samples
|
AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/Beacon.java
// public class Beacon {
//
// private String mId;
// private String mUuid;
// private int mMajor;
// private int mMinor;
// private int mTransition;
// private int mPower;
// private double mDistance;
// private String mAccuracy;
// private int mRssi;
// private Date mDate;
//
// public String getInternalId() {
// return mUuid + String.valueOf(mMajor) + String.valueOf(mMinor);
// }
//
// public String getId() {
// return mId;
// }
//
// public void setId(String id) {
// mId = id;
// }
//
// public String getUuid() {
// return mUuid;
// }
//
// public void setUuid(String uuid) {
// mUuid = uuid;
// }
//
// public int getMajor() {
// return mMajor;
// }
//
// public void setMajor(int major) {
// mMajor = major;
// }
//
// public int getMinor() {
// return mMinor;
// }
//
// public void setMinor(int minor) {
// mMinor = minor;
// }
//
// public int getTransition() {
// return mTransition;
// }
//
// public void setTransition(int transition) {
// mTransition = transition;
// }
//
// public int getPower() {
// return mPower;
// }
//
// public void setPower(int power) {
// mPower = power;
// }
//
// public double getDistance() {
// return mDistance;
// }
//
// public void setDistance(double distance) {
// mDistance = distance;
// }
//
// public String getAccuracy() {
// return mAccuracy;
// }
//
// public void setAccuracy(String accuracy) {
// mAccuracy = accuracy;
// }
//
// public int getRssi() {
// return mRssi;
// }
//
// public void setRssi(int rssi) {
// mRssi = rssi;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public void setDate(Date date) {
// mDate = date;
// }
//
// public static Beacon fromBundle(Bundle bundle) {
// Beacon beacon = new Beacon();
// beacon.setId(bundle.getString("id"));
// beacon.setUuid(bundle.getString("uuid"));
// beacon.setMajor(bundle.getInt("maj"));
// beacon.setMinor(bundle.getInt("min"));
// beacon.setTransition(bundle.getInt("transition"));
// beacon.setPower(bundle.getInt("power"));
// beacon.setDistance(bundle.getDouble("dist"));
// beacon.setAccuracy(bundle.getString("acc"));
// beacon.setRssi(bundle.getInt("rssi"));
// beacon.setDate(new Date(bundle.getLong("date")));
// return beacon;
// }
// }
//
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconAdapter.java
// public class BeaconAdapter extends RecyclerView.Adapter<BeaconAdapter.ViewHolder> {
//
// private LinkedHashMap<String, Beacon> mDataset;
//
// public BeaconAdapter(LinkedHashMap<String, Beacon> dataset) {
// mDataset = dataset;
// }
//
// @Override
// public BeaconAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// return new ViewHolder(new BeaconView(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(BeaconAdapter.ViewHolder holder, int position) {
// holder.getCell().bind(getItem(position));
// }
//
// private Beacon getItem(int position) {
// return mDataset.get(getItemKey(position));
// }
//
// private String getItemKey(int position) {
// Set<String> keys = mDataset.keySet();
// int i = 0;
// for (String key : keys) {
// if (i == position) {
// return key;
// }
// i++;
// }
// return null;
// }
//
// @Override
// public int getItemCount() {
// return mDataset.size();
// }
//
// public static class ViewHolder extends RecyclerView.ViewHolder {
// private BeaconView mCell;
//
// public ViewHolder(BeaconView v) {
// super(v);
// mCell = v;
// }
//
// public BeaconView getCell() {
// return mCell;
// }
// }
//
//
// }
|
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.accengage.samples.beacons.Beacon;
import com.accengage.samples.beacons.BeaconAdapter;
import com.accengage.samples.beacons.R;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.Constants;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
|
package com.accengage.samples.beacons.activities;
public class MainActivity extends Activity {
private static final int LOCATION_REQUEST = 1;
private RecyclerView mBeaconList;
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/Beacon.java
// public class Beacon {
//
// private String mId;
// private String mUuid;
// private int mMajor;
// private int mMinor;
// private int mTransition;
// private int mPower;
// private double mDistance;
// private String mAccuracy;
// private int mRssi;
// private Date mDate;
//
// public String getInternalId() {
// return mUuid + String.valueOf(mMajor) + String.valueOf(mMinor);
// }
//
// public String getId() {
// return mId;
// }
//
// public void setId(String id) {
// mId = id;
// }
//
// public String getUuid() {
// return mUuid;
// }
//
// public void setUuid(String uuid) {
// mUuid = uuid;
// }
//
// public int getMajor() {
// return mMajor;
// }
//
// public void setMajor(int major) {
// mMajor = major;
// }
//
// public int getMinor() {
// return mMinor;
// }
//
// public void setMinor(int minor) {
// mMinor = minor;
// }
//
// public int getTransition() {
// return mTransition;
// }
//
// public void setTransition(int transition) {
// mTransition = transition;
// }
//
// public int getPower() {
// return mPower;
// }
//
// public void setPower(int power) {
// mPower = power;
// }
//
// public double getDistance() {
// return mDistance;
// }
//
// public void setDistance(double distance) {
// mDistance = distance;
// }
//
// public String getAccuracy() {
// return mAccuracy;
// }
//
// public void setAccuracy(String accuracy) {
// mAccuracy = accuracy;
// }
//
// public int getRssi() {
// return mRssi;
// }
//
// public void setRssi(int rssi) {
// mRssi = rssi;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public void setDate(Date date) {
// mDate = date;
// }
//
// public static Beacon fromBundle(Bundle bundle) {
// Beacon beacon = new Beacon();
// beacon.setId(bundle.getString("id"));
// beacon.setUuid(bundle.getString("uuid"));
// beacon.setMajor(bundle.getInt("maj"));
// beacon.setMinor(bundle.getInt("min"));
// beacon.setTransition(bundle.getInt("transition"));
// beacon.setPower(bundle.getInt("power"));
// beacon.setDistance(bundle.getDouble("dist"));
// beacon.setAccuracy(bundle.getString("acc"));
// beacon.setRssi(bundle.getInt("rssi"));
// beacon.setDate(new Date(bundle.getLong("date")));
// return beacon;
// }
// }
//
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconAdapter.java
// public class BeaconAdapter extends RecyclerView.Adapter<BeaconAdapter.ViewHolder> {
//
// private LinkedHashMap<String, Beacon> mDataset;
//
// public BeaconAdapter(LinkedHashMap<String, Beacon> dataset) {
// mDataset = dataset;
// }
//
// @Override
// public BeaconAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// return new ViewHolder(new BeaconView(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(BeaconAdapter.ViewHolder holder, int position) {
// holder.getCell().bind(getItem(position));
// }
//
// private Beacon getItem(int position) {
// return mDataset.get(getItemKey(position));
// }
//
// private String getItemKey(int position) {
// Set<String> keys = mDataset.keySet();
// int i = 0;
// for (String key : keys) {
// if (i == position) {
// return key;
// }
// i++;
// }
// return null;
// }
//
// @Override
// public int getItemCount() {
// return mDataset.size();
// }
//
// public static class ViewHolder extends RecyclerView.ViewHolder {
// private BeaconView mCell;
//
// public ViewHolder(BeaconView v) {
// super(v);
// mCell = v;
// }
//
// public BeaconView getCell() {
// return mCell;
// }
// }
//
//
// }
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.accengage.samples.beacons.Beacon;
import com.accengage.samples.beacons.BeaconAdapter;
import com.accengage.samples.beacons.R;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.Constants;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
package com.accengage.samples.beacons.activities;
public class MainActivity extends Activity {
private static final int LOCATION_REQUEST = 1;
private RecyclerView mBeaconList;
|
private BeaconAdapter mBeaconAdapter;
|
Accengage/accengage-android-sdk-samples
|
AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/Beacon.java
// public class Beacon {
//
// private String mId;
// private String mUuid;
// private int mMajor;
// private int mMinor;
// private int mTransition;
// private int mPower;
// private double mDistance;
// private String mAccuracy;
// private int mRssi;
// private Date mDate;
//
// public String getInternalId() {
// return mUuid + String.valueOf(mMajor) + String.valueOf(mMinor);
// }
//
// public String getId() {
// return mId;
// }
//
// public void setId(String id) {
// mId = id;
// }
//
// public String getUuid() {
// return mUuid;
// }
//
// public void setUuid(String uuid) {
// mUuid = uuid;
// }
//
// public int getMajor() {
// return mMajor;
// }
//
// public void setMajor(int major) {
// mMajor = major;
// }
//
// public int getMinor() {
// return mMinor;
// }
//
// public void setMinor(int minor) {
// mMinor = minor;
// }
//
// public int getTransition() {
// return mTransition;
// }
//
// public void setTransition(int transition) {
// mTransition = transition;
// }
//
// public int getPower() {
// return mPower;
// }
//
// public void setPower(int power) {
// mPower = power;
// }
//
// public double getDistance() {
// return mDistance;
// }
//
// public void setDistance(double distance) {
// mDistance = distance;
// }
//
// public String getAccuracy() {
// return mAccuracy;
// }
//
// public void setAccuracy(String accuracy) {
// mAccuracy = accuracy;
// }
//
// public int getRssi() {
// return mRssi;
// }
//
// public void setRssi(int rssi) {
// mRssi = rssi;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public void setDate(Date date) {
// mDate = date;
// }
//
// public static Beacon fromBundle(Bundle bundle) {
// Beacon beacon = new Beacon();
// beacon.setId(bundle.getString("id"));
// beacon.setUuid(bundle.getString("uuid"));
// beacon.setMajor(bundle.getInt("maj"));
// beacon.setMinor(bundle.getInt("min"));
// beacon.setTransition(bundle.getInt("transition"));
// beacon.setPower(bundle.getInt("power"));
// beacon.setDistance(bundle.getDouble("dist"));
// beacon.setAccuracy(bundle.getString("acc"));
// beacon.setRssi(bundle.getInt("rssi"));
// beacon.setDate(new Date(bundle.getLong("date")));
// return beacon;
// }
// }
//
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconAdapter.java
// public class BeaconAdapter extends RecyclerView.Adapter<BeaconAdapter.ViewHolder> {
//
// private LinkedHashMap<String, Beacon> mDataset;
//
// public BeaconAdapter(LinkedHashMap<String, Beacon> dataset) {
// mDataset = dataset;
// }
//
// @Override
// public BeaconAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// return new ViewHolder(new BeaconView(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(BeaconAdapter.ViewHolder holder, int position) {
// holder.getCell().bind(getItem(position));
// }
//
// private Beacon getItem(int position) {
// return mDataset.get(getItemKey(position));
// }
//
// private String getItemKey(int position) {
// Set<String> keys = mDataset.keySet();
// int i = 0;
// for (String key : keys) {
// if (i == position) {
// return key;
// }
// i++;
// }
// return null;
// }
//
// @Override
// public int getItemCount() {
// return mDataset.size();
// }
//
// public static class ViewHolder extends RecyclerView.ViewHolder {
// private BeaconView mCell;
//
// public ViewHolder(BeaconView v) {
// super(v);
// mCell = v;
// }
//
// public BeaconView getCell() {
// return mCell;
// }
// }
//
//
// }
|
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.accengage.samples.beacons.Beacon;
import com.accengage.samples.beacons.BeaconAdapter;
import com.accengage.samples.beacons.R;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.Constants;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
|
package com.accengage.samples.beacons.activities;
public class MainActivity extends Activity {
private static final int LOCATION_REQUEST = 1;
private RecyclerView mBeaconList;
private BeaconAdapter mBeaconAdapter;
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/Beacon.java
// public class Beacon {
//
// private String mId;
// private String mUuid;
// private int mMajor;
// private int mMinor;
// private int mTransition;
// private int mPower;
// private double mDistance;
// private String mAccuracy;
// private int mRssi;
// private Date mDate;
//
// public String getInternalId() {
// return mUuid + String.valueOf(mMajor) + String.valueOf(mMinor);
// }
//
// public String getId() {
// return mId;
// }
//
// public void setId(String id) {
// mId = id;
// }
//
// public String getUuid() {
// return mUuid;
// }
//
// public void setUuid(String uuid) {
// mUuid = uuid;
// }
//
// public int getMajor() {
// return mMajor;
// }
//
// public void setMajor(int major) {
// mMajor = major;
// }
//
// public int getMinor() {
// return mMinor;
// }
//
// public void setMinor(int minor) {
// mMinor = minor;
// }
//
// public int getTransition() {
// return mTransition;
// }
//
// public void setTransition(int transition) {
// mTransition = transition;
// }
//
// public int getPower() {
// return mPower;
// }
//
// public void setPower(int power) {
// mPower = power;
// }
//
// public double getDistance() {
// return mDistance;
// }
//
// public void setDistance(double distance) {
// mDistance = distance;
// }
//
// public String getAccuracy() {
// return mAccuracy;
// }
//
// public void setAccuracy(String accuracy) {
// mAccuracy = accuracy;
// }
//
// public int getRssi() {
// return mRssi;
// }
//
// public void setRssi(int rssi) {
// mRssi = rssi;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public void setDate(Date date) {
// mDate = date;
// }
//
// public static Beacon fromBundle(Bundle bundle) {
// Beacon beacon = new Beacon();
// beacon.setId(bundle.getString("id"));
// beacon.setUuid(bundle.getString("uuid"));
// beacon.setMajor(bundle.getInt("maj"));
// beacon.setMinor(bundle.getInt("min"));
// beacon.setTransition(bundle.getInt("transition"));
// beacon.setPower(bundle.getInt("power"));
// beacon.setDistance(bundle.getDouble("dist"));
// beacon.setAccuracy(bundle.getString("acc"));
// beacon.setRssi(bundle.getInt("rssi"));
// beacon.setDate(new Date(bundle.getLong("date")));
// return beacon;
// }
// }
//
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconAdapter.java
// public class BeaconAdapter extends RecyclerView.Adapter<BeaconAdapter.ViewHolder> {
//
// private LinkedHashMap<String, Beacon> mDataset;
//
// public BeaconAdapter(LinkedHashMap<String, Beacon> dataset) {
// mDataset = dataset;
// }
//
// @Override
// public BeaconAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// return new ViewHolder(new BeaconView(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(BeaconAdapter.ViewHolder holder, int position) {
// holder.getCell().bind(getItem(position));
// }
//
// private Beacon getItem(int position) {
// return mDataset.get(getItemKey(position));
// }
//
// private String getItemKey(int position) {
// Set<String> keys = mDataset.keySet();
// int i = 0;
// for (String key : keys) {
// if (i == position) {
// return key;
// }
// i++;
// }
// return null;
// }
//
// @Override
// public int getItemCount() {
// return mDataset.size();
// }
//
// public static class ViewHolder extends RecyclerView.ViewHolder {
// private BeaconView mCell;
//
// public ViewHolder(BeaconView v) {
// super(v);
// mCell = v;
// }
//
// public BeaconView getCell() {
// return mCell;
// }
// }
//
//
// }
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.accengage.samples.beacons.Beacon;
import com.accengage.samples.beacons.BeaconAdapter;
import com.accengage.samples.beacons.R;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.Constants;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
package com.accengage.samples.beacons.activities;
public class MainActivity extends Activity {
private static final int LOCATION_REQUEST = 1;
private RecyclerView mBeaconList;
private BeaconAdapter mBeaconAdapter;
|
private LinkedHashMap<String, Beacon> mBeacons = new LinkedHashMap<>();
|
Accengage/accengage-android-sdk-samples
|
AccCustomInApps/app/src/main/java/com/accengage/samples/custominapps/MainActivity.java
|
// Path: AccCustomInApps/app/src/main/java/com/accengage/samples/custominapps/customviews/CustomInAppLayout.java
// public class CustomInAppLayout extends LinearLayout {
//
// protected InApp mInApp;
//
// public CustomInAppLayout(Context context) {
// super(context);
// }
//
// public CustomInAppLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// public CustomInAppLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// public void populate(InApp inApp) {
// mInApp = inApp;
// }
// }
|
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.accengage.samples.custominapps.customviews.CustomInAppLayout;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.InApp;
import com.ad4screen.sdk.Log;
import com.ad4screen.sdk.Tag;
|
getA4S().setView("BannerDown");
break;
case BANNER_OFFER:
getA4S().setView("BannerOffer");
break;
case BANNER_OFFER_PROMOCODE:
getA4S().setView("BannerOfferPromo");
break;
case POPUP_BASIC:
getA4S().setView("PopupBasic");
break;
case POPUP_OFFER:
getA4S().setView("PopupOffer");
break;
case POPUP_PROMOCODE:
getA4S().setView("PopupPromo");
break;
}
}
});
}
@Override
protected void onResume() {
super.onResume();
// Initialize callback in onResume because stopActivity reinitialize callbacks
getA4S().setInAppInflatedCallback(new A4S.Callback<InApp>() {
@Override
public void onResult(InApp inapp) {
|
// Path: AccCustomInApps/app/src/main/java/com/accengage/samples/custominapps/customviews/CustomInAppLayout.java
// public class CustomInAppLayout extends LinearLayout {
//
// protected InApp mInApp;
//
// public CustomInAppLayout(Context context) {
// super(context);
// }
//
// public CustomInAppLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// public CustomInAppLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// public void populate(InApp inApp) {
// mInApp = inApp;
// }
// }
// Path: AccCustomInApps/app/src/main/java/com/accengage/samples/custominapps/MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.accengage.samples.custominapps.customviews.CustomInAppLayout;
import com.ad4screen.sdk.A4S;
import com.ad4screen.sdk.InApp;
import com.ad4screen.sdk.Log;
import com.ad4screen.sdk.Tag;
getA4S().setView("BannerDown");
break;
case BANNER_OFFER:
getA4S().setView("BannerOffer");
break;
case BANNER_OFFER_PROMOCODE:
getA4S().setView("BannerOfferPromo");
break;
case POPUP_BASIC:
getA4S().setView("PopupBasic");
break;
case POPUP_OFFER:
getA4S().setView("PopupOffer");
break;
case POPUP_PROMOCODE:
getA4S().setView("PopupPromo");
break;
}
}
});
}
@Override
protected void onResume() {
super.onResume();
// Initialize callback in onResume because stopActivity reinitialize callbacks
getA4S().setInAppInflatedCallback(new A4S.Callback<InApp>() {
@Override
public void onResult(InApp inapp) {
|
CustomInAppLayout customView = AccengageCustomViewFactory.create(MainActivity.this, inapp.getDisplayTemplate());
|
Accengage/accengage-android-sdk-samples
|
AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconReceiver.java
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
// public class MainActivity extends Activity {
//
// private static final int LOCATION_REQUEST = 1;
//
// private RecyclerView mBeaconList;
// private BeaconAdapter mBeaconAdapter;
// private LinkedHashMap<String, Beacon> mBeacons = new LinkedHashMap<>();
//
// private BroadcastReceiver mReceiver = new BroadcastReceiver() {
//
// @Override
// public void onReceive(Context context, Intent intent) {
// Bundle payload = intent.getExtras();
// if (payload == null) {
// return;
// }
//
// Bundle beacons = payload.getBundle(Constants.EXTRA_BEACON_PAYLOAD);
// if (beacons == null) {
// return;
// }
//
// List<Beacon> beaconsList = fromBundle(beacons);
// for (Beacon beacon : beaconsList) {
// mBeacons.put(beacon.getInternalId(), beacon);
// }
// mBeaconAdapter.notifyDataSetChanged();
// }
//
// private List<Beacon> fromBundle(Bundle beaconsBundle) {
// List<Beacon> beacons = new ArrayList<>();
// Set<String> triggeredBeacons = beaconsBundle.keySet();
// for (String beaconId : triggeredBeacons) {
// Bundle beaconDetails = beaconsBundle.getBundle(beaconId);
// if (beaconDetails != null) {
// beacons.add(Beacon.fromBundle(beaconDetails));
// }
// }
// return beacons;
// }
// };
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// A4S.get(this).setPushNotificationLocked(false);
// setContentView(R.layout.activity_beacon);
//
// // Request location permission for beacons features
// if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST);
// }
//
// mBeaconList = findViewById(R.id.listBeacons);
// mBeaconList.setHasFixedSize(true);
// mBeaconList.setLayoutManager(new LinearLayoutManager(this));
// mBeaconList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
// mBeaconAdapter = new BeaconAdapter(mBeacons);
// mBeaconList.setAdapter(mBeaconAdapter);
//
// findViewById(R.id.buttonClearBeacons).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// mBeacons.clear();
// mBeaconAdapter.notifyDataSetChanged();
// }
// });
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// listenBeacons();
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// unlistenBeacons();
// }
//
// private void listenBeacons() {
// IntentFilter filter = new IntentFilter(Constants.ACTION_TRIGGER);
// filter.addCategory(Constants.CATEGORY_BEACON_NOTIFICATIONS);
// registerReceiver(mReceiver, filter);
// }
//
// private void unlistenBeacons() {
// unregisterReceiver(mReceiver);
// }
//
// }
|
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.accengage.samples.beacons.activities.MainActivity;
import com.ad4screen.sdk.Constants;
import java.util.Set;
|
package com.accengage.samples.beacons;
public class BeaconReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
|
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/activities/MainActivity.java
// public class MainActivity extends Activity {
//
// private static final int LOCATION_REQUEST = 1;
//
// private RecyclerView mBeaconList;
// private BeaconAdapter mBeaconAdapter;
// private LinkedHashMap<String, Beacon> mBeacons = new LinkedHashMap<>();
//
// private BroadcastReceiver mReceiver = new BroadcastReceiver() {
//
// @Override
// public void onReceive(Context context, Intent intent) {
// Bundle payload = intent.getExtras();
// if (payload == null) {
// return;
// }
//
// Bundle beacons = payload.getBundle(Constants.EXTRA_BEACON_PAYLOAD);
// if (beacons == null) {
// return;
// }
//
// List<Beacon> beaconsList = fromBundle(beacons);
// for (Beacon beacon : beaconsList) {
// mBeacons.put(beacon.getInternalId(), beacon);
// }
// mBeaconAdapter.notifyDataSetChanged();
// }
//
// private List<Beacon> fromBundle(Bundle beaconsBundle) {
// List<Beacon> beacons = new ArrayList<>();
// Set<String> triggeredBeacons = beaconsBundle.keySet();
// for (String beaconId : triggeredBeacons) {
// Bundle beaconDetails = beaconsBundle.getBundle(beaconId);
// if (beaconDetails != null) {
// beacons.add(Beacon.fromBundle(beaconDetails));
// }
// }
// return beacons;
// }
// };
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// A4S.get(this).setPushNotificationLocked(false);
// setContentView(R.layout.activity_beacon);
//
// // Request location permission for beacons features
// if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST);
// }
//
// mBeaconList = findViewById(R.id.listBeacons);
// mBeaconList.setHasFixedSize(true);
// mBeaconList.setLayoutManager(new LinearLayoutManager(this));
// mBeaconList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
// mBeaconAdapter = new BeaconAdapter(mBeacons);
// mBeaconList.setAdapter(mBeaconAdapter);
//
// findViewById(R.id.buttonClearBeacons).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// mBeacons.clear();
// mBeaconAdapter.notifyDataSetChanged();
// }
// });
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// listenBeacons();
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// unlistenBeacons();
// }
//
// private void listenBeacons() {
// IntentFilter filter = new IntentFilter(Constants.ACTION_TRIGGER);
// filter.addCategory(Constants.CATEGORY_BEACON_NOTIFICATIONS);
// registerReceiver(mReceiver, filter);
// }
//
// private void unlistenBeacons() {
// unregisterReceiver(mReceiver);
// }
//
// }
// Path: AccBeacons/app/src/main/java/com/accengage/samples/beacons/BeaconReceiver.java
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.accengage.samples.beacons.activities.MainActivity;
import com.ad4screen.sdk.Constants;
import java.util.Set;
package com.accengage.samples.beacons;
public class BeaconReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
|
Intent notifIntent = new Intent(context, MainActivity.class);
|
Accengage/accengage-android-sdk-samples
|
AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
// public class DBPreferencesActivity extends Activity {
//
// public static final String KEY_PREFERENCE_ID = "key_preference_id";
// public static final String DBVIEW_PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + ".dbview_preferences";
//
// public static final int GEOFENCE_PREFERENCES = 0;
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// int preferenceId = getIntent().getIntExtra(KEY_PREFERENCE_ID, GEOFENCE_PREFERENCES);
// if (preferenceId == GEOFENCE_PREFERENCES) {
// // Display geofence preferences fragment
// getFragmentManager().beginTransaction()
// .replace(android.R.id.content, new GeofencePreferencesFragment())
// .commit();
// }
// }
//
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static class GeofencePreferencesFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// //PreferenceManager.setDefaultValues(getActivity(), R.xml.geofence_dbview_settings, false);
// getPreferenceManager().setSharedPreferencesName(DBVIEW_PREFERENCES_FILE_NAME);
//
// addPreferencesFromResource(R.xml.geofence_dbview_settings);
// }
// }
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import com.accengage.samples.geofences.activities.DBPreferencesActivity;
import com.google.android.gms.maps.model.Circle;
|
package com.accengage.samples.geofences;
public class Utils {
public static int _ID = 0;
public static int SERVER_ID = 1;
public static int EXTERNAL_ID = 2;
public static int NAME = 3;
public static int LATITUDE = 4;
public static int LONGITUDE = 5;
public static int RADIUS = 6;
public static int DETECTED_TIME = 7;
public static int NOTIFIED_TIME = 8;
public static int DETECTED_COUNT = 9;
public static int DEVICE_LATITUDE = 10;
public static int DEVICE_LONGITUDE = 11;
public static int DISTANCE = 12;
/**
* Checks in the SharedPreferences how you chose the geofences to be displayed
* @param context
* @return selected option as a keyword
*/
public static String getGeofenceSortingField(Context context) {
SharedPreferences preferences = context.getSharedPreferences(
|
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/activities/DBPreferencesActivity.java
// public class DBPreferencesActivity extends Activity {
//
// public static final String KEY_PREFERENCE_ID = "key_preference_id";
// public static final String DBVIEW_PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + ".dbview_preferences";
//
// public static final int GEOFENCE_PREFERENCES = 0;
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// int preferenceId = getIntent().getIntExtra(KEY_PREFERENCE_ID, GEOFENCE_PREFERENCES);
// if (preferenceId == GEOFENCE_PREFERENCES) {
// // Display geofence preferences fragment
// getFragmentManager().beginTransaction()
// .replace(android.R.id.content, new GeofencePreferencesFragment())
// .commit();
// }
// }
//
//
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public static class GeofencePreferencesFragment extends PreferenceFragment {
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// //PreferenceManager.setDefaultValues(getActivity(), R.xml.geofence_dbview_settings, false);
// getPreferenceManager().setSharedPreferencesName(DBVIEW_PREFERENCES_FILE_NAME);
//
// addPreferencesFromResource(R.xml.geofence_dbview_settings);
// }
// }
// }
// Path: AccGeofences/app/src/main/java/com/accengage/samples/geofences/Utils.java
import android.content.Context;
import android.content.SharedPreferences;
import com.accengage.samples.geofences.activities.DBPreferencesActivity;
import com.google.android.gms.maps.model.Circle;
package com.accengage.samples.geofences;
public class Utils {
public static int _ID = 0;
public static int SERVER_ID = 1;
public static int EXTERNAL_ID = 2;
public static int NAME = 3;
public static int LATITUDE = 4;
public static int LONGITUDE = 5;
public static int RADIUS = 6;
public static int DETECTED_TIME = 7;
public static int NOTIFIED_TIME = 8;
public static int DETECTED_COUNT = 9;
public static int DEVICE_LATITUDE = 10;
public static int DEVICE_LONGITUDE = 11;
public static int DISTANCE = 12;
/**
* Checks in the SharedPreferences how you chose the geofences to be displayed
* @param context
* @return selected option as a keyword
*/
public static String getGeofenceSortingField(Context context) {
SharedPreferences preferences = context.getSharedPreferences(
|
DBPreferencesActivity.DBVIEW_PREFERENCES_FILE_NAME,
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/Modules.java
|
// Path: java/com/asaskevich/smartcursor/api/IModule.java
// public interface IModule {
// public String getModuleName();
// public String getAuthor();
// }
//
// Path: java/com/asaskevich/smartcursor/api/ModuleConnector.java
// public class ModuleConnector
// extends Event {
// public static final int ENTITY_PROCESSOR = 0, PLAYER_PROCESSOR = 1, DROP_PROCESSOR = 2, BLOCK_PROCESSOR = 3;
// private IModule module;
// private int type;
//
// public ModuleConnector(IEntityProcessor module) {
// this.module = module;
// this.type = ENTITY_PROCESSOR;
// }
//
// public ModuleConnector(IPlayerProcessor module) {
// this.module = module;
// this.type = PLAYER_PROCESSOR;
// }
//
// public ModuleConnector(IDropProcessor module) {
// this.module = module;
// this.type = DROP_PROCESSOR;
// }
//
// public ModuleConnector(IBlockProcessor module) {
// this.module = module;
// this.type = BLOCK_PROCESSOR;
// }
//
// public IModule getModule() {
// return this.module;
// }
//
// public int getType() {
// return this.type;
// }
//
// public static void connectModule(IEntityProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IPlayerProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IDropProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IBlockProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.api.IModule;
import com.asaskevich.smartcursor.api.IPlayerProcessor;
import com.asaskevich.smartcursor.api.ModuleConnector;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
public static void switchModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
boolean status = moduleStatus.get(canonicalName);
moduleStatus.put(canonicalName, !status);
syncConfig(SmartCursor.config);
}
public static boolean isActiveModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
return moduleStatus.containsKey(canonicalName) && moduleStatus.get(canonicalName);
}
public static void syncConfig(Configuration config) {
config.load();
for (String key : moduleStatus.keySet()) {
boolean status = isActiveModule(key);
config.get("modules", key, status).set(status);
}
config.save();
}
public static void loadConfig(Configuration config) {
for (String key : moduleStatus.keySet()) {
boolean status = config.getBoolean(key, "modules", true, key);
moduleStatus.put(key, status);
}
}
@SubscribeEvent
|
// Path: java/com/asaskevich/smartcursor/api/IModule.java
// public interface IModule {
// public String getModuleName();
// public String getAuthor();
// }
//
// Path: java/com/asaskevich/smartcursor/api/ModuleConnector.java
// public class ModuleConnector
// extends Event {
// public static final int ENTITY_PROCESSOR = 0, PLAYER_PROCESSOR = 1, DROP_PROCESSOR = 2, BLOCK_PROCESSOR = 3;
// private IModule module;
// private int type;
//
// public ModuleConnector(IEntityProcessor module) {
// this.module = module;
// this.type = ENTITY_PROCESSOR;
// }
//
// public ModuleConnector(IPlayerProcessor module) {
// this.module = module;
// this.type = PLAYER_PROCESSOR;
// }
//
// public ModuleConnector(IDropProcessor module) {
// this.module = module;
// this.type = DROP_PROCESSOR;
// }
//
// public ModuleConnector(IBlockProcessor module) {
// this.module = module;
// this.type = BLOCK_PROCESSOR;
// }
//
// public IModule getModule() {
// return this.module;
// }
//
// public int getType() {
// return this.type;
// }
//
// public static void connectModule(IEntityProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IPlayerProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IDropProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IBlockProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
// }
// Path: java/com/asaskevich/smartcursor/Modules.java
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.api.IModule;
import com.asaskevich.smartcursor.api.IPlayerProcessor;
import com.asaskevich.smartcursor.api.ModuleConnector;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public static void switchModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
boolean status = moduleStatus.get(canonicalName);
moduleStatus.put(canonicalName, !status);
syncConfig(SmartCursor.config);
}
public static boolean isActiveModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
return moduleStatus.containsKey(canonicalName) && moduleStatus.get(canonicalName);
}
public static void syncConfig(Configuration config) {
config.load();
for (String key : moduleStatus.keySet()) {
boolean status = isActiveModule(key);
config.get("modules", key, status).set(status);
}
config.save();
}
public static void loadConfig(Configuration config) {
for (String key : moduleStatus.keySet()) {
boolean status = config.getBoolean(key, "modules", true, key);
moduleStatus.put(key, status);
}
}
@SubscribeEvent
|
public void onRegisterModule(ModuleConnector event) {
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/Modules.java
|
// Path: java/com/asaskevich/smartcursor/api/IModule.java
// public interface IModule {
// public String getModuleName();
// public String getAuthor();
// }
//
// Path: java/com/asaskevich/smartcursor/api/ModuleConnector.java
// public class ModuleConnector
// extends Event {
// public static final int ENTITY_PROCESSOR = 0, PLAYER_PROCESSOR = 1, DROP_PROCESSOR = 2, BLOCK_PROCESSOR = 3;
// private IModule module;
// private int type;
//
// public ModuleConnector(IEntityProcessor module) {
// this.module = module;
// this.type = ENTITY_PROCESSOR;
// }
//
// public ModuleConnector(IPlayerProcessor module) {
// this.module = module;
// this.type = PLAYER_PROCESSOR;
// }
//
// public ModuleConnector(IDropProcessor module) {
// this.module = module;
// this.type = DROP_PROCESSOR;
// }
//
// public ModuleConnector(IBlockProcessor module) {
// this.module = module;
// this.type = BLOCK_PROCESSOR;
// }
//
// public IModule getModule() {
// return this.module;
// }
//
// public int getType() {
// return this.type;
// }
//
// public static void connectModule(IEntityProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IPlayerProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IDropProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IBlockProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.api.IModule;
import com.asaskevich.smartcursor.api.IPlayerProcessor;
import com.asaskevich.smartcursor.api.ModuleConnector;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
public static void switchModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
boolean status = moduleStatus.get(canonicalName);
moduleStatus.put(canonicalName, !status);
syncConfig(SmartCursor.config);
}
public static boolean isActiveModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
return moduleStatus.containsKey(canonicalName) && moduleStatus.get(canonicalName);
}
public static void syncConfig(Configuration config) {
config.load();
for (String key : moduleStatus.keySet()) {
boolean status = isActiveModule(key);
config.get("modules", key, status).set(status);
}
config.save();
}
public static void loadConfig(Configuration config) {
for (String key : moduleStatus.keySet()) {
boolean status = config.getBoolean(key, "modules", true, key);
moduleStatus.put(key, status);
}
}
@SubscribeEvent
public void onRegisterModule(ModuleConnector event) {
|
// Path: java/com/asaskevich/smartcursor/api/IModule.java
// public interface IModule {
// public String getModuleName();
// public String getAuthor();
// }
//
// Path: java/com/asaskevich/smartcursor/api/ModuleConnector.java
// public class ModuleConnector
// extends Event {
// public static final int ENTITY_PROCESSOR = 0, PLAYER_PROCESSOR = 1, DROP_PROCESSOR = 2, BLOCK_PROCESSOR = 3;
// private IModule module;
// private int type;
//
// public ModuleConnector(IEntityProcessor module) {
// this.module = module;
// this.type = ENTITY_PROCESSOR;
// }
//
// public ModuleConnector(IPlayerProcessor module) {
// this.module = module;
// this.type = PLAYER_PROCESSOR;
// }
//
// public ModuleConnector(IDropProcessor module) {
// this.module = module;
// this.type = DROP_PROCESSOR;
// }
//
// public ModuleConnector(IBlockProcessor module) {
// this.module = module;
// this.type = BLOCK_PROCESSOR;
// }
//
// public IModule getModule() {
// return this.module;
// }
//
// public int getType() {
// return this.type;
// }
//
// public static void connectModule(IEntityProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IPlayerProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IDropProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
//
// public static void connectModule(IBlockProcessor module) {
// MinecraftForge.EVENT_BUS.post(new ModuleConnector(module));
// }
// }
// Path: java/com/asaskevich/smartcursor/Modules.java
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.api.IModule;
import com.asaskevich.smartcursor.api.IPlayerProcessor;
import com.asaskevich.smartcursor.api.ModuleConnector;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public static void switchModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
boolean status = moduleStatus.get(canonicalName);
moduleStatus.put(canonicalName, !status);
syncConfig(SmartCursor.config);
}
public static boolean isActiveModule(String canonicalName) {
if (!moduleStatus.containsKey(canonicalName)) moduleStatus.put(canonicalName, true);
return moduleStatus.containsKey(canonicalName) && moduleStatus.get(canonicalName);
}
public static void syncConfig(Configuration config) {
config.load();
for (String key : moduleStatus.keySet()) {
boolean status = isActiveModule(key);
config.get("modules", key, status).set(status);
}
config.save();
}
public static void loadConfig(Configuration config) {
for (String key : moduleStatus.keySet()) {
boolean status = config.getBoolean(key, "modules", true, key);
moduleStatus.put(key, status);
}
}
@SubscribeEvent
public void onRegisterModule(ModuleConnector event) {
|
IModule module = event.getModule();
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/modules/drop/ItemModIdentificationModule.java
|
// Path: java/com/asaskevich/smartcursor/utils/ModIdentification.java
// public class ModIdentification {
//
//
// @SuppressWarnings("deprecation")
// public static String nameFromStack(ItemStack stack) {
// try {
// ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem()));
// String modname = mod == null ? "Minecraft" : mod.getName();
// return modname;
// } catch (NullPointerException e) {
// return "";
// }
// }
//
// }
|
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.utils.ModIdentification;
|
package com.asaskevich.smartcursor.modules.drop;
public class ItemModIdentificationModule
implements IDropProcessor {
@Override
public String getModuleName() {
return "Mod Identification for Blocks";
}
@Override
public String getAuthor() {
return "modmuss50";
}
@Override
public void process(List<String> list, ItemStack stack) {
|
// Path: java/com/asaskevich/smartcursor/utils/ModIdentification.java
// public class ModIdentification {
//
//
// @SuppressWarnings("deprecation")
// public static String nameFromStack(ItemStack stack) {
// try {
// ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem()));
// String modname = mod == null ? "Minecraft" : mod.getName();
// return modname;
// } catch (NullPointerException e) {
// return "";
// }
// }
//
// }
// Path: java/com/asaskevich/smartcursor/modules/drop/ItemModIdentificationModule.java
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import com.asaskevich.smartcursor.api.IDropProcessor;
import com.asaskevich.smartcursor.utils.ModIdentification;
package com.asaskevich.smartcursor.modules.drop;
public class ItemModIdentificationModule
implements IDropProcessor {
@Override
public String getModuleName() {
return "Mod Identification for Blocks";
}
@Override
public String getAuthor() {
return "modmuss50";
}
@Override
public void process(List<String> list, ItemStack stack) {
|
list.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.ITALIC + ModIdentification.nameFromStack(stack) + EnumChatFormatting.RESET);
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/utils/UpdateManager.java
|
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
|
import java.io.DataInputStream;
import java.io.InputStream;
import java.net.URL;
import net.minecraft.event.ClickEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
package com.asaskevich.smartcursor.utils;
public class UpdateManager {
public PlayerEvent.PlayerLoggedInEvent event;
@SubscribeEvent
public void onEnterWorld(PlayerEvent.PlayerLoggedInEvent event) {
this.event = event;
new Thread() {
public void run() {
try {
String page = makeRequest("https://mods.io/mods/1089-smartcursor");
int l = page.indexOf("<td><strong>");
if (l < 0) throw new Exception("");
int r = page.indexOf("</strong>", l + 10);
if (r < 0) throw new Exception("");
|
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
// Path: java/com/asaskevich/smartcursor/utils/UpdateManager.java
import java.io.DataInputStream;
import java.io.InputStream;
import java.net.URL;
import net.minecraft.event.ClickEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
package com.asaskevich.smartcursor.utils;
public class UpdateManager {
public PlayerEvent.PlayerLoggedInEvent event;
@SubscribeEvent
public void onEnterWorld(PlayerEvent.PlayerLoggedInEvent event) {
this.event = event;
new Thread() {
public void run() {
try {
String page = makeRequest("https://mods.io/mods/1089-smartcursor");
int l = page.indexOf("<td><strong>");
if (l < 0) throw new Exception("");
int r = page.indexOf("</strong>", l + 10);
if (r < 0) throw new Exception("");
|
String localVersion = ModInfo.VERSION;
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/modules/entity/EntityHorseModule.java
|
// Path: java/com/asaskevich/smartcursor/utils/Utils.java
// public class Utils {
// public static double round(double value, int places) {
// BigDecimal bd = new BigDecimal(value);
// bd = bd.setScale(places, RoundingMode.HALF_UP);
// return bd.doubleValue();
// }
//
// public static NBTTagCompound convertEntityToNbt(Entity entity) {
// NBTTagCompound tag = new NBTTagCompound();
// entity.writeToNBT(tag);
// return tag;
// }
//
// public static void getPoisons(Entity entity) {
// try {
// NBTTagCompound tag = convertEntityToNbt(entity);
// NBTTagList list = (NBTTagList) tag.getTag("ActiveEffects");
// System.out.println("Tag count: " + list.tagCount());
// } catch (Exception e) {}
// }
// }
|
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.util.StatCollector;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.utils.Utils;
|
package com.asaskevich.smartcursor.modules.entity;
public class EntityHorseModule
implements IEntityProcessor {
@Override
public void process(List<String> list, Entity entity) {
if (entity instanceof EntityHorse) {
EntityHorse horse = (EntityHorse) entity;
|
// Path: java/com/asaskevich/smartcursor/utils/Utils.java
// public class Utils {
// public static double round(double value, int places) {
// BigDecimal bd = new BigDecimal(value);
// bd = bd.setScale(places, RoundingMode.HALF_UP);
// return bd.doubleValue();
// }
//
// public static NBTTagCompound convertEntityToNbt(Entity entity) {
// NBTTagCompound tag = new NBTTagCompound();
// entity.writeToNBT(tag);
// return tag;
// }
//
// public static void getPoisons(Entity entity) {
// try {
// NBTTagCompound tag = convertEntityToNbt(entity);
// NBTTagList list = (NBTTagList) tag.getTag("ActiveEffects");
// System.out.println("Tag count: " + list.tagCount());
// } catch (Exception e) {}
// }
// }
// Path: java/com/asaskevich/smartcursor/modules/entity/EntityHorseModule.java
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.util.StatCollector;
import com.asaskevich.smartcursor.api.IEntityProcessor;
import com.asaskevich.smartcursor.utils.Utils;
package com.asaskevich.smartcursor.modules.entity;
public class EntityHorseModule
implements IEntityProcessor {
@Override
public void process(List<String> list, Entity entity) {
if (entity instanceof EntityHorse) {
EntityHorse horse = (EntityHorse) entity;
|
list.add(StatCollector.translateToLocal("smartcursor.mob.jumpStrength") + String.format("%.3f", Utils.round(horse.getHorseJumpStrength(), 4)));
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/modules/block/BlockModIdentificatorModule.java
|
// Path: java/com/asaskevich/smartcursor/utils/ModIdentification.java
// public class ModIdentification {
//
//
// @SuppressWarnings("deprecation")
// public static String nameFromStack(ItemStack stack) {
// try {
// ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem()));
// String modname = mod == null ? "Minecraft" : mod.getName();
// return modname;
// } catch (NullPointerException e) {
// return "";
// }
// }
//
// }
|
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.utils.ModIdentification;
|
package com.asaskevich.smartcursor.modules.block;
public class BlockModIdentificatorModule
implements IBlockProcessor {
@Override
public String getModuleName() {
return "Mod Identification for Blocks";
}
@Override
public String getAuthor() {
return "modmuss50";
}
@Override
public void process(List<String> list, Block block, int meta, World theWorld, int blockX, int blockY, int blockZ) {
Item item = block.getItem(theWorld, blockX, blockY, blockZ);
ItemStack stack = new ItemStack(block);
if (item != null) stack = new ItemStack(block.getItem(theWorld, blockX, blockY, blockZ));
|
// Path: java/com/asaskevich/smartcursor/utils/ModIdentification.java
// public class ModIdentification {
//
//
// @SuppressWarnings("deprecation")
// public static String nameFromStack(ItemStack stack) {
// try {
// ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem()));
// String modname = mod == null ? "Minecraft" : mod.getName();
// return modname;
// } catch (NullPointerException e) {
// return "";
// }
// }
//
// }
// Path: java/com/asaskevich/smartcursor/modules/block/BlockModIdentificatorModule.java
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import com.asaskevich.smartcursor.api.IBlockProcessor;
import com.asaskevich.smartcursor.utils.ModIdentification;
package com.asaskevich.smartcursor.modules.block;
public class BlockModIdentificatorModule
implements IBlockProcessor {
@Override
public String getModuleName() {
return "Mod Identification for Blocks";
}
@Override
public String getAuthor() {
return "modmuss50";
}
@Override
public void process(List<String> list, Block block, int meta, World theWorld, int blockX, int blockY, int blockZ) {
Item item = block.getItem(theWorld, blockX, blockY, blockZ);
ItemStack stack = new ItemStack(block);
if (item != null) stack = new ItemStack(block.getItem(theWorld, blockX, blockY, blockZ));
|
list.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.ITALIC + ModIdentification.nameFromStack(stack) + EnumChatFormatting.RESET);
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/gui/ConfigGUI.java
|
// Path: java/com/asaskevich/smartcursor/SmartCursor.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, canBeDeactivated = true, guiFactory = "com.asaskevich.smartcursor.gui.GUIFactory")
// @SideOnly(Side.CLIENT)
// public class SmartCursor {
// public static CommonProxy proxy;
// public static RenderHandler renderHandler;
// public static KeyInputHandler keyInputHandler;
// public static Minecraft mc;
// public static Configuration config;
// @Mod.Instance(ModInfo.ID)
// public static SmartCursor instance;
//
// @EventHandler
// public static void preInit(FMLPreInitializationEvent event) {
// // Init
// config = new Configuration(event.getSuggestedConfigurationFile());
// Setting.syncConfig(config);
// mc = Minecraft.getMinecraft();
// renderHandler = new RenderHandler(mc);
// keyInputHandler = new KeyInputHandler(renderHandler);
// KeyBindler.init();
// // Register handlers
// MinecraftForge.EVENT_BUS.register(renderHandler);
// MinecraftForge.EVENT_BUS.register(new Modules());
// FMLCommonHandler.instance().bus().register(new UpdateManager());
// FMLCommonHandler.instance().bus().register(keyInputHandler);
// FMLCommonHandler.instance().bus().register(instance);
// // Register build-in plugins
// Plugins.init();
// Modules.loadConfig(config);
// }
//
// @EventHandler
// public static void init(FMLInitializationEvent event) {}
//
// @EventHandler
// public static void postInit(FMLPostInitializationEvent event) {}
//
// @SubscribeEvent
// public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
// if (eventArgs.modID.equals(ModInfo.ID)) Setting.syncConfig(config);
// }
// }
//
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
|
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.SmartCursor;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.client.config.GuiConfig;
|
package com.asaskevich.smartcursor.gui;
public class ConfigGUI
extends GuiConfig {
@SuppressWarnings({ "rawtypes", "unchecked" })
public ConfigGUI(GuiScreen parent) {
|
// Path: java/com/asaskevich/smartcursor/SmartCursor.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, canBeDeactivated = true, guiFactory = "com.asaskevich.smartcursor.gui.GUIFactory")
// @SideOnly(Side.CLIENT)
// public class SmartCursor {
// public static CommonProxy proxy;
// public static RenderHandler renderHandler;
// public static KeyInputHandler keyInputHandler;
// public static Minecraft mc;
// public static Configuration config;
// @Mod.Instance(ModInfo.ID)
// public static SmartCursor instance;
//
// @EventHandler
// public static void preInit(FMLPreInitializationEvent event) {
// // Init
// config = new Configuration(event.getSuggestedConfigurationFile());
// Setting.syncConfig(config);
// mc = Minecraft.getMinecraft();
// renderHandler = new RenderHandler(mc);
// keyInputHandler = new KeyInputHandler(renderHandler);
// KeyBindler.init();
// // Register handlers
// MinecraftForge.EVENT_BUS.register(renderHandler);
// MinecraftForge.EVENT_BUS.register(new Modules());
// FMLCommonHandler.instance().bus().register(new UpdateManager());
// FMLCommonHandler.instance().bus().register(keyInputHandler);
// FMLCommonHandler.instance().bus().register(instance);
// // Register build-in plugins
// Plugins.init();
// Modules.loadConfig(config);
// }
//
// @EventHandler
// public static void init(FMLInitializationEvent event) {}
//
// @EventHandler
// public static void postInit(FMLPostInitializationEvent event) {}
//
// @SubscribeEvent
// public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
// if (eventArgs.modID.equals(ModInfo.ID)) Setting.syncConfig(config);
// }
// }
//
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
// Path: java/com/asaskevich/smartcursor/gui/ConfigGUI.java
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.SmartCursor;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.client.config.GuiConfig;
package com.asaskevich.smartcursor.gui;
public class ConfigGUI
extends GuiConfig {
@SuppressWarnings({ "rawtypes", "unchecked" })
public ConfigGUI(GuiScreen parent) {
|
super(parent, new ConfigElement(SmartCursor.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), ModInfo.ID, false, false, GuiConfig.getAbridgedConfigPath(SmartCursor.config.toString()));
|
asaskevich/SmartCursor
|
java/com/asaskevich/smartcursor/gui/ConfigGUI.java
|
// Path: java/com/asaskevich/smartcursor/SmartCursor.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, canBeDeactivated = true, guiFactory = "com.asaskevich.smartcursor.gui.GUIFactory")
// @SideOnly(Side.CLIENT)
// public class SmartCursor {
// public static CommonProxy proxy;
// public static RenderHandler renderHandler;
// public static KeyInputHandler keyInputHandler;
// public static Minecraft mc;
// public static Configuration config;
// @Mod.Instance(ModInfo.ID)
// public static SmartCursor instance;
//
// @EventHandler
// public static void preInit(FMLPreInitializationEvent event) {
// // Init
// config = new Configuration(event.getSuggestedConfigurationFile());
// Setting.syncConfig(config);
// mc = Minecraft.getMinecraft();
// renderHandler = new RenderHandler(mc);
// keyInputHandler = new KeyInputHandler(renderHandler);
// KeyBindler.init();
// // Register handlers
// MinecraftForge.EVENT_BUS.register(renderHandler);
// MinecraftForge.EVENT_BUS.register(new Modules());
// FMLCommonHandler.instance().bus().register(new UpdateManager());
// FMLCommonHandler.instance().bus().register(keyInputHandler);
// FMLCommonHandler.instance().bus().register(instance);
// // Register build-in plugins
// Plugins.init();
// Modules.loadConfig(config);
// }
//
// @EventHandler
// public static void init(FMLInitializationEvent event) {}
//
// @EventHandler
// public static void postInit(FMLPostInitializationEvent event) {}
//
// @SubscribeEvent
// public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
// if (eventArgs.modID.equals(ModInfo.ID)) Setting.syncConfig(config);
// }
// }
//
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
|
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.SmartCursor;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.client.config.GuiConfig;
|
package com.asaskevich.smartcursor.gui;
public class ConfigGUI
extends GuiConfig {
@SuppressWarnings({ "rawtypes", "unchecked" })
public ConfigGUI(GuiScreen parent) {
|
// Path: java/com/asaskevich/smartcursor/SmartCursor.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, canBeDeactivated = true, guiFactory = "com.asaskevich.smartcursor.gui.GUIFactory")
// @SideOnly(Side.CLIENT)
// public class SmartCursor {
// public static CommonProxy proxy;
// public static RenderHandler renderHandler;
// public static KeyInputHandler keyInputHandler;
// public static Minecraft mc;
// public static Configuration config;
// @Mod.Instance(ModInfo.ID)
// public static SmartCursor instance;
//
// @EventHandler
// public static void preInit(FMLPreInitializationEvent event) {
// // Init
// config = new Configuration(event.getSuggestedConfigurationFile());
// Setting.syncConfig(config);
// mc = Minecraft.getMinecraft();
// renderHandler = new RenderHandler(mc);
// keyInputHandler = new KeyInputHandler(renderHandler);
// KeyBindler.init();
// // Register handlers
// MinecraftForge.EVENT_BUS.register(renderHandler);
// MinecraftForge.EVENT_BUS.register(new Modules());
// FMLCommonHandler.instance().bus().register(new UpdateManager());
// FMLCommonHandler.instance().bus().register(keyInputHandler);
// FMLCommonHandler.instance().bus().register(instance);
// // Register build-in plugins
// Plugins.init();
// Modules.loadConfig(config);
// }
//
// @EventHandler
// public static void init(FMLInitializationEvent event) {}
//
// @EventHandler
// public static void postInit(FMLPostInitializationEvent event) {}
//
// @SubscribeEvent
// public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
// if (eventArgs.modID.equals(ModInfo.ID)) Setting.syncConfig(config);
// }
// }
//
// Path: java/com/asaskevich/smartcursor/mod/ModInfo.java
// public class ModInfo {
// public static final String ID = "SmartCursor";
// public static final String NAME = ID;
// public static final String VERSION = "1.4.5";
// public static final String AUTHOR = "Alex Saskevich";
// public static final String PROXY_LOCATION = "com.asaskevich.smartcursor.proxy";
// }
// Path: java/com/asaskevich/smartcursor/gui/ConfigGUI.java
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import com.asaskevich.smartcursor.SmartCursor;
import com.asaskevich.smartcursor.mod.ModInfo;
import cpw.mods.fml.client.config.GuiConfig;
package com.asaskevich.smartcursor.gui;
public class ConfigGUI
extends GuiConfig {
@SuppressWarnings({ "rawtypes", "unchecked" })
public ConfigGUI(GuiScreen parent) {
|
super(parent, new ConfigElement(SmartCursor.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), ModInfo.ID, false, false, GuiConfig.getAbridgedConfigPath(SmartCursor.config.toString()));
|
Keavon/Picasso
|
src/Game/Scripts/BallMovement.java
|
// Path: src/Game/Scenes/menu.java
// public class menu extends Scene {
// public void Load(PicassoEngine engine) {
// // Play game in goFullscreen
// Application.goFullscreen();
// Application.showCursor();
//
// // Add sky
// setSky(new Sky("assets/images/sky.jpg"));
// Camera camera = new Camera(new Vector3());
// camera.addScript(new MenuCamera(camera, this, engine));
// addGameObject(camera);
// setActiveCamera(camera);
// }
// }
|
import Game.Scenes.*;
import Game.Scenes.menu;
import PicassoEngine.*;
|
super(gameObject);
this.levelNumber = levelNumber;
this.engine = engine;
this.scene = scene;
this.cameraFollow = cameraFollow;
this.viewResetAngle = viewResetAngle;
RigidBody ball = (RigidBody) gameObject;
ball.addForce(movementForce);
}
public void Update() {
double angle = cameraFollow.getOrbitAngle();
Vector3 force = new Vector3();
if (Input.getKey("W")) {
force.add(new Vector3(Math.cos(angle * Math.PI / 180), 0, Math.sin(angle * Math.PI / 180)));
}
if (Input.getKey("S")) {
force.add(new Vector3(Math.cos((angle + 180) * Math.PI / 180), 0, Math.sin((angle + 180) * Math.PI / 180)));
}
if (Input.getKey("A")) {
force.add(new Vector3(Math.cos((angle + 90) * Math.PI / 180), 0, Math.sin((angle + 90) * Math.PI / 180)));
}
if (Input.getKey("D")) {
force.add(new Vector3(Math.cos((angle - 90) * Math.PI / 180), 0, Math.sin((angle - 90) * Math.PI / 180)));
}
movementForce.set(force.getScaled(5));
// Exit game with escape key
if (Input.getKey("Escape")) {
|
// Path: src/Game/Scenes/menu.java
// public class menu extends Scene {
// public void Load(PicassoEngine engine) {
// // Play game in goFullscreen
// Application.goFullscreen();
// Application.showCursor();
//
// // Add sky
// setSky(new Sky("assets/images/sky.jpg"));
// Camera camera = new Camera(new Vector3());
// camera.addScript(new MenuCamera(camera, this, engine));
// addGameObject(camera);
// setActiveCamera(camera);
// }
// }
// Path: src/Game/Scripts/BallMovement.java
import Game.Scenes.*;
import Game.Scenes.menu;
import PicassoEngine.*;
super(gameObject);
this.levelNumber = levelNumber;
this.engine = engine;
this.scene = scene;
this.cameraFollow = cameraFollow;
this.viewResetAngle = viewResetAngle;
RigidBody ball = (RigidBody) gameObject;
ball.addForce(movementForce);
}
public void Update() {
double angle = cameraFollow.getOrbitAngle();
Vector3 force = new Vector3();
if (Input.getKey("W")) {
force.add(new Vector3(Math.cos(angle * Math.PI / 180), 0, Math.sin(angle * Math.PI / 180)));
}
if (Input.getKey("S")) {
force.add(new Vector3(Math.cos((angle + 180) * Math.PI / 180), 0, Math.sin((angle + 180) * Math.PI / 180)));
}
if (Input.getKey("A")) {
force.add(new Vector3(Math.cos((angle + 90) * Math.PI / 180), 0, Math.sin((angle + 90) * Math.PI / 180)));
}
if (Input.getKey("D")) {
force.add(new Vector3(Math.cos((angle - 90) * Math.PI / 180), 0, Math.sin((angle - 90) * Math.PI / 180)));
}
movementForce.set(force.getScaled(5));
// Exit game with escape key
if (Input.getKey("Escape")) {
|
engine.loadScene(new menu());
|
kakao/hbase-tools
|
hbase0.98/hbase-table-stat-0.98/src/test/java/com/kakao/hbase/stat/TableStatRegexTest.java
|
// Path: hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/Level.java
// public class Level implements Comparable<Level> {
// private final Object level;
//
// public Level(Object level) {
// this.level = level;
// }
//
// @Override
// public String toString() {
// if (level instanceof RegionName) {
// return ((RegionName) level).name();
// } else if (level instanceof ServerName) {
// return ((ServerName) level).getServerName();
// } else if (level instanceof TableName) {
// return ((TableName) level).getTableName();
// } else {
// return level.toString();
// }
// }
//
// @SuppressWarnings("NullableProblems")
// @Override
// public int compareTo(Level thatLevel) {
// if (thatLevel == null) {
// return 1;
// }
// if (level instanceof RegionName) {
// return ((RegionName) level).compareTo((RegionName) thatLevel.level);
// } else if (level instanceof ServerName) {
// return ((ServerName) level).compareTo((ServerName) thatLevel.level);
// } else if (level instanceof TableName) {
// return ((TableName) level).compareTo((TableName) thatLevel.level);
// } else if (level instanceof String) {
// return ((String) level).compareTo((String) thatLevel.level);
// } else
// throw new RuntimeException("can not compareTo");
// }
//
// public boolean equalsName(String name) {
// if (name == null) return false;
//
// if (level instanceof RegionName) {
// return ((RegionName) level).name().equals(name);
// } else if (level instanceof ServerName) {
// return ((ServerName) level).getServerName().equals(name);
// } else if (level instanceof TableName) {
// return ((TableName) level).getTableName().equals(name);
// } else if (level instanceof String) {
// return level.equals(name);
// } else
// throw new RuntimeException("can not equalsName");
// }
// }
|
import com.kakao.hbase.stat.load.Level;
import org.junit.Assert;
import org.junit.Test;
import java.util.Set;
import static org.junit.Assert.assertEquals;
|
String tableNameRegex = tableName + ".*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0", "--rs"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("RegionServer", command.getLoad().getLevelClass().getLevelTypeString());
}
@Test
public void testRegexTableNameWithRegion() throws Exception {
String tableNameRegex = tableName + ".*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0", "--region"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("Region (RS Index)", command.getLoad().getLevelClass().getLevelTypeString());
}
@Test
public void testRegexTableName() throws Exception {
String tableName2 = createAdditionalTable(tableName + "2");
String tableName3 = createAdditionalTable(tableName + "22");
String tableNameRegex = tableName + "2.*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("Table", command.getLoad().getLevelClass().getLevelTypeString());
Assert.assertEquals(2, command.getLoad().getLoadMap().size());
|
// Path: hbase0.98/hbase-table-stat-0.98/src/main/java/com/kakao/hbase/stat/load/Level.java
// public class Level implements Comparable<Level> {
// private final Object level;
//
// public Level(Object level) {
// this.level = level;
// }
//
// @Override
// public String toString() {
// if (level instanceof RegionName) {
// return ((RegionName) level).name();
// } else if (level instanceof ServerName) {
// return ((ServerName) level).getServerName();
// } else if (level instanceof TableName) {
// return ((TableName) level).getTableName();
// } else {
// return level.toString();
// }
// }
//
// @SuppressWarnings("NullableProblems")
// @Override
// public int compareTo(Level thatLevel) {
// if (thatLevel == null) {
// return 1;
// }
// if (level instanceof RegionName) {
// return ((RegionName) level).compareTo((RegionName) thatLevel.level);
// } else if (level instanceof ServerName) {
// return ((ServerName) level).compareTo((ServerName) thatLevel.level);
// } else if (level instanceof TableName) {
// return ((TableName) level).compareTo((TableName) thatLevel.level);
// } else if (level instanceof String) {
// return ((String) level).compareTo((String) thatLevel.level);
// } else
// throw new RuntimeException("can not compareTo");
// }
//
// public boolean equalsName(String name) {
// if (name == null) return false;
//
// if (level instanceof RegionName) {
// return ((RegionName) level).name().equals(name);
// } else if (level instanceof ServerName) {
// return ((ServerName) level).getServerName().equals(name);
// } else if (level instanceof TableName) {
// return ((TableName) level).getTableName().equals(name);
// } else if (level instanceof String) {
// return level.equals(name);
// } else
// throw new RuntimeException("can not equalsName");
// }
// }
// Path: hbase0.98/hbase-table-stat-0.98/src/test/java/com/kakao/hbase/stat/TableStatRegexTest.java
import com.kakao.hbase.stat.load.Level;
import org.junit.Assert;
import org.junit.Test;
import java.util.Set;
import static org.junit.Assert.assertEquals;
String tableNameRegex = tableName + ".*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0", "--rs"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("RegionServer", command.getLoad().getLevelClass().getLevelTypeString());
}
@Test
public void testRegexTableNameWithRegion() throws Exception {
String tableNameRegex = tableName + ".*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0", "--region"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("Region (RS Index)", command.getLoad().getLevelClass().getLevelTypeString());
}
@Test
public void testRegexTableName() throws Exception {
String tableName2 = createAdditionalTable(tableName + "2");
String tableName3 = createAdditionalTable(tableName + "22");
String tableNameRegex = tableName + "2.*";
String[] args = {"zookeeper", tableNameRegex, "--interval=0"};
TableStat command = new TableStat(admin, new StatArgs(args));
command.run();
Assert.assertEquals("Table", command.getLoad().getLevelClass().getLevelTypeString());
Assert.assertEquals(2, command.getLoad().getLoadMap().size());
|
Set<Level> levelSet = command.getLoad().getLoadMap().keySet();
|
kakao/hbase-tools
|
hbase0.98/hbase-common-0.98/src/test/java/com/kakao/hbase/common/util/UtilTest.java
|
// Path: hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/Constant.java
// public class Constant {
// public static final Charset CHARSET = StandardCharsets.UTF_8;
// public static final long WAIT_INTERVAL_MS = 1000;
// public static final long LARGE_WAIT_INTERVAL_MS = 60000;
// public static final long SMALL_WAIT_INTERVAL_MS = 3000;
// public static final int TRY_MAX = 20;
// public static final int TRY_MAX_SMALL = 3;
// public static final String TABLE_DELIMITER = ",";
// public static final String MESSAGE_CANNOT_MOVE = "Can not move region";
// public static final String MESSAGE_DISABLED_OR_NOT_FOUND_TABLE = "Disabled or not found table";
// public static final String MESSAGE_NEED_REFRESH = "need refresh";
// public static final String UNIT_TEST_TABLE_PREFIX = "UNIT_TEST_";
// public static final String MESSAGE_INVALID_DATE_FORMAT = "Invalid date format";
// public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// public static final SimpleDateFormat DATE_FORMAT_ARGS = new SimpleDateFormat("yyyyMMddHHmmss");
//
// private Constant() {
// }
// }
|
import com.kakao.hbase.common.Constant;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
|
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.common.util;
public class UtilTest {
@Test
public void testParseTimestamp() throws Exception {
try {
Util.parseTimestamp("0");
Assert.fail();
} catch (IllegalArgumentException e) {
|
// Path: hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/Constant.java
// public class Constant {
// public static final Charset CHARSET = StandardCharsets.UTF_8;
// public static final long WAIT_INTERVAL_MS = 1000;
// public static final long LARGE_WAIT_INTERVAL_MS = 60000;
// public static final long SMALL_WAIT_INTERVAL_MS = 3000;
// public static final int TRY_MAX = 20;
// public static final int TRY_MAX_SMALL = 3;
// public static final String TABLE_DELIMITER = ",";
// public static final String MESSAGE_CANNOT_MOVE = "Can not move region";
// public static final String MESSAGE_DISABLED_OR_NOT_FOUND_TABLE = "Disabled or not found table";
// public static final String MESSAGE_NEED_REFRESH = "need refresh";
// public static final String UNIT_TEST_TABLE_PREFIX = "UNIT_TEST_";
// public static final String MESSAGE_INVALID_DATE_FORMAT = "Invalid date format";
// public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// public static final SimpleDateFormat DATE_FORMAT_ARGS = new SimpleDateFormat("yyyyMMddHHmmss");
//
// private Constant() {
// }
// }
// Path: hbase0.98/hbase-common-0.98/src/test/java/com/kakao/hbase/common/util/UtilTest.java
import com.kakao.hbase.common.Constant;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.common.util;
public class UtilTest {
@Test
public void testParseTimestamp() throws Exception {
try {
Util.parseTimestamp("0");
Assert.fail();
} catch (IllegalArgumentException e) {
|
if (!e.getMessage().contains(Constant.MESSAGE_INVALID_DATE_FORMAT)) {
|
kakao/hbase-tools
|
hbase0.98/hbase-table-stat-0.98/src/test/java/com/kakao/hbase/stat/ArgsTest.java
|
// Path: hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/InvalidTableException.java
// public class InvalidTableException extends IOException {
// public InvalidTableException(String message) {
// super(message);
// }
// }
|
import com.kakao.hbase.common.InvalidTableException;
import joptsimple.OptionException;
import org.apache.hadoop.hbase.*;
import org.junit.Assert;
import org.junit.Test;
|
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.stat;
public class ArgsTest extends StatTestBase {
public ArgsTest() {
super(ArgsTest.class);
}
@Test
public void testDisabledTable() throws Exception {
admin.disableTable(tableName);
try {
validateTable(admin, tableName);
|
// Path: hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/InvalidTableException.java
// public class InvalidTableException extends IOException {
// public InvalidTableException(String message) {
// super(message);
// }
// }
// Path: hbase0.98/hbase-table-stat-0.98/src/test/java/com/kakao/hbase/stat/ArgsTest.java
import com.kakao.hbase.common.InvalidTableException;
import joptsimple.OptionException;
import org.apache.hadoop.hbase.*;
import org.junit.Assert;
import org.junit.Test;
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.stat;
public class ArgsTest extends StatTestBase {
public ArgsTest() {
super(ArgsTest.class);
}
@Test
public void testDisabledTable() throws Exception {
admin.disableTable(tableName);
try {
validateTable(admin, tableName);
|
} catch (InvalidTableException e) {
|
kakao/hbase-tools
|
hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/LoadEntry.java
|
// Path: hbase1.2/hbase-common-1.2/src/main/java/com/kakao/hbase/specific/RegionLoadDelegator.java
// public class RegionLoadDelegator {
// private final org.apache.hadoop.hbase.RegionLoad regionLoad;
//
// public RegionLoadDelegator(org.apache.hadoop.hbase.RegionLoad regionLoad) {
// this.regionLoad = regionLoad;
// }
//
// public static LoadEntry[] loadEntries() {
// return LoadEntry.values();
// }
//
// public int getStorefiles() {
// return regionLoad.getStorefiles();
// }
//
// public int getStoreUncompressedSizeMB() {
// return regionLoad.getStoreUncompressedSizeMB();
// }
//
// public int getStorefileSizeMB() {
// return regionLoad.getStorefileSizeMB();
// }
//
// public long getReadRequestsCount() {
// return regionLoad.getReadRequestsCount();
// }
//
// public long getWriteRequestsCount() {
// return regionLoad.getWriteRequestsCount();
// }
//
// public int getMemStoreSizeMB() {
// return regionLoad.getMemStoreSizeMB();
// }
//
// public long getCurrentCompactedKVs() {
// return regionLoad.getCurrentCompactedKVs();
// }
//
// public int getRegions() {
// return 1;
// }
//
// public float getDataLocality() {
// return regionLoad.getDataLocality();
// }
// }
|
import com.kakao.hbase.specific.RegionLoadDelegator;
import org.apache.hadoop.util.StringUtils;
|
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.common;
public enum LoadEntry {
Reads {
@Override
|
// Path: hbase1.2/hbase-common-1.2/src/main/java/com/kakao/hbase/specific/RegionLoadDelegator.java
// public class RegionLoadDelegator {
// private final org.apache.hadoop.hbase.RegionLoad regionLoad;
//
// public RegionLoadDelegator(org.apache.hadoop.hbase.RegionLoad regionLoad) {
// this.regionLoad = regionLoad;
// }
//
// public static LoadEntry[] loadEntries() {
// return LoadEntry.values();
// }
//
// public int getStorefiles() {
// return regionLoad.getStorefiles();
// }
//
// public int getStoreUncompressedSizeMB() {
// return regionLoad.getStoreUncompressedSizeMB();
// }
//
// public int getStorefileSizeMB() {
// return regionLoad.getStorefileSizeMB();
// }
//
// public long getReadRequestsCount() {
// return regionLoad.getReadRequestsCount();
// }
//
// public long getWriteRequestsCount() {
// return regionLoad.getWriteRequestsCount();
// }
//
// public int getMemStoreSizeMB() {
// return regionLoad.getMemStoreSizeMB();
// }
//
// public long getCurrentCompactedKVs() {
// return regionLoad.getCurrentCompactedKVs();
// }
//
// public int getRegions() {
// return 1;
// }
//
// public float getDataLocality() {
// return regionLoad.getDataLocality();
// }
// }
// Path: hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/LoadEntry.java
import com.kakao.hbase.specific.RegionLoadDelegator;
import org.apache.hadoop.util.StringUtils;
/*
* Copyright 2015 Kakao Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kakao.hbase.common;
public enum LoadEntry {
Reads {
@Override
|
public Number getValue(RegionLoadDelegator regionLoad) {
|
arantius/TiVo-Commander
|
src/com/arantius/tivocommander/SubscribeBase.java
|
// Path: src/com/arantius/tivocommander/rpc/request/Subscribe.java
// public class Subscribe extends MindRpcRequest {
// public Subscribe() {
// super("subscribe");
//
// mDataMap.put("bodyId", MindRpc.mTivoDevice.tsn);
// mDataMap.put("recordingQuality", "best");
// }
//
// public void setCollection(String collectionId, JsonNode channel, int max,
// String which, String subscriptionId) {
// HashMap<String, Object> idSetSource = new HashMap<String, Object>();
// idSetSource.put("channel", channel);
// idSetSource.put("collectionId", collectionId);
// idSetSource.put("type", "seasonPassSource");
// if (subscriptionId != null && !"".equals(subscriptionId)) {
// mDataMap.put("subscriptionId", subscriptionId);
// }
// mDataMap.put("idSetSource", idSetSource);
// mDataMap.put("maxRecordings", max);
// mDataMap.put("showStatus", which);
// }
//
// public void setIgnoreConflicts(boolean ignoreConflicts) {
// mDataMap.put("ignoreConflicts", ignoreConflicts);
// }
//
// public void setKeepUntil(String behavior) {
// mDataMap.put("keepBehavior", behavior);
// }
//
// public void setOffer(String offerId, String contentId) {
// HashMap<String, String> idSetSource = new HashMap<String, String>();
// idSetSource.put("contentId", contentId);
// idSetSource.put("offerId", offerId);
// idSetSource.put("type", "singleOfferSource");
// mDataMap.put("idSetSource", idSetSource);
// }
//
// public void setPadding(Integer start, Integer stop) {
// if (start != 0) {
// mDataMap.put("startTimePadding", start);
// }
// if (stop != 0) {
// mDataMap.put("endTimePadding", stop);
// }
// }
//
// public void setPriority(Integer priority) {
// if (priority > 0) {
// mDataMap.put("priority", priority);
// }
// }
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.arantius.tivocommander.rpc.request.Subscribe;
|
pos = ((Spinner) findViewById(R.id.start)).getSelectedItemPosition();
mPaddingStart = mStartStopValues[pos];
pos = ((Spinner) findViewById(R.id.stop)).getSelectedItemPosition();
mPaddingStop = mStartStopValues[pos];
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Utils.activateHomeButton(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return Utils.onOptionsItemSelected(item, this, true);
}
protected void setUpSpinner(int spinnerId, String[] labels) {
Spinner spinner = (Spinner) findViewById(spinnerId);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
labels);
adapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
|
// Path: src/com/arantius/tivocommander/rpc/request/Subscribe.java
// public class Subscribe extends MindRpcRequest {
// public Subscribe() {
// super("subscribe");
//
// mDataMap.put("bodyId", MindRpc.mTivoDevice.tsn);
// mDataMap.put("recordingQuality", "best");
// }
//
// public void setCollection(String collectionId, JsonNode channel, int max,
// String which, String subscriptionId) {
// HashMap<String, Object> idSetSource = new HashMap<String, Object>();
// idSetSource.put("channel", channel);
// idSetSource.put("collectionId", collectionId);
// idSetSource.put("type", "seasonPassSource");
// if (subscriptionId != null && !"".equals(subscriptionId)) {
// mDataMap.put("subscriptionId", subscriptionId);
// }
// mDataMap.put("idSetSource", idSetSource);
// mDataMap.put("maxRecordings", max);
// mDataMap.put("showStatus", which);
// }
//
// public void setIgnoreConflicts(boolean ignoreConflicts) {
// mDataMap.put("ignoreConflicts", ignoreConflicts);
// }
//
// public void setKeepUntil(String behavior) {
// mDataMap.put("keepBehavior", behavior);
// }
//
// public void setOffer(String offerId, String contentId) {
// HashMap<String, String> idSetSource = new HashMap<String, String>();
// idSetSource.put("contentId", contentId);
// idSetSource.put("offerId", offerId);
// idSetSource.put("type", "singleOfferSource");
// mDataMap.put("idSetSource", idSetSource);
// }
//
// public void setPadding(Integer start, Integer stop) {
// if (start != 0) {
// mDataMap.put("startTimePadding", start);
// }
// if (stop != 0) {
// mDataMap.put("endTimePadding", stop);
// }
// }
//
// public void setPriority(Integer priority) {
// if (priority > 0) {
// mDataMap.put("priority", priority);
// }
// }
// }
// Path: src/com/arantius/tivocommander/SubscribeBase.java
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.arantius.tivocommander.rpc.request.Subscribe;
pos = ((Spinner) findViewById(R.id.start)).getSelectedItemPosition();
mPaddingStart = mStartStopValues[pos];
pos = ((Spinner) findViewById(R.id.stop)).getSelectedItemPosition();
mPaddingStop = mStartStopValues[pos];
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Utils.activateHomeButton(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return Utils.onOptionsItemSelected(item, this, true);
}
protected void setUpSpinner(int spinnerId, String[] labels) {
Spinner spinner = (Spinner) findViewById(spinnerId);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
labels);
adapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
|
protected void subscribeRequestCommon(Subscribe request) {
|
code4craft/hello-design-pattern
|
src/main/java/helloworld/creational/abstract_factory/JavaSplitHelloWorldFactory.java
|
// Path: src/main/java/helloworld/SplitHelloWorld.java
// public class SplitHelloWorld implements HelloWorld {
//
// private HelloWorldInterjection helloWorldInterjection;
//
// private HelloWorldObject helloWorldObject;
//
// private static final String separator = " ";
//
// private static final String terminator = "!";
//
// public SplitHelloWorld(HelloWorldInterjection helloWorldInterjection, HelloWorldObject helloWorldObject) {
// this.helloWorldInterjection = helloWorldInterjection;
// this.helloWorldObject = helloWorldObject;
// }
//
// @Override
// public String helloWorld() {
// return helloWorldInterjection.interjection() + separator + helloWorldObject.object() + terminator;
// }
//
// public interface HelloWorldInterjection {
//
// public String interjection();
// }
//
// public interface HelloWorldObject {
//
// public String object();
// }
//
// public static class DefaultInterjection implements HelloWorldInterjection {
//
// @Override
// public String interjection() {
// return "Hello";
// }
// }
//
// }
|
import helloworld.SplitHelloWorld;
|
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class JavaSplitHelloWorldFactory implements SplitHelloWorldFactory {
@Override
|
// Path: src/main/java/helloworld/SplitHelloWorld.java
// public class SplitHelloWorld implements HelloWorld {
//
// private HelloWorldInterjection helloWorldInterjection;
//
// private HelloWorldObject helloWorldObject;
//
// private static final String separator = " ";
//
// private static final String terminator = "!";
//
// public SplitHelloWorld(HelloWorldInterjection helloWorldInterjection, HelloWorldObject helloWorldObject) {
// this.helloWorldInterjection = helloWorldInterjection;
// this.helloWorldObject = helloWorldObject;
// }
//
// @Override
// public String helloWorld() {
// return helloWorldInterjection.interjection() + separator + helloWorldObject.object() + terminator;
// }
//
// public interface HelloWorldInterjection {
//
// public String interjection();
// }
//
// public interface HelloWorldObject {
//
// public String object();
// }
//
// public static class DefaultInterjection implements HelloWorldInterjection {
//
// @Override
// public String interjection() {
// return "Hello";
// }
// }
//
// }
// Path: src/main/java/helloworld/creational/abstract_factory/JavaSplitHelloWorldFactory.java
import helloworld.SplitHelloWorld;
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class JavaSplitHelloWorldFactory implements SplitHelloWorldFactory {
@Override
|
public SplitHelloWorld.HelloWorldInterjection createHelloWorldInterjection() {
|
code4craft/hello-design-pattern
|
src/test/java/helloworld/creational/abstract_factory/AbstractFactoryTest.java
|
// Path: src/main/java/helloworld/creational/abstract_factory/AbstractFactory.java
// public class AbstractFactory {
//
// public enum Type {
// Java, DesignPattern;
// }
//
// private static Map<Type, Class<? extends SplitHelloWorldFactory>> map;
//
// static {
// map = new HashMap<Type, Class<? extends SplitHelloWorldFactory>>();
// map.put(Type.Java, JavaSplitHelloWorldFactory.class);
// map.put(Type.DesignPattern, DesignPatternSplitHelloWorldFactory.class);
// }
//
// public static SplitHelloWorldFactory select(Type type) throws IllegalAccessException, InstantiationException {
// return map.get(type).newInstance();
// }
//
// }
//
// Path: src/main/java/helloworld/creational/abstract_factory/SplitHelloWorldFactory.java
// public interface SplitHelloWorldFactory {
//
// public SplitHelloWorld.HelloWorldInterjection createHelloWorldInterjection();
//
// public SplitHelloWorld.HelloWorldObject createHelloWorldObject();
// }
|
import helloworld.creational.abstract_factory.AbstractFactory;
import helloworld.creational.abstract_factory.SplitHelloWorldFactory;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
|
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class AbstractFactoryTest {
@Test
public void testHelloWorld() throws InstantiationException, IllegalAccessException {
|
// Path: src/main/java/helloworld/creational/abstract_factory/AbstractFactory.java
// public class AbstractFactory {
//
// public enum Type {
// Java, DesignPattern;
// }
//
// private static Map<Type, Class<? extends SplitHelloWorldFactory>> map;
//
// static {
// map = new HashMap<Type, Class<? extends SplitHelloWorldFactory>>();
// map.put(Type.Java, JavaSplitHelloWorldFactory.class);
// map.put(Type.DesignPattern, DesignPatternSplitHelloWorldFactory.class);
// }
//
// public static SplitHelloWorldFactory select(Type type) throws IllegalAccessException, InstantiationException {
// return map.get(type).newInstance();
// }
//
// }
//
// Path: src/main/java/helloworld/creational/abstract_factory/SplitHelloWorldFactory.java
// public interface SplitHelloWorldFactory {
//
// public SplitHelloWorld.HelloWorldInterjection createHelloWorldInterjection();
//
// public SplitHelloWorld.HelloWorldObject createHelloWorldObject();
// }
// Path: src/test/java/helloworld/creational/abstract_factory/AbstractFactoryTest.java
import helloworld.creational.abstract_factory.AbstractFactory;
import helloworld.creational.abstract_factory.SplitHelloWorldFactory;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class AbstractFactoryTest {
@Test
public void testHelloWorld() throws InstantiationException, IllegalAccessException {
|
SplitHelloWorldFactory splitHelloWorldFactory = AbstractFactory.select(AbstractFactory.Type.Java);
|
code4craft/hello-design-pattern
|
src/test/java/helloworld/creational/abstract_factory/AbstractFactoryTest.java
|
// Path: src/main/java/helloworld/creational/abstract_factory/AbstractFactory.java
// public class AbstractFactory {
//
// public enum Type {
// Java, DesignPattern;
// }
//
// private static Map<Type, Class<? extends SplitHelloWorldFactory>> map;
//
// static {
// map = new HashMap<Type, Class<? extends SplitHelloWorldFactory>>();
// map.put(Type.Java, JavaSplitHelloWorldFactory.class);
// map.put(Type.DesignPattern, DesignPatternSplitHelloWorldFactory.class);
// }
//
// public static SplitHelloWorldFactory select(Type type) throws IllegalAccessException, InstantiationException {
// return map.get(type).newInstance();
// }
//
// }
//
// Path: src/main/java/helloworld/creational/abstract_factory/SplitHelloWorldFactory.java
// public interface SplitHelloWorldFactory {
//
// public SplitHelloWorld.HelloWorldInterjection createHelloWorldInterjection();
//
// public SplitHelloWorld.HelloWorldObject createHelloWorldObject();
// }
|
import helloworld.creational.abstract_factory.AbstractFactory;
import helloworld.creational.abstract_factory.SplitHelloWorldFactory;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
|
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class AbstractFactoryTest {
@Test
public void testHelloWorld() throws InstantiationException, IllegalAccessException {
|
// Path: src/main/java/helloworld/creational/abstract_factory/AbstractFactory.java
// public class AbstractFactory {
//
// public enum Type {
// Java, DesignPattern;
// }
//
// private static Map<Type, Class<? extends SplitHelloWorldFactory>> map;
//
// static {
// map = new HashMap<Type, Class<? extends SplitHelloWorldFactory>>();
// map.put(Type.Java, JavaSplitHelloWorldFactory.class);
// map.put(Type.DesignPattern, DesignPatternSplitHelloWorldFactory.class);
// }
//
// public static SplitHelloWorldFactory select(Type type) throws IllegalAccessException, InstantiationException {
// return map.get(type).newInstance();
// }
//
// }
//
// Path: src/main/java/helloworld/creational/abstract_factory/SplitHelloWorldFactory.java
// public interface SplitHelloWorldFactory {
//
// public SplitHelloWorld.HelloWorldInterjection createHelloWorldInterjection();
//
// public SplitHelloWorld.HelloWorldObject createHelloWorldObject();
// }
// Path: src/test/java/helloworld/creational/abstract_factory/AbstractFactoryTest.java
import helloworld.creational.abstract_factory.AbstractFactory;
import helloworld.creational.abstract_factory.SplitHelloWorldFactory;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
package helloworld.creational.abstract_factory;
/**
* @author yihua.huang@dianping.com
*/
public class AbstractFactoryTest {
@Test
public void testHelloWorld() throws InstantiationException, IllegalAccessException {
|
SplitHelloWorldFactory splitHelloWorldFactory = AbstractFactory.select(AbstractFactory.Type.Java);
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/interfaces/GDSSaver.java
|
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
|
import com.rc.gds.Key;
|
package com.rc.gds.interfaces;
public interface GDSSaver {
public abstract GDSSaver entity(Object pojo);
public abstract GDSSaver withSpecialID(String specialID);
/**
* This function will force the re-saving of any pojo that already have an ID set. Normal behaviour is for all new pojos (pojos with a
* blank ID) to be saved recursively, and all pojos that have an ID to be skipped as they are already saved. Not really recommended to
* use this function - you should rather save objects directly when you update them!
*
* Be very careful of cyclical links in your object graph - it will cause a stack overflow exception when setting this to true.
*
* @param recursiveUpdate
* @return
*/
public abstract GDSSaver forceRecursiveUpdate(boolean recursiveUpdate);
|
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
// Path: src/main/java/com/rc/gds/interfaces/GDSSaver.java
import com.rc.gds.Key;
package com.rc.gds.interfaces;
public interface GDSSaver {
public abstract GDSSaver entity(Object pojo);
public abstract GDSSaver withSpecialID(String specialID);
/**
* This function will force the re-saving of any pojo that already have an ID set. Normal behaviour is for all new pojos (pojos with a
* blank ID) to be saved recursively, and all pojos that have an ID to be skipped as they are already saved. Not really recommended to
* use this function - you should rather save objects directly when you update them!
*
* Be very careful of cyclical links in your object graph - it will cause a stack overflow exception when setting this to true.
*
* @param recursiveUpdate
* @return
*/
public abstract GDSSaver forceRecursiveUpdate(boolean recursiveUpdate);
|
public abstract Key now();
|
Ryan-ZA/async-elastic-orm
|
src/test/java/com/rc/gds/PerfTest.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
|
System.out.println("Done " + i);
}
System.out.println("testSaveRawMap ellapsed: " + (System.currentTimeMillis() - time));
}
@Test
public void testSaveGDSerial() {
long time = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
TestParent testParent = new TestParent();
testParent.name = "parent1";
getGDS().save().entity(testParent).now();
Assert.assertNotNull(testParent.id);
if (i % 1000 == 0)
System.out.println("Done " + i);
}
System.out.println("testSaveGDSerial ellapsed: " + (System.currentTimeMillis() - time));
}
@Test
public void testSaveGDSAsync() {
long time = System.currentTimeMillis();
// Can only do max 200 at a time because of 200 unit index queue default in ES
for (int j = 0; j < 100; j++) {
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
// Path: src/test/java/com/rc/gds/PerfTest.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
System.out.println("Done " + i);
}
System.out.println("testSaveRawMap ellapsed: " + (System.currentTimeMillis() - time));
}
@Test
public void testSaveGDSerial() {
long time = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
TestParent testParent = new TestParent();
testParent.name = "parent1";
getGDS().save().entity(testParent).now();
Assert.assertNotNull(testParent.id);
if (i % 1000 == 0)
System.out.println("Done " + i);
}
System.out.println("testSaveGDSerial ellapsed: " + (System.currentTimeMillis() - time));
}
@Test
public void testSaveGDSAsync() {
long time = System.currentTimeMillis();
// Can only do max 200 at a time because of 200 unit index queue default in ES
for (int j = 0; j < 100; j++) {
|
List<GDSResult<Key>> results = new ArrayList<>();
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/GDSClass.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
|
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.rc.gds.annotation.PostSave;
import com.rc.gds.annotation.PreDelete;
import com.rc.gds.annotation.PreSave;
import com.rc.gds.interfaces.GDS;
|
while (clazz != Object.class && clazz != null && !GDSField.nonDSClasses.contains(clazz) && !clazz.isPrimitive() && clazz != Class.class) {
Field[] classfields = clazz.getDeclaredFields();
try {
AccessibleObject.setAccessible(classfields, true);
} catch (Exception ex) {
//System.out.println("Error trying to setAccessible for class: " + clazz + " " + ex.toString());
}
for (Field field : classfields) {
if (GDSField.createIDField(field) != null) {
hasIdFieldMap.put(clazz, true);
return true;
}
}
clazz = clazz.getSuperclass();
}
hasIdFieldMap.put(originalClazz, false);
return false;
}
public static void makeConstructorsPublic(Class<?> clazz) {
Constructor<?>[] cons = clazz.getDeclaredConstructors();
try {
AccessibleObject.setAccessible(cons, true);
} catch (Exception ex) {
//System.out.println("Error trying to makeConstructorsPublic for class: " + clazz + " " + ex.toString());
}
}
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
// Path: src/main/java/com/rc/gds/GDSClass.java
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.rc.gds.annotation.PostSave;
import com.rc.gds.annotation.PreDelete;
import com.rc.gds.annotation.PreSave;
import com.rc.gds.interfaces.GDS;
while (clazz != Object.class && clazz != null && !GDSField.nonDSClasses.contains(clazz) && !clazz.isPrimitive() && clazz != Class.class) {
Field[] classfields = clazz.getDeclaredFields();
try {
AccessibleObject.setAccessible(classfields, true);
} catch (Exception ex) {
//System.out.println("Error trying to setAccessible for class: " + clazz + " " + ex.toString());
}
for (Field field : classfields) {
if (GDSField.createIDField(field) != null) {
hasIdFieldMap.put(clazz, true);
return true;
}
}
clazz = clazz.getSuperclass();
}
hasIdFieldMap.put(originalClazz, false);
return false;
}
public static void makeConstructorsPublic(Class<?> clazz) {
Constructor<?>[] cons = clazz.getDeclaredConstructors();
try {
AccessibleObject.setAccessible(cons, true);
} catch (Exception ex) {
//System.out.println("Error trying to makeConstructorsPublic for class: " + clazz + " " + ex.toString());
}
}
|
private static void callAnnotatedMethod(GDS gds, Class<? extends Annotation> annotation, Map<Class<?>, Method> annotationMap, Object pojo) throws IllegalAccessException,
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/interfaces/GDSLoader.java
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
|
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
|
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
// Path: src/main/java/com/rc/gds/interfaces/GDSLoader.java
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
|
public abstract void fetch(Key key, GDSCallback<Object> callback);
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/interfaces/GDSLoader.java
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
|
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
|
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
public abstract void fetch(Key key, GDSCallback<Object> callback);
/**
* Will fetch all pojos for keys.
*
* @param keys
* @return
* @throws ExecutionException
* @throws InterruptedException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
*/
public abstract void fetchBatch(Iterable<Key> keys, GDSCallback<Map<Key, Object>> callback) throws InterruptedException, ExecutionException, ClassNotFoundException,
InstantiationException, IllegalAccessException;
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
// Path: src/main/java/com/rc/gds/interfaces/GDSLoader.java
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
public abstract void fetch(Key key, GDSCallback<Object> callback);
/**
* Will fetch all pojos for keys.
*
* @param keys
* @return
* @throws ExecutionException
* @throws InterruptedException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
*/
public abstract void fetchBatch(Iterable<Key> keys, GDSCallback<Map<Key, Object>> callback) throws InterruptedException, ExecutionException, ClassNotFoundException,
InstantiationException, IllegalAccessException;
|
public abstract void fetchLinks(List<GDSLink> linksToFetch, GDSCallback<List<GDSLink>> callback) throws IllegalArgumentException, IllegalAccessException,
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/interfaces/GDSLoader.java
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
|
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
|
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
public abstract void fetch(Key key, GDSCallback<Object> callback);
/**
* Will fetch all pojos for keys.
*
* @param keys
* @return
* @throws ExecutionException
* @throws InterruptedException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
*/
public abstract void fetchBatch(Iterable<Key> keys, GDSCallback<Map<Key, Object>> callback) throws InterruptedException, ExecutionException, ClassNotFoundException,
InstantiationException, IllegalAccessException;
public abstract void fetchLinks(List<GDSLink> linksToFetch, GDSCallback<List<GDSLink>> callback) throws IllegalArgumentException, IllegalAccessException,
ClassNotFoundException,
InstantiationException, InterruptedException, ExecutionException;
/**
* Real logic for loading pojos from the datastore. Can be given a Entity or EmbeddedEntity, and if the entity is in the correct format
* you will get back a POJO.
*
* @param entity
* @param id
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InterruptedException
* @throws ExecutionException
*/
|
// Path: src/main/java/com/rc/gds/GDSLink.java
// public class GDSLink {
//
// Object pojo;
// Collection<Object> collection;
// GDSField gdsField;
// Key key;
// Collection<Key> keyCollection;
//
// public GDSLink(Object pojo, GDSField gdsField, Key key) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// this.key = key;
// }
//
// public GDSLink(Object pojo, GDSField gdsField, Collection<Key> keyIterable) {
// this.pojo = pojo;
// this.gdsField = gdsField;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Collection<Key> keyIterable) {
// this.collection = collection;
// keyCollection = keyIterable;
// }
//
// public GDSLink(Collection<Object> collection, Key key) {
// this.collection = collection;
// this.key = key;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
//
// Path: src/main/java/com/rc/gds/PropertyContainer.java
// public interface PropertyContainer {
//
// public void setProperty(String key, Object val);
//
// public void setUnindexedProperty(String key, Object val);
//
// public Map<String, Object> getDBDbObject();
//
// public Object getProperty(String key);
//
// public boolean hasProperty(String key);
//
// }
// Path: src/main/java/com/rc/gds/interfaces/GDSLoader.java
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.rc.gds.GDSLink;
import com.rc.gds.Key;
import com.rc.gds.PropertyContainer;
package com.rc.gds.interfaces;
public interface GDSLoader {
/**
* This will fetch a pojo of type clazz with specific id. This method is prefered over fetch(Key)
*
* @param clazz
* Class of the object to fetch. Should be the class itself if possible, but superclass or subclass of the object will work
* too.
* @param id
* Long id returned from a previous saved pojo
* @return
*/
public abstract <T> GDSResult<T> fetch(Class<T> clazz, String id);
/**
* Will fetch the pojo matching the key.
*
* @param key
* @return
*/
public abstract void fetch(Key key, GDSCallback<Object> callback);
/**
* Will fetch all pojos for keys.
*
* @param keys
* @return
* @throws ExecutionException
* @throws InterruptedException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
*/
public abstract void fetchBatch(Iterable<Key> keys, GDSCallback<Map<Key, Object>> callback) throws InterruptedException, ExecutionException, ClassNotFoundException,
InstantiationException, IllegalAccessException;
public abstract void fetchLinks(List<GDSLink> linksToFetch, GDSCallback<List<GDSLink>> callback) throws IllegalArgumentException, IllegalAccessException,
ClassNotFoundException,
InstantiationException, InterruptedException, ExecutionException;
/**
* Real logic for loading pojos from the datastore. Can be given a Entity or EmbeddedEntity, and if the entity is in the correct format
* you will get back a POJO.
*
* @param entity
* @param id
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InterruptedException
* @throws ExecutionException
*/
|
public abstract void entityToPOJO(PropertyContainer entity, String id, List<GDSLink> linksToFetch, GDSCallback<Object> callback) throws ClassNotFoundException,
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/GDSDeleterImpl.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSDeleter.java
// public interface GDSDeleter {
//
// public abstract GDSResult<Boolean> delete(Object o);
//
// public abstract GDSResult<Boolean> deleteAll(Iterable<?> iterable);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
|
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
import org.elasticsearch.index.query.QueryBuilders;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSDeleter;
import com.rc.gds.interfaces.GDSResult;
|
package com.rc.gds;
public class GDSDeleterImpl implements GDSDeleter {
GDS gds;
GDSDeleterImpl(GDS gds) {
this.gds = gds;
}
/*
* (non-Javadoc)
* @see com.rc.gds.GDSDeleter#delete(java.lang.Object)
*/
@Override
|
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSDeleter.java
// public interface GDSDeleter {
//
// public abstract GDSResult<Boolean> delete(Object o);
//
// public abstract GDSResult<Boolean> deleteAll(Iterable<?> iterable);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
// Path: src/main/java/com/rc/gds/GDSDeleterImpl.java
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
import org.elasticsearch.index.query.QueryBuilders;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSDeleter;
import com.rc.gds.interfaces.GDSResult;
package com.rc.gds;
public class GDSDeleterImpl implements GDSDeleter {
GDS gds;
GDSDeleterImpl(GDS gds) {
this.gds = gds;
}
/*
* (non-Javadoc)
* @see com.rc.gds.GDSDeleter#delete(java.lang.Object)
*/
@Override
|
public GDSResult<Boolean> delete(Object o) {
|
Ryan-ZA/async-elastic-orm
|
src/test/java/com/rc/gds/BasicTest.java
|
// Path: src/test/java/com/rc/gds/TestSubClass.java
// public static class TheSubClass {
//
// int i;
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.rc.gds.TestSubClass.TheSubClass;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
|
refreshIndex();
List<TestChild> list = getGDS().query(TestChild.class).asList();
Assert.assertEquals(1000, list.size());
//Assert.assertEquals("child12", list.get(12).name);
//Assert.assertEquals("child22", list.get(22).name);
}
@Test
public void testSave() {
TestParent testParent = new TestParent();
TestChild testChild = new TestChild();
testParent.name = "parent1";
testChild.name = "child1";
testParent.testChild = testChild;
getGDS().save().entity(testParent).now();
Assert.assertNotNull(testParent.id);
Assert.assertNotNull(testChild.id);
TestParent fetchParent = getGDS().load().fetch(TestParent.class, testParent.id).now();
Assert.assertEquals(testParent.name, fetchParent.name);
Assert.assertEquals(testParent.testChild.name, fetchParent.testChild.name);
}
@Test
public void testSubClass() {
TestSubClass test = new TestSubClass();
test.name = "parent";
|
// Path: src/test/java/com/rc/gds/TestSubClass.java
// public static class TheSubClass {
//
// int i;
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
// Path: src/test/java/com/rc/gds/BasicTest.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.rc.gds.TestSubClass.TheSubClass;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
refreshIndex();
List<TestChild> list = getGDS().query(TestChild.class).asList();
Assert.assertEquals(1000, list.size());
//Assert.assertEquals("child12", list.get(12).name);
//Assert.assertEquals("child22", list.get(22).name);
}
@Test
public void testSave() {
TestParent testParent = new TestParent();
TestChild testChild = new TestChild();
testParent.name = "parent1";
testChild.name = "child1";
testParent.testChild = testChild;
getGDS().save().entity(testParent).now();
Assert.assertNotNull(testParent.id);
Assert.assertNotNull(testChild.id);
TestParent fetchParent = getGDS().load().fetch(TestParent.class, testParent.id).now();
Assert.assertEquals(testParent.name, fetchParent.name);
Assert.assertEquals(testParent.testChild.name, fetchParent.testChild.name);
}
@Test
public void testSubClass() {
TestSubClass test = new TestSubClass();
test.name = "parent";
|
test.theSubClass = new TheSubClass();
|
Ryan-ZA/async-elastic-orm
|
src/test/java/com/rc/gds/BasicTest.java
|
// Path: src/test/java/com/rc/gds/TestSubClass.java
// public static class TheSubClass {
//
// int i;
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.rc.gds.TestSubClass.TheSubClass;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
|
testParentMap.name = "testParentList" + num;
testParentMap.testChildMap = new HashMap<String, TestChild>();
for (int i = 0; i < 10; i++) {
TestChild testChild = new TestChild();
testChild.name = "child" + i;
testParentMap.testChildMap.put("key " + i, testChild);
testParentMap.testChildMap.put("key2 " + i, testChild);
testParentMap.testChildMap.put("key3 " + i, testChild);
}
getGDS().save().entity(testParentMap).now();
Assert.assertNotNull(testParentMap.id);
for (TestChild testChild : testParentMap.testChildMap.values())
Assert.assertNotNull(testChild.id);
TestParentMap fetchParent = getGDS().load().fetch(TestParentMap.class, testParentMap.id).now();
Assert.assertEquals(30, fetchParent.testChildMap.size());
for (int i = 0; i < 10; i++) {
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key " + i).name);
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key2 " + i).name);
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key3 " + i).name);
}
}
@Test
public void testBatcher() {
TestParent testParent1 = new TestParent();
|
// Path: src/test/java/com/rc/gds/TestSubClass.java
// public static class TheSubClass {
//
// int i;
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
// public interface GDS {
//
// /**
// * Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
// * have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
// *
// * It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
// * done by this GDS.
// */
// public abstract void beginTransaction();
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void commitTransaction();
//
// /**
// *
// * @return A new GDSDelete that can be used to delete pojos from the datastore
// */
// public abstract GDSDeleter delete();
//
// /**
// * @param <T>
// * @return Delete a single pojo
// */
// public abstract <T> GDSResult<Boolean> delete(T t);
//
// public abstract Client getClient();
//
// public abstract String indexFor(String kind);
//
// public abstract String[] indexFor(String[] kinds);
//
// /**
// * @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
// */
// public abstract GDSLoader load();
//
// /**
// * A way to fetch an object if you don't know the class - only a stored class string
// *
// * @return
// */
// public abstract GDSResult<Object> load(String kind, String id);
//
// /**
// * Fetch a single pojo
// *
// * @param <T>
// *
// * @param ownerKind
// * @param ownerID
// * @return
// */
// public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
//
// /**
// * @param clazz
// * The class of pojos to search for. All subclasses of this type will also be searched for.
// * @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
// */
// public abstract <T> GDSQuery<T> query(Class<T> clazz);
//
// /**
// * Must call beginTransaction before using this or you will receive a NullPointerException.
// */
// public abstract void rollbackTransaction();
//
// /**
// * @return A new GDSSaver that can be used to save any collection of pojos.
// */
// public abstract GDSSaver save();
//
// /**
// * @param <T>
// * @return Save a single pojo
// */
// public abstract <T> GDSResult<Key> save(T t);
//
// public abstract <T> GDSResult<List<T>> fetchAll(Class<T> clazz, String[] ids);
//
// public abstract <T> GDSMultiResult<T> fetchAll(Class<T> clazz);
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
// Path: src/test/java/com/rc/gds/BasicTest.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.rc.gds.TestSubClass.TheSubClass;
import com.rc.gds.interfaces.GDS;
import com.rc.gds.interfaces.GDSResult;
testParentMap.name = "testParentList" + num;
testParentMap.testChildMap = new HashMap<String, TestChild>();
for (int i = 0; i < 10; i++) {
TestChild testChild = new TestChild();
testChild.name = "child" + i;
testParentMap.testChildMap.put("key " + i, testChild);
testParentMap.testChildMap.put("key2 " + i, testChild);
testParentMap.testChildMap.put("key3 " + i, testChild);
}
getGDS().save().entity(testParentMap).now();
Assert.assertNotNull(testParentMap.id);
for (TestChild testChild : testParentMap.testChildMap.values())
Assert.assertNotNull(testChild.id);
TestParentMap fetchParent = getGDS().load().fetch(TestParentMap.class, testParentMap.id).now();
Assert.assertEquals(30, fetchParent.testChildMap.size());
for (int i = 0; i < 10; i++) {
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key " + i).name);
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key2 " + i).name);
Assert.assertEquals("child" + i, fetchParent.testChildMap.get("key3 " + i).name);
}
}
@Test
public void testBatcher() {
TestParent testParent1 = new TestParent();
|
GDSResult<Key> result1 = getGDS().save().entity(testParent1).result();
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/GDSBatcher.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
|
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
|
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
// Path: src/main/java/com/rc/gds/GDSBatcher.java
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
|
final GDSMultiResult<?>[] multiResults;
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/GDSBatcher.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
|
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
|
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
final GDSMultiResult<?>[] multiResults;
public GDSBatcher(GDSResult<?>... input) {
singleResults = input;
multiResults = null;
}
public GDSBatcher(GDSMultiResult<?>... input) {
singleResults = null;
multiResults = input;
}
public GDSBatcher(GDSResult<?>[] singleResults, GDSMultiResult<?>[] multiResults) {
this.singleResults = singleResults;
this.multiResults = multiResults;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public GDSResult<Boolean> onAllComplete() {
final AtomicInteger current = new AtomicInteger(0);
final AtomicInteger total = new AtomicInteger(0);
final GDSAsyncImpl<Boolean> asyncResult = new GDSAsyncImpl<>();
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
// Path: src/main/java/com/rc/gds/GDSBatcher.java
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
final GDSMultiResult<?>[] multiResults;
public GDSBatcher(GDSResult<?>... input) {
singleResults = input;
multiResults = null;
}
public GDSBatcher(GDSMultiResult<?>... input) {
singleResults = null;
multiResults = input;
}
public GDSBatcher(GDSResult<?>[] singleResults, GDSMultiResult<?>[] multiResults) {
this.singleResults = singleResults;
this.multiResults = multiResults;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public GDSResult<Boolean> onAllComplete() {
final AtomicInteger current = new AtomicInteger(0);
final AtomicInteger total = new AtomicInteger(0);
final GDSAsyncImpl<Boolean> asyncResult = new GDSAsyncImpl<>();
|
final GDSCallback singleCallback = new GDSCallback() {
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/GDSBatcher.java
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
|
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
|
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
final GDSMultiResult<?>[] multiResults;
public GDSBatcher(GDSResult<?>... input) {
singleResults = input;
multiResults = null;
}
public GDSBatcher(GDSMultiResult<?>... input) {
singleResults = null;
multiResults = input;
}
public GDSBatcher(GDSResult<?>[] singleResults, GDSMultiResult<?>[] multiResults) {
this.singleResults = singleResults;
this.multiResults = multiResults;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public GDSResult<Boolean> onAllComplete() {
final AtomicInteger current = new AtomicInteger(0);
final AtomicInteger total = new AtomicInteger(0);
final GDSAsyncImpl<Boolean> asyncResult = new GDSAsyncImpl<>();
final GDSCallback singleCallback = new GDSCallback() {
@Override
public void onSuccess(Object t, Throwable err) {
handleSuccess(current, total, asyncResult, err);
}
};
|
// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// public void onSuccess(T t, Throwable err);
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
//
// public void later(GDSResultReceiver<T> resultReceiver);
//
// public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
//
// public List<T> asList();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
//
// public void later(GDSCallback<T> inCallback);
//
// public T now();
//
// }
//
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
//
// public void success(List<T> list, Throwable err);
//
// }
// Path: src/main/java/com/rc/gds/GDSBatcher.java
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;
package com.rc.gds;
public class GDSBatcher {
final GDSResult<?>[] singleResults;
final GDSMultiResult<?>[] multiResults;
public GDSBatcher(GDSResult<?>... input) {
singleResults = input;
multiResults = null;
}
public GDSBatcher(GDSMultiResult<?>... input) {
singleResults = null;
multiResults = input;
}
public GDSBatcher(GDSResult<?>[] singleResults, GDSMultiResult<?>[] multiResults) {
this.singleResults = singleResults;
this.multiResults = multiResults;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public GDSResult<Boolean> onAllComplete() {
final AtomicInteger current = new AtomicInteger(0);
final AtomicInteger total = new AtomicInteger(0);
final GDSAsyncImpl<Boolean> asyncResult = new GDSAsyncImpl<>();
final GDSCallback singleCallback = new GDSCallback() {
@Override
public void onSuccess(Object t, Throwable err) {
handleSuccess(current, total, asyncResult, err);
}
};
|
final GDSResultListReceiver multiCallback = new GDSResultListReceiver() {
|
Ryan-ZA/async-elastic-orm
|
src/main/java/com/rc/gds/interfaces/GDS.java
|
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
|
import java.util.List;
import org.elasticsearch.client.Client;
import com.rc.gds.Key;
|
package com.rc.gds.interfaces;
public interface GDS {
/**
* Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
* have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
*
* It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
* done by this GDS.
*/
public abstract void beginTransaction();
/**
* Must call beginTransaction before using this or you will receive a NullPointerException.
*/
public abstract void commitTransaction();
/**
*
* @return A new GDSDelete that can be used to delete pojos from the datastore
*/
public abstract GDSDeleter delete();
/**
* @param <T>
* @return Delete a single pojo
*/
public abstract <T> GDSResult<Boolean> delete(T t);
public abstract Client getClient();
public abstract String indexFor(String kind);
public abstract String[] indexFor(String[] kinds);
/**
* @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
*/
public abstract GDSLoader load();
/**
* A way to fetch an object if you don't know the class - only a stored class string
*
* @return
*/
public abstract GDSResult<Object> load(String kind, String id);
/**
* Fetch a single pojo
*
* @param <T>
*
* @param ownerKind
* @param ownerID
* @return
*/
public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
/**
* @param clazz
* The class of pojos to search for. All subclasses of this type will also be searched for.
* @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
*/
public abstract <T> GDSQuery<T> query(Class<T> clazz);
/**
* Must call beginTransaction before using this or you will receive a NullPointerException.
*/
public abstract void rollbackTransaction();
/**
* @return A new GDSSaver that can be used to save any collection of pojos.
*/
public abstract GDSSaver save();
/**
* @param <T>
* @return Save a single pojo
*/
|
// Path: src/main/java/com/rc/gds/Key.java
// public class Key implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// String kind, id;
// Long version;
//
// public Key() {
// }
//
// public Key(Map<String, Object> map) {
// id = (String) map.get("id");
// kind = (String) map.get("kind");
// }
//
// public Key(Class<?> clazz, String id) {
// this.id = id;
// kind = GDSClass.getKind(clazz);
// }
//
// public Key(String kind, String id) {
// this.id = id;
// this.kind = kind;
// }
//
// public Key(String kind, String id, long version) {
// this(kind, id);
// this.version = version;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Key other = (Key) obj;
// if (id == null) {
// if (other.id != null)
// return false;
// } else if (!id.equals(other.id))
// return false;
// if (kind == null) {
// if (other.kind != null)
// return false;
// } else if (!kind.equals(other.kind))
// return false;
// return true;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getKind() {
// return kind;
// }
//
// public void setKind(String kind) {
// this.kind = kind;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (id == null ? 0 : id.hashCode());
// result = prime * result + (kind == null ? 0 : kind.hashCode());
// return result;
// }
//
// public Map<String, Object> toMap() {
// Map<String, Object> map = new HashMap<>();
// map.put("id", id);
// map.put("kind", kind);
// return map;
// }
//
// }
// Path: src/main/java/com/rc/gds/interfaces/GDS.java
import java.util.List;
import org.elasticsearch.client.Client;
import com.rc.gds.Key;
package com.rc.gds.interfaces;
public interface GDS {
/**
* Begin a transaction that will last until commitTransaction() or rollbackTransaction() is called. You must call one of these when you
* have finished the transaction. The transaction will apply to all load() save() and query() calls from this GDS.
*
* It is not required to call this to do simple operations - you only need to use this if you wish to commit/rollback all operations
* done by this GDS.
*/
public abstract void beginTransaction();
/**
* Must call beginTransaction before using this or you will receive a NullPointerException.
*/
public abstract void commitTransaction();
/**
*
* @return A new GDSDelete that can be used to delete pojos from the datastore
*/
public abstract GDSDeleter delete();
/**
* @param <T>
* @return Delete a single pojo
*/
public abstract <T> GDSResult<Boolean> delete(T t);
public abstract Client getClient();
public abstract String indexFor(String kind);
public abstract String[] indexFor(String[] kinds);
/**
* @return A new GDSLoader that can be used to load pojos IFF you have the ID or Key of the pojo.
*/
public abstract GDSLoader load();
/**
* A way to fetch an object if you don't know the class - only a stored class string
*
* @return
*/
public abstract GDSResult<Object> load(String kind, String id);
/**
* Fetch a single pojo
*
* @param <T>
*
* @param ownerKind
* @param ownerID
* @return
*/
public abstract <T> GDSResult<T> load(Class<T> clazz, String id);
/**
* @param clazz
* The class of pojos to search for. All subclasses of this type will also be searched for.
* @return A new parametrized GDSQuery that can be used to search for specific kinds of pojos. Filters and sorting are available.
*/
public abstract <T> GDSQuery<T> query(Class<T> clazz);
/**
* Must call beginTransaction before using this or you will receive a NullPointerException.
*/
public abstract void rollbackTransaction();
/**
* @return A new GDSSaver that can be used to save any collection of pojos.
*/
public abstract GDSSaver save();
/**
* @param <T>
* @return Save a single pojo
*/
|
public abstract <T> GDSResult<Key> save(T t);
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/interceptor/UserInterceptor.java
|
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
|
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.User;
|
package com.phn.bookhouse.interceptor;
public class UserInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex)
throws Exception {
System.out.println("最后执行!!!一般用于释放资源!!");
}
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
System.out.println("Action执行之后,生成视图之前执行!!");
}
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
System.out.println("action之前执行!!!");
// 获取request对象
// HttpServletRequest request = ((ServletRequestAttributes)
// RequestContextHolder.getRequestAttributes()).getRequest();
// 获取session对象
HttpSession session = request.getSession(true);
|
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
// Path: src/main/java/com/phn/bookhouse/interceptor/UserInterceptor.java
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.User;
package com.phn.bookhouse.interceptor;
public class UserInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex)
throws Exception {
System.out.println("最后执行!!!一般用于释放资源!!");
}
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
System.out.println("Action执行之后,生成视图之前执行!!");
}
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
System.out.println("action之前执行!!!");
// 获取request对象
// HttpServletRequest request = ((ServletRequestAttributes)
// RequestContextHolder.getRequestAttributes()).getRequest();
// 获取session对象
HttpSession session = request.getSession(true);
|
User user = (User) session.getAttribute("loginUser");
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/controller/AddressController.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
|
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.entity.User;
import com.phn.bookhouse.service.AddressService;
|
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file AddressController.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/address")
public class AddressController {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
// Path: src/main/java/com/phn/bookhouse/controller/AddressController.java
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.entity.User;
import com.phn.bookhouse.service.AddressService;
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file AddressController.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/address")
public class AddressController {
@Autowired
|
private AddressService addressService;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/HouseServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/HouseDao.java
// public interface HouseDao {
// public House loginJudge(House house);
// /**
// * @param house
// * @return
// */
// public int updateHouseInfo(House house);
// /**
// * @param house
// * @return
// */
// public int updateHousePass(House house);
//
// /**
// * @param houseid
// * @return
// */
// public House selectHouseById(long houseid);
// /**
// * @author pan
// * @param loginHouse
// */
// public void updateHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public List<House> registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/HouseService.java
// public interface HouseService {
// public int addHouse(House house);
// public int removeHouseById(long houseid);
// public House findHouseById(long houseid);
// public House loginJudge(String housename,String housepass);
// public List<House> findHouseByName(String housename);
// public int editHouseInfo(House house);
// public int editHousePass(House house);
// /**
// * @author pan
// * @param loginHouse
// */
// public void editHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public boolean registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.HouseDao;
import com.phn.bookhouse.entity.House;
import com.phn.bookhouse.service.HouseService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file HouseServiceImpl.java
* @author pan
* @date 2014年11月13日
* @email panhainan@yeah.net
*/
@Service("houseService")
public class HouseServiceImpl implements HouseService {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/dao/HouseDao.java
// public interface HouseDao {
// public House loginJudge(House house);
// /**
// * @param house
// * @return
// */
// public int updateHouseInfo(House house);
// /**
// * @param house
// * @return
// */
// public int updateHousePass(House house);
//
// /**
// * @param houseid
// * @return
// */
// public House selectHouseById(long houseid);
// /**
// * @author pan
// * @param loginHouse
// */
// public void updateHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public List<House> registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/HouseService.java
// public interface HouseService {
// public int addHouse(House house);
// public int removeHouseById(long houseid);
// public House findHouseById(long houseid);
// public House loginJudge(String housename,String housepass);
// public List<House> findHouseByName(String housename);
// public int editHouseInfo(House house);
// public int editHousePass(House house);
// /**
// * @author pan
// * @param loginHouse
// */
// public void editHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public boolean registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/HouseServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.HouseDao;
import com.phn.bookhouse.entity.House;
import com.phn.bookhouse.service.HouseService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file HouseServiceImpl.java
* @author pan
* @date 2014年11月13日
* @email panhainan@yeah.net
*/
@Service("houseService")
public class HouseServiceImpl implements HouseService {
@Autowired
|
private HouseDao houseDao;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/HouseServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/HouseDao.java
// public interface HouseDao {
// public House loginJudge(House house);
// /**
// * @param house
// * @return
// */
// public int updateHouseInfo(House house);
// /**
// * @param house
// * @return
// */
// public int updateHousePass(House house);
//
// /**
// * @param houseid
// * @return
// */
// public House selectHouseById(long houseid);
// /**
// * @author pan
// * @param loginHouse
// */
// public void updateHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public List<House> registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/HouseService.java
// public interface HouseService {
// public int addHouse(House house);
// public int removeHouseById(long houseid);
// public House findHouseById(long houseid);
// public House loginJudge(String housename,String housepass);
// public List<House> findHouseByName(String housename);
// public int editHouseInfo(House house);
// public int editHousePass(House house);
// /**
// * @author pan
// * @param loginHouse
// */
// public void editHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public boolean registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.HouseDao;
import com.phn.bookhouse.entity.House;
import com.phn.bookhouse.service.HouseService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file HouseServiceImpl.java
* @author pan
* @date 2014年11月13日
* @email panhainan@yeah.net
*/
@Service("houseService")
public class HouseServiceImpl implements HouseService {
@Autowired
private HouseDao houseDao;
@Override
|
// Path: src/main/java/com/phn/bookhouse/dao/HouseDao.java
// public interface HouseDao {
// public House loginJudge(House house);
// /**
// * @param house
// * @return
// */
// public int updateHouseInfo(House house);
// /**
// * @param house
// * @return
// */
// public int updateHousePass(House house);
//
// /**
// * @param houseid
// * @return
// */
// public House selectHouseById(long houseid);
// /**
// * @author pan
// * @param loginHouse
// */
// public void updateHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public List<House> registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/HouseService.java
// public interface HouseService {
// public int addHouse(House house);
// public int removeHouseById(long houseid);
// public House findHouseById(long houseid);
// public House loginJudge(String housename,String housepass);
// public List<House> findHouseByName(String housename);
// public int editHouseInfo(House house);
// public int editHousePass(House house);
// /**
// * @author pan
// * @param loginHouse
// */
// public void editHouseLogo(House loginHouse);
// /**
// * @author pan
// * @param house
// */
// public boolean registJudge(House house);
// /**
// * @author pan
// * @param house
// * @return
// */
// public int regist(House house);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/HouseServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.HouseDao;
import com.phn.bookhouse.entity.House;
import com.phn.bookhouse.service.HouseService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file HouseServiceImpl.java
* @author pan
* @date 2014年11月13日
* @email panhainan@yeah.net
*/
@Service("houseService")
public class HouseServiceImpl implements HouseService {
@Autowired
private HouseDao houseDao;
@Override
|
public int addHouse(House house) {
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/UserService.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
|
import java.util.List;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.entity.User;
|
package com.phn.bookhouse.service;
public interface UserService {
public int insertUser(User user);
/**
* @author pan
* @param username
* @param userpass
* @return
*/
public User loginJudge(String username, String userpass);
/**
* @author pan
* @param user
*/
public int editUserInfo(User user);
/**
* @author pan
* @param user_id
* @return
*/
public User findUserById(long user_id);
/**
* @author pan
* @param loginUser
* @return
*/
public int editUserPass(User user);
|
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/User.java
// public class User {
// private long user_id;
// private String user_login_name;
// private String user_login_password;
// private String user_nick_name;
// private String user_sex;
// private String user_picture;
// private String user_phone;
// private String user_login_email;
// // private long user_addr_id;
// private List<Address> address = new ArrayList<Address>();
//
// public long getUser_id() {
// return user_id;
// }
//
// public void setUser_id(long user_id) {
// this.user_id = user_id;
// }
//
// public String getUser_login_name() {
// return user_login_name;
// }
//
// public void setUser_login_name(String user_login_name) {
// this.user_login_name = user_login_name;
// }
//
// public String getUser_login_password() {
// return user_login_password;
// }
//
// public void setUser_login_password(String user_login_password) {
// this.user_login_password = user_login_password;
// }
//
// public String getUser_nick_name() {
// return user_nick_name;
// }
//
// public void setUser_nick_name(String user_nick_name) {
// this.user_nick_name = user_nick_name;
// }
//
// public String getUser_sex() {
// return user_sex;
// }
//
// public void setUser_sex(String user_sex) {
// this.user_sex = user_sex;
// }
//
// public String getUser_picture() {
// return user_picture;
// }
//
// public void setUser_picture(String user_picture) {
// this.user_picture = user_picture;
// }
//
// public String getUser_phone() {
// return user_phone;
// }
//
// public void setUser_phone(String user_phone) {
// this.user_phone = user_phone;
// }
//
// public String getUser_login_email() {
// return user_login_email;
// }
//
// public void setUser_login_email(String user_login_email) {
// this.user_login_email = user_login_email;
// }
//
// public List<Address> getAddress() {
// return address;
// }
//
// public void setAddress(List<Address> address) {
// this.address = address;
// }
//
// @Override
// public String toString() {
// return "User [user_id=" + user_id + ", user_login_name=" + user_login_name + ", user_nick_name=" + user_nick_name+"]";
// }
// }
// Path: src/main/java/com/phn/bookhouse/service/UserService.java
import java.util.List;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.entity.User;
package com.phn.bookhouse.service;
public interface UserService {
public int insertUser(User user);
/**
* @author pan
* @param username
* @param userpass
* @return
*/
public User loginJudge(String username, String userpass);
/**
* @author pan
* @param user
*/
public int editUserInfo(User user);
/**
* @author pan
* @param user_id
* @return
*/
public User findUserById(long user_id);
/**
* @author pan
* @param loginUser
* @return
*/
public int editUserPass(User user);
|
public List<Address> findUserAddress(long userid);
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/controller/BookHouseController.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file BookHouseController.java
* @author pan
* @date 2014年11月21日
* @email panhainan@yeah.net
*/
@Controller
public class BookHouseController {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/controller/BookHouseController.java
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file BookHouseController.java
* @author pan
* @date 2014年11月21日
* @email panhainan@yeah.net
*/
@Controller
public class BookHouseController {
@Autowired
|
private TypeService typeService;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/controller/BookHouseController.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file BookHouseController.java
* @author pan
* @date 2014年11月21日
* @email panhainan@yeah.net
*/
@Controller
public class BookHouseController {
@Autowired
private TypeService typeService;
@RequestMapping("/index.htm")
public String index(HttpServletRequest req) {
int typefatherid = -1;
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/controller/BookHouseController.java
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file BookHouseController.java
* @author pan
* @date 2014年11月21日
* @email panhainan@yeah.net
*/
@Controller
public class BookHouseController {
@Autowired
private TypeService typeService;
@RequestMapping("/index.htm")
public String index(HttpServletRequest req) {
int typefatherid = -1;
|
List<Type> listftype = typeService.findFatherType(typefatherid);
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/AddressServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/AddressDao.java
// public interface AddressDao {
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public Address selectAddressById(long addressid);
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public int deleteAddress(long addressid);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int updateAddress(Address address);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int insertAddress(Address address);
//
// /**
// * @author pan
// * @param user_id
// * @return
// */
// public List<Address> selectAddressByUserId(long user_id);
//
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AddressDao;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.service.AddressService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file AddressServiceImpl.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Service("addressService")
public class AddressServiceImpl implements AddressService {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/dao/AddressDao.java
// public interface AddressDao {
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public Address selectAddressById(long addressid);
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public int deleteAddress(long addressid);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int updateAddress(Address address);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int insertAddress(Address address);
//
// /**
// * @author pan
// * @param user_id
// * @return
// */
// public List<Address> selectAddressByUserId(long user_id);
//
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/AddressServiceImpl.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AddressDao;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.service.AddressService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file AddressServiceImpl.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Service("addressService")
public class AddressServiceImpl implements AddressService {
@Autowired
|
private AddressDao addressDao;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/AddressServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/AddressDao.java
// public interface AddressDao {
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public Address selectAddressById(long addressid);
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public int deleteAddress(long addressid);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int updateAddress(Address address);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int insertAddress(Address address);
//
// /**
// * @author pan
// * @param user_id
// * @return
// */
// public List<Address> selectAddressByUserId(long user_id);
//
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AddressDao;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.service.AddressService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file AddressServiceImpl.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Service("addressService")
public class AddressServiceImpl implements AddressService {
@Autowired
private AddressDao addressDao;
@Override
|
// Path: src/main/java/com/phn/bookhouse/dao/AddressDao.java
// public interface AddressDao {
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public Address selectAddressById(long addressid);
//
// /**
// * @author pan
// * @param addressid
// * @return
// */
// public int deleteAddress(long addressid);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int updateAddress(Address address);
//
// /**
// * @author pan
// * @param address
// * @return
// */
// public int insertAddress(Address address);
//
// /**
// * @author pan
// * @param user_id
// * @return
// */
// public List<Address> selectAddressByUserId(long user_id);
//
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Address.java
// public class Address {
// private long addr_id;
//
// private String addr_user_name;
//
// private String addr_name;
//
// private String addr_phone;
//
// // private long addr_user_id;
// private User user;
//
// public long getAddr_id() {
// return addr_id;
// }
//
// public void setAddr_id(long addr_id) {
// this.addr_id = addr_id;
// }
//
// public String getAddr_user_name() {
// return addr_user_name;
// }
//
// public void setAddr_user_name(String addr_user_name) {
// this.addr_user_name = addr_user_name;
// }
//
// public String getAddr_name() {
// return addr_name;
// }
//
// public void setAddr_name(String addr_name) {
// this.addr_name = addr_name;
// }
//
// public String getAddr_phone() {
// return addr_phone;
// }
//
// public void setAddr_phone(String addr_phone) {
// this.addr_phone = addr_phone;
// }
//
// // public long getAddr_user_id() {
// // return addr_user_id;
// // }
// //
// // public void setAddr_user_id(long addr_user_id) {
// // this.addr_user_id = addr_user_id;
// // }
//
// @Override
// public String toString() {
// return "Address [addr_id=" + addr_id + ", user=" + user
// + ", addr_name=" + addr_name + ", addr_user_name="
// + addr_user_name + ",addr_phone="+addr_phone+"]";
// }
//
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AddressService.java
// public interface AddressService {
// public int addAddress(Address address);
// public int editAddress(Address address);
// public int removeAddress(long addressid);
// public Address findAddressById(long addressid);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/AddressServiceImpl.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AddressDao;
import com.phn.bookhouse.entity.Address;
import com.phn.bookhouse.service.AddressService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file AddressServiceImpl.java
* @author pan
* @date 2014年11月17日
* @email panhainan@yeah.net
*/
@Service("addressService")
public class AddressServiceImpl implements AddressService {
@Autowired
private AddressDao addressDao;
@Override
|
public int addAddress(Address address) {
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/interceptor/HouseInterceptor.java
|
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
|
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.House;
|
package com.phn.bookhouse.interceptor;
public class HouseInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex)
throws Exception {
System.out.println("最后执行!!!一般用于释放资源!!");
}
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
System.out.println("Action执行之后,生成视图之前执行!!");
}
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
System.out.println("action之前执行!!!");
// 获取request对象
// HttpServletRequest request = ((ServletRequestAttributes)
// RequestContextHolder.getRequestAttributes()).getRequest();
// 获取session对象
HttpSession session = request.getSession(true);
|
// Path: src/main/java/com/phn/bookhouse/entity/House.java
// public class House {
// private long hous_id;
// private String hous_login_name;
// private String hous_login_email;
// private String hous_login_password;
// private String hous_name;
// private String hous_logo;
// private String hous_phone;
// private String hous_company_name;
// private String hous_company_addr;
// private double hous_score_description;
// private double hous_score_service;
// private double hous_score_speed;
//
// public long getHous_id() {
// return hous_id;
// }
//
// public void setHous_id(long hous_id) {
// this.hous_id = hous_id;
// }
//
// public String getHous_login_name() {
// return hous_login_name;
// }
//
// public void setHous_login_name(String hous_login_name) {
// this.hous_login_name = hous_login_name;
// }
//
// public String getHous_login_email() {
// return hous_login_email;
// }
//
// public void setHous_login_email(String hous_login_email) {
// this.hous_login_email = hous_login_email;
// }
//
// public String getHous_login_password() {
// return hous_login_password;
// }
//
// public void setHous_login_password(String hous_login_password) {
// this.hous_login_password = hous_login_password;
// }
//
// public String getHous_name() {
// return hous_name;
// }
//
// public void setHous_name(String hous_name) {
// this.hous_name = hous_name;
// }
//
// public String getHous_logo() {
// return hous_logo;
// }
//
// public void setHous_logo(String hous_logo) {
// this.hous_logo = hous_logo;
// }
//
// public String getHous_phone() {
// return hous_phone;
// }
//
// public void setHous_phone(String hous_phone) {
// this.hous_phone = hous_phone;
// }
//
// public String getHous_company_name() {
// return hous_company_name;
// }
//
// public void setHous_company_name(String hous_company_name) {
// this.hous_company_name = hous_company_name;
// }
//
// public String getHous_company_addr() {
// return hous_company_addr;
// }
//
// public void setHous_company_addr(String hous_company_addr) {
// this.hous_company_addr = hous_company_addr;
// }
//
// public double getHous_score_description() {
// return hous_score_description;
// }
//
// public void setHous_score_description(double hous_score_description) {
// this.hous_score_description = hous_score_description;
// }
//
// public double getHous_score_service() {
// return hous_score_service;
// }
//
// public void setHous_score_service(double hous_score_service) {
// this.hous_score_service = hous_score_service;
// }
//
// public double getHous_score_speed() {
// return hous_score_speed;
// }
//
// public void setHous_score_speed(double hous_score_speed) {
// this.hous_score_speed = hous_score_speed;
// }
//
// }
// Path: src/main/java/com/phn/bookhouse/interceptor/HouseInterceptor.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.House;
package com.phn.bookhouse.interceptor;
public class HouseInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex)
throws Exception {
System.out.println("最后执行!!!一般用于释放资源!!");
}
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
System.out.println("Action执行之后,生成视图之前执行!!");
}
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
System.out.println("action之前执行!!!");
// 获取request对象
// HttpServletRequest request = ((ServletRequestAttributes)
// RequestContextHolder.getRequestAttributes()).getRequest();
// 获取session对象
HttpSession session = request.getSession(true);
|
House house = (House) session.getAttribute("loginHouse");
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/controller/TypeController.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file TypeController.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/booktype")
public class TypeController {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/controller/TypeController.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file TypeController.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/booktype")
public class TypeController {
@Autowired
|
private TypeService typeService;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/controller/TypeController.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file TypeController.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/booktype")
public class TypeController {
@Autowired
private TypeService typeService;
@RequestMapping(value = "/goAllBookType.htm")
public String goAllBookType(HttpServletRequest req) {
int typefatherid = -1;
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/controller/TypeController.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.controller;
/**
* @file TypeController.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
@Controller
@RequestMapping(value = "/booktype")
public class TypeController {
@Autowired
private TypeService typeService;
@RequestMapping(value = "/goAllBookType.htm")
public String goAllBookType(HttpServletRequest req) {
int typefatherid = -1;
|
List<Type> listftype = typeService.findFatherType(typefatherid);
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/AdminServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/AdminDao.java
// public interface AdminDao {
// public int insertAdmin(Admin admin);
// public int deleteAdminById(int adminid);
// public Admin selectAdminById(int adminid);
// public List<Admin> selectAdminByName(String adminname);
// public int updateAdmin(Admin admin);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AdminDao;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
|
package com.phn.bookhouse.service.impl;
@Service("adminService")
public class AdminServiceImpl implements AdminService {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/dao/AdminDao.java
// public interface AdminDao {
// public int insertAdmin(Admin admin);
// public int deleteAdminById(int adminid);
// public Admin selectAdminById(int adminid);
// public List<Admin> selectAdminByName(String adminname);
// public int updateAdmin(Admin admin);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/AdminServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AdminDao;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
package com.phn.bookhouse.service.impl;
@Service("adminService")
public class AdminServiceImpl implements AdminService {
@Autowired
|
private AdminDao adminDao;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/AdminServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/AdminDao.java
// public interface AdminDao {
// public int insertAdmin(Admin admin);
// public int deleteAdminById(int adminid);
// public Admin selectAdminById(int adminid);
// public List<Admin> selectAdminByName(String adminname);
// public int updateAdmin(Admin admin);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AdminDao;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
|
package com.phn.bookhouse.service.impl;
@Service("adminService")
public class AdminServiceImpl implements AdminService {
@Autowired
private AdminDao adminDao;
@Override
|
// Path: src/main/java/com/phn/bookhouse/dao/AdminDao.java
// public interface AdminDao {
// public int insertAdmin(Admin admin);
// public int deleteAdminById(int adminid);
// public Admin selectAdminById(int adminid);
// public List<Admin> selectAdminByName(String adminname);
// public int updateAdmin(Admin admin);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/AdminServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.AdminDao;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
package com.phn.bookhouse.service.impl;
@Service("adminService")
public class AdminServiceImpl implements AdminService {
@Autowired
private AdminDao adminDao;
@Override
|
public int addAdmin(Admin admin) {
|
panhainan/BookHouse
|
src/test/java/com/test/service/TypeServiceTest.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import static org.junit.Assert.fail;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.test.service;
/**
* @file TypeServiceTest.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
public class TypeServiceTest {
private TypeService typeService;
@Before
public void before() {
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:spring.xml",
"classpath:spring-mybatis.xml" });
typeService = (TypeService) context.getBean("typeService");
}
/**
* Test method for
* {@link com.phn.bookhouse.service.impl.TypeServiceImpl#addType(com.phn.bookhouse.entity.Type)}
* .
*/
@Test
public void testAddType() {
|
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/test/java/com/test/service/TypeServiceTest.java
import static org.junit.Assert.fail;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.test.service;
/**
* @file TypeServiceTest.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
public class TypeServiceTest {
private TypeService typeService;
@Before
public void before() {
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:spring.xml",
"classpath:spring-mybatis.xml" });
typeService = (TypeService) context.getBean("typeService");
}
/**
* Test method for
* {@link com.phn.bookhouse.service.impl.TypeServiceImpl#addType(com.phn.bookhouse.entity.Type)}
* .
*/
@Test
public void testAddType() {
|
Type type = new Type();
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/TypeServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/TypeDao.java
// public interface TypeDao {
// public int insertType(Type type);
//
// public int deleteTypeById(int typeid);
//
// public Type selectTypeById(int typeid);
//
// public List<Type> selectTypeByName(String typename);
//
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> selectTypeByFatherId(int typefatherid);
//
// public int updateType(Type type);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.TypeDao;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file TypeServiceImpl.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
@Service("typeService")
public class TypeServiceImpl implements TypeService {
@Autowired
|
// Path: src/main/java/com/phn/bookhouse/dao/TypeDao.java
// public interface TypeDao {
// public int insertType(Type type);
//
// public int deleteTypeById(int typeid);
//
// public Type selectTypeById(int typeid);
//
// public List<Type> selectTypeByName(String typename);
//
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> selectTypeByFatherId(int typefatherid);
//
// public int updateType(Type type);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/TypeServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.TypeDao;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file TypeServiceImpl.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
@Service("typeService")
public class TypeServiceImpl implements TypeService {
@Autowired
|
private TypeDao typeDao;
|
panhainan/BookHouse
|
src/main/java/com/phn/bookhouse/service/impl/TypeServiceImpl.java
|
// Path: src/main/java/com/phn/bookhouse/dao/TypeDao.java
// public interface TypeDao {
// public int insertType(Type type);
//
// public int deleteTypeById(int typeid);
//
// public Type selectTypeById(int typeid);
//
// public List<Type> selectTypeByName(String typename);
//
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> selectTypeByFatherId(int typefatherid);
//
// public int updateType(Type type);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.TypeDao;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
|
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file TypeServiceImpl.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
@Service("typeService")
public class TypeServiceImpl implements TypeService {
@Autowired
private TypeDao typeDao;
@Override
|
// Path: src/main/java/com/phn/bookhouse/dao/TypeDao.java
// public interface TypeDao {
// public int insertType(Type type);
//
// public int deleteTypeById(int typeid);
//
// public Type selectTypeById(int typeid);
//
// public List<Type> selectTypeByName(String typename);
//
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> selectTypeByFatherId(int typefatherid);
//
// public int updateType(Type type);
// }
//
// Path: src/main/java/com/phn/bookhouse/entity/Type.java
// public class Type {
// private int type_id;
//
// private String type_name;
//
// private int type_father_id;
//
// public int getType_id() {
// return type_id;
// }
//
// public void setType_id(int type_id) {
// this.type_id = type_id;
// }
//
// public String getType_name() {
// return type_name;
// }
//
// public void setType_name(String type_name) {
// this.type_name = type_name;
// }
//
// public int getType_father_id() {
// return type_father_id;
// }
//
// public void setType_father_id(int type_father_id) {
// this.type_father_id = type_father_id;
// }
// @Override
// public String toString() {
// return "Type [type_id=" + type_id + ",type_name=" + type_name
// + ", type_father_id=" + type_father_id + "]";
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/TypeService.java
// public interface TypeService {
// public int addType(Type type);
// public int removeTypeById(int typeid);
// public Type findTypeById(int typeid);
// public List<Type> findTypeByName(String typename);
// public int editType(Type type);
// /**
// * @author pan
// * @param typefatherid
// * @return List<Type>
// */
// public List<Type> findTypeByFatherId(int typefatherid);
// /**
// * @author pan
// * @param typefatherid
// * @return
// */
// public List<Type> findFatherType(int typefatherid);
// }
// Path: src/main/java/com/phn/bookhouse/service/impl/TypeServiceImpl.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phn.bookhouse.dao.TypeDao;
import com.phn.bookhouse.entity.Type;
import com.phn.bookhouse.service.TypeService;
/**
*
*/
package com.phn.bookhouse.service.impl;
/**
* @file TypeServiceImpl.java
* @author pan
* @date 2014年11月14日
* @email panhainan@yeah.net
*/
@Service("typeService")
public class TypeServiceImpl implements TypeService {
@Autowired
private TypeDao typeDao;
@Override
|
public int addType(Type type) {
|
panhainan/BookHouse
|
src/test/java/com/test/service/AdminServiceTest.java
|
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
|
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
|
/**
*
*/
package com.test.service;
/**
* @class AdminServiceTest.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
public class AdminServiceTest {
private AdminService adminService;
@Before
public void before() {
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:spring.xml",
"classpath:spring-mybatis.xml" });
adminService = (AdminService) context.getBean("adminService");
}
/**
* Test method for
* {@link com.phn.bookhouse.service.impl.AdminServiceImpl#insertAdmin(com.phn.bookhouse.entity.Admin)}
* .
*/
// @Test
public void testInsertAdmin() {
|
// Path: src/main/java/com/phn/bookhouse/entity/Admin.java
// public class Admin {
// private int admi_id;
// private String admi_login_name;
// private String admi_login_password;
//
// public int getAdmi_id() {
// return admi_id;
// }
//
// public void setAdmi_id(int admi_id) {
// this.admi_id = admi_id;
// }
//
// public String getAdmi_login_name() {
// return admi_login_name;
// }
//
// public void setAdmi_login_name(String admi_login_name) {
// this.admi_login_name = admi_login_name;
// }
//
// public String getAdmi_login_password() {
// return admi_login_password;
// }
//
// public void setAdmi_login_password(String admi_login_password) {
// this.admi_login_password = admi_login_password;
// }
//
// }
//
// Path: src/main/java/com/phn/bookhouse/service/AdminService.java
// public interface AdminService {
// public int addAdmin(Admin admin);
// public int removeAdminById(int adminid);
// public Admin findAdminById(int adminid);
// public List<Admin> findAdminByName(String adminname);
// public int editAdmin(Admin admin);
// }
// Path: src/test/java/com/test/service/AdminServiceTest.java
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.phn.bookhouse.entity.Admin;
import com.phn.bookhouse.service.AdminService;
/**
*
*/
package com.test.service;
/**
* @class AdminServiceTest.java
* @author pan
* @date 2014年11月12日
* @email panhainan@yeah.net
*/
public class AdminServiceTest {
private AdminService adminService;
@Before
public void before() {
@SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:spring.xml",
"classpath:spring-mybatis.xml" });
adminService = (AdminService) context.getBean("adminService");
}
/**
* Test method for
* {@link com.phn.bookhouse.service.impl.AdminServiceImpl#insertAdmin(com.phn.bookhouse.entity.Admin)}
* .
*/
// @Test
public void testInsertAdmin() {
|
Admin admin = new Admin();
|
WASdev/tool.lars
|
server/src/fat/java/com/ibm/ws/lars/rest/FrontPageTest.java
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
//
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
|
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;
|
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests for the LARS front page
*/
@RunWith(Parameterized.class)
public class FrontPageTest {
@Rule
public final RepositoryContext repository;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
//
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
// Path: server/src/fat/java/com/ibm/ws/lars/rest/FrontPageTest.java
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests for the LARS front page
*/
@RunWith(Parameterized.class)
public class FrontPageTest {
@Rule
public final RepositoryContext repository;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
|
return Arrays.asList(new Object[][] { { Protocol.HTTP, "http://localhost:" + FatUtils.LIBERTY_PORT_HTTP },
|
WASdev/tool.lars
|
server/src/fat/java/com/ibm/ws/lars/rest/FrontPageTest.java
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
//
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
|
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;
|
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests for the LARS front page
*/
@RunWith(Parameterized.class)
public class FrontPageTest {
@Rule
public final RepositoryContext repository;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
//
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
// Path: server/src/fat/java/com/ibm/ws/lars/rest/FrontPageTest.java
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests for the LARS front page
*/
@RunWith(Parameterized.class)
public class FrontPageTest {
@Rule
public final RepositoryContext repository;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
|
return Arrays.asList(new Object[][] { { Protocol.HTTP, "http://localhost:" + FatUtils.LIBERTY_PORT_HTTP },
|
WASdev/tool.lars
|
client-lib-tests/src/fat/java/com/ibm/ws/repository/test/RepositoryUtilsTest.java
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
|
import com.ibm.ws.repository.connections.RestRepositoryConnection;
import com.ibm.ws.repository.transport.exceptions.RequestFailureException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.ibm.ws.lars.testutils.FatUtils;
import com.ibm.ws.lars.testutils.fixtures.RepositoryFixture;
import com.ibm.ws.repository.connections.RepositoryConnection;
|
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.repository.test;
@RunWith(Parameterized.class)
public class RepositoryUtilsTest {
private final RepositoryConnection repoConnection;
@Rule
public final RepositoryFixture fixture;
@Parameters(name = "{0}")
public static Object[][] getParameters() {
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
// Path: client-lib-tests/src/fat/java/com/ibm/ws/repository/test/RepositoryUtilsTest.java
import com.ibm.ws.repository.connections.RestRepositoryConnection;
import com.ibm.ws.repository.transport.exceptions.RequestFailureException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.ibm.ws.lars.testutils.FatUtils;
import com.ibm.ws.lars.testutils.fixtures.RepositoryFixture;
import com.ibm.ws.repository.connections.RepositoryConnection;
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.repository.test;
@RunWith(Parameterized.class)
public class RepositoryUtilsTest {
private final RepositoryConnection repoConnection;
@Rule
public final RepositoryFixture fixture;
@Parameters(name = "{0}")
public static Object[][] getParameters() {
|
return FatUtils.getRestFixtureParameters();
|
WASdev/tool.lars
|
server/src/test/java/com/ibm/ws/lars/rest/ConfigurationTest.java
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/ReflectionTricks.java
// public class ReflectionTricks {
//
// /**
// * Invoke a method reflectively that does not use primitive arguments
// *
// * @param targetObject
// * @param methodName
// * @param varargs
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallNoPrimitives(Object targetObject, String methodName, Object... varargs)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",1)
// return reflectiveCallWithDefaultClass(targetObject, methodName, null, varargs);
// }
//
// /**
// * Invoke a method reflectively that does not use primitive arguments, with a default type for arguments.
// * If the argument is of the default type, or any subclass of it, then the default type will be used in the
// * method invocation.
// *
// * @param targetObject
// * @param methodName
// * @param defaultType
// * @param varargs
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallWithDefaultClass(Object targetObject, String methodName, Class defaultClass, Object... varargs)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",Object.class,1,"Foo")
//
// // create a class array from the vararg object array
// @SuppressWarnings("rawtypes")
// Class[] classes;
// if (varargs != null) {
// classes = new Class[varargs.length];
// for (int i = 0; i < varargs.length; i++) {
// Object arg = varargs[i];
// if(defaultClass != null && defaultClass.isInstance(arg)) {
// classes[i] = defaultClass;
// } else {
// classes[i] = arg.getClass();
// }
// }
// } else {
// classes = new Class[0];
// }
//
// return reflectiveCallAnyTypes(targetObject, methodName, classes, varargs);
// }
//
//
// /**
// * Invoke a method reflectively if that does not use primitive arguments
// *
// * @param targetObject
// * @param methodName
// * @param classes
// * @param values
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallAnyTypes(Object targetObject, String methodName, @SuppressWarnings("rawtypes") Class[] classes, Object[] values)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",
// // new Class[] {int.class},
// // new Object[] {9});
//
// // Get the class of the targetObject
// Class<?> c = null;
// if (targetObject instanceof Class) {
// c = (Class<?>) targetObject;
// } else {
// c = targetObject.getClass();
// }
//
// Method method = null;
// boolean finished = false;
// while (!finished) {
//
// try {
// // get method
// method = c.getDeclaredMethod(methodName, classes);
// finished = true;
// method.setAccessible(true);
// } catch (NoSuchMethodException nsme) {
// if (c.getName().equals("java.lang.Object")) {
// throw nsme;
// } else {
// c = c.getSuperclass();
// }
// }
// }
//
// return method.invoke(targetObject, values);
// }
//
// public static Asset getAsset(RepositoryResource resource) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// Method getAssetMethod = RepositoryResourceImpl.class.getDeclaredMethod("getAsset");
// getAssetMethod.setAccessible(true);
// return (Asset) getAssetMethod.invoke(resource);
// }
//
// }
|
import java.lang.reflect.InvocationTargetException;
import com.ibm.ws.lars.testutils.ReflectionTricks;
import static org.junit.Assert.assertEquals;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Test;
|
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Unit tests for the {@link Configuration} class
*/
public class ConfigurationTest {
@Test
public void testComputeRestAppURLBase() throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
String methodName = "computeRestBaseUri";
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/ReflectionTricks.java
// public class ReflectionTricks {
//
// /**
// * Invoke a method reflectively that does not use primitive arguments
// *
// * @param targetObject
// * @param methodName
// * @param varargs
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallNoPrimitives(Object targetObject, String methodName, Object... varargs)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",1)
// return reflectiveCallWithDefaultClass(targetObject, methodName, null, varargs);
// }
//
// /**
// * Invoke a method reflectively that does not use primitive arguments, with a default type for arguments.
// * If the argument is of the default type, or any subclass of it, then the default type will be used in the
// * method invocation.
// *
// * @param targetObject
// * @param methodName
// * @param defaultType
// * @param varargs
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallWithDefaultClass(Object targetObject, String methodName, Class defaultClass, Object... varargs)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",Object.class,1,"Foo")
//
// // create a class array from the vararg object array
// @SuppressWarnings("rawtypes")
// Class[] classes;
// if (varargs != null) {
// classes = new Class[varargs.length];
// for (int i = 0; i < varargs.length; i++) {
// Object arg = varargs[i];
// if(defaultClass != null && defaultClass.isInstance(arg)) {
// classes[i] = defaultClass;
// } else {
// classes[i] = arg.getClass();
// }
// }
// } else {
// classes = new Class[0];
// }
//
// return reflectiveCallAnyTypes(targetObject, methodName, classes, varargs);
// }
//
//
// /**
// * Invoke a method reflectively if that does not use primitive arguments
// *
// * @param targetObject
// * @param methodName
// * @param classes
// * @param values
// * @return
// * @throws ClassNotFoundException
// * @throws NoSuchMethodException
// * @throws SecurityException
// * @throws IllegalAccessException
// * @throws InstantiationException
// * @throws IllegalArgumentException
// * @throws InvocationTargetException
// */
// public static Object reflectiveCallAnyTypes(Object targetObject, String methodName, @SuppressWarnings("rawtypes") Class[] classes, Object[] values)
// throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, InstantiationException,
// IllegalArgumentException, InvocationTargetException {
//
// // Usage example of this method
// // int i = (Integer)reflectiveCallAnyTypes(targetObject,"methodName",
// // new Class[] {int.class},
// // new Object[] {9});
//
// // Get the class of the targetObject
// Class<?> c = null;
// if (targetObject instanceof Class) {
// c = (Class<?>) targetObject;
// } else {
// c = targetObject.getClass();
// }
//
// Method method = null;
// boolean finished = false;
// while (!finished) {
//
// try {
// // get method
// method = c.getDeclaredMethod(methodName, classes);
// finished = true;
// method.setAccessible(true);
// } catch (NoSuchMethodException nsme) {
// if (c.getName().equals("java.lang.Object")) {
// throw nsme;
// } else {
// c = c.getSuperclass();
// }
// }
// }
//
// return method.invoke(targetObject, values);
// }
//
// public static Asset getAsset(RepositoryResource resource) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// Method getAssetMethod = RepositoryResourceImpl.class.getDeclaredMethod("getAsset");
// getAssetMethod.setAccessible(true);
// return (Asset) getAssetMethod.invoke(resource);
// }
//
// }
// Path: server/src/test/java/com/ibm/ws/lars/rest/ConfigurationTest.java
import java.lang.reflect.InvocationTargetException;
import com.ibm.ws.lars.testutils.ReflectionTricks;
import static org.junit.Assert.assertEquals;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Test;
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Unit tests for the {@link Configuration} class
*/
public class ConfigurationTest {
@Test
public void testComputeRestAppURLBase() throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
String methodName = "computeRestBaseUri";
|
assertEquals("http://example.org/ma/v1/", ReflectionTricks.reflectiveCallNoPrimitives(Configuration.class, methodName, "http://example.org"));
|
WASdev/tool.lars
|
client-lib-tests/src/test/java/com/ibm/ws/repository/connections/test/SingleFileRepositoryConnectionTest.java
|
// Path: client-lib/src/main/java/com/ibm/ws/repository/connections/SingleFileRepositoryConnection.java
// public class SingleFileRepositoryConnection extends AbstractRepositoryConnection implements RepositoryConnection {
//
// private final File jsonFile;
//
// public SingleFileRepositoryConnection(File jsonFile) {
// this.jsonFile = jsonFile;
// }
//
// @Override
// public String getRepositoryLocation() {
// return jsonFile.getAbsolutePath();
// }
//
// @Override
// public RepositoryReadableClient createClient() {
// return new SingleFileClient(jsonFile);
// }
//
// /**
// * Create an empty single file Repository connection.
// * <p>
// * Repository data will be stored in {@code jsonFile} which must not exist and will be created by this method.
// *
// * @param jsonFile the location for the repository file
// * @return the repository connection
// * @throws IOException if {@code jsonFile} already exists or there is a problem creating the file
// */
// public static SingleFileRepositoryConnection createEmptyRepository(File jsonFile) throws IOException {
// if (jsonFile.exists()) {
// throw new IOException("Cannot create empty repository as the file already exists: " + jsonFile.getAbsolutePath());
// }
//
// OutputStreamWriter writer = null;
// try {
// writer = new OutputStreamWriter(new FileOutputStream(jsonFile), "UTF-8");
// writer.write("[]");
// } finally {
// if (writer != null) {
// writer.close();
// }
// }
//
// return new SingleFileRepositoryConnection(jsonFile);
// }
//
// }
|
import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.File;
import org.junit.After;
import org.junit.Test;
import com.ibm.ws.repository.connections.SingleFileRepositoryConnection;
import com.ibm.ws.repository.resources.RepositoryResource;
|
/*******************************************************************************
* Copyright (c) 2017 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.repository.connections.test;
/**
* Tests specific to the SingleFileRepositoryConnection
*/
public class SingleFileRepositoryConnectionTest {
private static final File FILE = new File("testSingleFileRepo");
@After
public void cleanup() {
if (FILE.exists()) {
FILE.delete();
}
}
@Test
public void testNoFileCheckStatus() {
|
// Path: client-lib/src/main/java/com/ibm/ws/repository/connections/SingleFileRepositoryConnection.java
// public class SingleFileRepositoryConnection extends AbstractRepositoryConnection implements RepositoryConnection {
//
// private final File jsonFile;
//
// public SingleFileRepositoryConnection(File jsonFile) {
// this.jsonFile = jsonFile;
// }
//
// @Override
// public String getRepositoryLocation() {
// return jsonFile.getAbsolutePath();
// }
//
// @Override
// public RepositoryReadableClient createClient() {
// return new SingleFileClient(jsonFile);
// }
//
// /**
// * Create an empty single file Repository connection.
// * <p>
// * Repository data will be stored in {@code jsonFile} which must not exist and will be created by this method.
// *
// * @param jsonFile the location for the repository file
// * @return the repository connection
// * @throws IOException if {@code jsonFile} already exists or there is a problem creating the file
// */
// public static SingleFileRepositoryConnection createEmptyRepository(File jsonFile) throws IOException {
// if (jsonFile.exists()) {
// throw new IOException("Cannot create empty repository as the file already exists: " + jsonFile.getAbsolutePath());
// }
//
// OutputStreamWriter writer = null;
// try {
// writer = new OutputStreamWriter(new FileOutputStream(jsonFile), "UTF-8");
// writer.write("[]");
// } finally {
// if (writer != null) {
// writer.close();
// }
// }
//
// return new SingleFileRepositoryConnection(jsonFile);
// }
//
// }
// Path: client-lib-tests/src/test/java/com/ibm/ws/repository/connections/test/SingleFileRepositoryConnectionTest.java
import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.File;
import org.junit.After;
import org.junit.Test;
import com.ibm.ws.repository.connections.SingleFileRepositoryConnection;
import com.ibm.ws.repository.resources.RepositoryResource;
/*******************************************************************************
* Copyright (c) 2017 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.repository.connections.test;
/**
* Tests specific to the SingleFileRepositoryConnection
*/
public class SingleFileRepositoryConnectionTest {
private static final File FILE = new File("testSingleFileRepo");
@After
public void cleanup() {
if (FILE.exists()) {
FILE.delete();
}
}
@Test
public void testNoFileCheckStatus() {
|
SingleFileRepositoryConnection repo = new SingleFileRepositoryConnection(FILE);
|
WASdev/tool.lars
|
cli-client/src/test/java/com/ibm/ws/lars/upload/cli/MainTest.java
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
|
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import org.junit.Test;
import com.ibm.ws.lars.testutils.FatUtils;
|
public MainRunner(String expectedExceptionMessage, int expectedStdoutLines) {
this.expectedExceptionMessage = expectedExceptionMessage;
this.expectedStdoutLines = expectedStdoutLines;
}
public void run(String... args) throws ClientException {
InputStream input = new ByteArrayInputStream(new byte[0]);
ByteArrayOutputStream stdoutBAOS = new ByteArrayOutputStream();
try (PrintStream output = new PrintStream(stdoutBAOS)) {
Main main = new Main(input, output);
Exception exception = null;
try {
main.run(args);
} catch (ClientException e) {
if (expectedExceptionMessage != null) {
exception = e;
assertEquals("Unexpected exception message", expectedExceptionMessage, e.getMessage());
} else {
throw e;
}
}
if (expectedExceptionMessage != null && exception == null) {
fail("The expected client exception was not thrown");
}
stdout = stdoutBAOS.toString();
assertEquals("The help output didn't contain the expected number of lines:\n" + stdout,
expectedStdoutLines,
|
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
//
// public static final String SCRIPT;
//
// public static final String DB_PORT;
// public static final String LIBERTY_PORT_HTTP;
// public static final String LIBERTY_PORT_HTTPS;
// public static final String TEST_DB_NAME;
// public static final String LARS_APPLICATION_ROOT;
// public static final String BASEURL_LIBERTY_PORT_HTTP;
//
// static {
// if (System.getProperty("os.name").startsWith("Windows")) {
// SCRIPT = "client/bin/larsClient.bat";
// } else {
// SCRIPT = "client/bin/larsClient";
// }
//
// Properties defaultConfig = new Properties();
// InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
// try {
// defaultConfig.load(propsStream);
// } catch (IOException e) {
// // Can't recover from this
// throw new RuntimeException("Unable to find config.properties file for database/server configuration");
// }
//
// DB_PORT = defaultConfig.getProperty("testMongoPort");
// LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
// LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
// TEST_DB_NAME = defaultConfig.getProperty("testDbName");
// LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
// BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
//
// }
//
// public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
//
// public static final String ADMIN_USERNAME = "admin";
//
// public static final String ADMIN_PASSWORD = "passw0rd";
//
// public static final String USER_ROLE_USERNAME = "user";
//
// public static final String USER_ROLE_PASSWORD = "passw0rd";
//
// public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
//
// public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
//
// private static DB fatDB = null;
//
// public static int countLines(String input) {
// int lines = 0;
// // If the last character isn't \n, add one, as that will make
// // the count match what you would normally expect
// if (input.charAt(input.length() - 1) != '\n') {
// lines = 1;
// }
// while (true) {
// int nlIndex = input.indexOf('\n');
// if (nlIndex == -1) {
// break;
// }
// lines++;
// input = input.substring(nlIndex + 1);
// }
// return lines;
// }
//
// public static Object[][] getRestFixtureParameters() {
// List<Object[]> objectList = new ArrayList<Object[]>();
//
// objectList.add(new Object[] { FAT_REPO });
//
// return objectList.toArray(new Object[objectList.size()][]);
// }
//
// /**
// * Returns a connection to the mongo database used for fat tests.
// * <p>
// * The same connection instance is returned to all tests.
// * <p>
// * We never explicitly close the client and rely on the connection being closed when the JVM
// * exits.
// */
// public static synchronized DB getMongoDB() throws UnknownHostException {
// if (fatDB == null) {
// MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
// fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
// }
// return fatDB;
// }
// }
// Path: cli-client/src/test/java/com/ibm/ws/lars/upload/cli/MainTest.java
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import org.junit.Test;
import com.ibm.ws.lars.testutils.FatUtils;
public MainRunner(String expectedExceptionMessage, int expectedStdoutLines) {
this.expectedExceptionMessage = expectedExceptionMessage;
this.expectedStdoutLines = expectedStdoutLines;
}
public void run(String... args) throws ClientException {
InputStream input = new ByteArrayInputStream(new byte[0]);
ByteArrayOutputStream stdoutBAOS = new ByteArrayOutputStream();
try (PrintStream output = new PrintStream(stdoutBAOS)) {
Main main = new Main(input, output);
Exception exception = null;
try {
main.run(args);
} catch (ClientException e) {
if (expectedExceptionMessage != null) {
exception = e;
assertEquals("Unexpected exception message", expectedExceptionMessage, e.getMessage());
} else {
throw e;
}
}
if (expectedExceptionMessage != null && exception == null) {
fail("The expected client exception was not thrown");
}
stdout = stdoutBAOS.toString();
assertEquals("The help output didn't contain the expected number of lines:\n" + stdout,
expectedStdoutLines,
|
FatUtils.countLines(stdout));
|
WASdev/tool.lars
|
server/src/fat/java/com/ibm/ws/lars/rest/ImCompatibilityTest.java
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
|
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.ByteArrayInputStream;
import java.util.Properties;
import org.junit.Rule;
import org.junit.Test;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
|
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests to check any additional requirements needed to support Installation Manager
*/
public class ImCompatibilityTest {
// Note that we only run this test against HTTPS (not HTTP).
@Rule
|
// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
// HTTP, HTTPS
// }
// Path: server/src/fat/java/com/ibm/ws/lars/rest/ImCompatibilityTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.ByteArrayInputStream;
import java.util.Properties;
import org.junit.Rule;
import org.junit.Test;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.ibm.ws.lars.rest;
/**
* Tests to check any additional requirements needed to support Installation Manager
*/
public class ImCompatibilityTest {
// Note that we only run this test against HTTPS (not HTTP).
@Rule
|
public RepositoryContext context = RepositoryContext.createAsUser(Protocol.HTTPS);
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/main/java/org/lilycms/hbaseindex/StringIndexFieldDefinition.java
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
//
// Path: src/util/src/main/java/org/lilycms/util/LocaleHelper.java
// public class LocaleHelper {
// public static Locale parseLocale(String localeString) {
// StringTokenizer localeParser = new StringTokenizer(localeString, "-_");
//
// String lang = null, country = null, variant = null;
//
// if (localeParser.hasMoreTokens())
// lang = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// country = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// variant = localeParser.nextToken();
//
// if (lang != null && country != null && variant != null)
// return new Locale(lang, country, variant);
// else if (lang != null && country != null)
// return new Locale(lang, country);
// else if (lang != null)
// return new Locale(lang);
// else
// return new Locale("");
// }
//
// public static String getString(Locale locale) {
// return getString(locale, "_");
// }
//
// public static String getString(Locale locale, String separator) {
// boolean hasLanguage = !locale.getLanguage().equals("");
// boolean hasCountry = !locale.getCountry().equals("");
// boolean hasVariant = !locale.getVariant().equals("");
//
// if (hasLanguage && hasCountry && hasVariant)
// return locale.getLanguage() + separator + locale.getCountry() + separator + locale.getVariant();
// else if (hasLanguage && hasCountry)
// return locale.getLanguage() + separator + locale.getCountry();
// else if (hasLanguage)
// return locale.getLanguage();
// else
// return "";
// }
// }
|
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import org.lilycms.util.LocaleHelper;
import java.io.UnsupportedEncodingException;
import java.text.Collator;
import java.text.Normalizer;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* A string field in an index.
*
* <p>Strings can be of variable length, therefore the {#setLength} method returns -1.
*
* <p>Various options can be set for this field:
*
* <ul>
* <li>{@link #setByteEncodeMode}: the way a string should be mapped onto bytes: as utf8,
* by folding everything to ascii, or by using collation keys.
* <li>
* <li>{@link #setLocale}
* <li>{@link #setCaseSensitive}
* </ul>
*/
public class StringIndexFieldDefinition extends IndexFieldDefinition {
public enum ByteEncodeMode { UTF8, ASCII_FOLDING, COLLATOR }
private Locale locale = Locale.US;
private ByteEncodeMode byteEncodeMode = ByteEncodeMode.UTF8;
private boolean caseSensitive = true;
private static Map<ByteEncodeMode, StringEncoder> ENCODERS;
static {
ENCODERS = new HashMap<ByteEncodeMode, StringEncoder>();
ENCODERS.put(ByteEncodeMode.UTF8, new Utf8StringEncoder());
ENCODERS.put(ByteEncodeMode.ASCII_FOLDING, new AsciiFoldingStringEncoder());
ENCODERS.put(ByteEncodeMode.COLLATOR, new CollatorStringEncoder());
}
/**
* The end-of-field marker consists of all-zero-bits bytes. This is to achieve the effect
* that shorter strings would always sort before those that contain an additional character.
* Supposing a zero is an allowed byte within an encoded string, the further bytes should
* again be zeros for the same purpose.
*
* <p>This makes the assumption that a sequence of zero bytes will not occur in an encoded
* string (see also the toBytes method where this is checked, and where the same sequence is also hardcoded!)
*/
private static final byte[] EOF_MARKER = new byte[] {0, 0, 0, 0};
public StringIndexFieldDefinition(String name) {
super(name, IndexValueType.STRING);
}
public StringIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.STRING, jsonObject);
if (jsonObject.get("locale") != null)
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
//
// Path: src/util/src/main/java/org/lilycms/util/LocaleHelper.java
// public class LocaleHelper {
// public static Locale parseLocale(String localeString) {
// StringTokenizer localeParser = new StringTokenizer(localeString, "-_");
//
// String lang = null, country = null, variant = null;
//
// if (localeParser.hasMoreTokens())
// lang = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// country = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// variant = localeParser.nextToken();
//
// if (lang != null && country != null && variant != null)
// return new Locale(lang, country, variant);
// else if (lang != null && country != null)
// return new Locale(lang, country);
// else if (lang != null)
// return new Locale(lang);
// else
// return new Locale("");
// }
//
// public static String getString(Locale locale) {
// return getString(locale, "_");
// }
//
// public static String getString(Locale locale, String separator) {
// boolean hasLanguage = !locale.getLanguage().equals("");
// boolean hasCountry = !locale.getCountry().equals("");
// boolean hasVariant = !locale.getVariant().equals("");
//
// if (hasLanguage && hasCountry && hasVariant)
// return locale.getLanguage() + separator + locale.getCountry() + separator + locale.getVariant();
// else if (hasLanguage && hasCountry)
// return locale.getLanguage() + separator + locale.getCountry();
// else if (hasLanguage)
// return locale.getLanguage();
// else
// return "";
// }
// }
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/StringIndexFieldDefinition.java
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import org.lilycms.util.LocaleHelper;
import java.io.UnsupportedEncodingException;
import java.text.Collator;
import java.text.Normalizer;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* A string field in an index.
*
* <p>Strings can be of variable length, therefore the {#setLength} method returns -1.
*
* <p>Various options can be set for this field:
*
* <ul>
* <li>{@link #setByteEncodeMode}: the way a string should be mapped onto bytes: as utf8,
* by folding everything to ascii, or by using collation keys.
* <li>
* <li>{@link #setLocale}
* <li>{@link #setCaseSensitive}
* </ul>
*/
public class StringIndexFieldDefinition extends IndexFieldDefinition {
public enum ByteEncodeMode { UTF8, ASCII_FOLDING, COLLATOR }
private Locale locale = Locale.US;
private ByteEncodeMode byteEncodeMode = ByteEncodeMode.UTF8;
private boolean caseSensitive = true;
private static Map<ByteEncodeMode, StringEncoder> ENCODERS;
static {
ENCODERS = new HashMap<ByteEncodeMode, StringEncoder>();
ENCODERS.put(ByteEncodeMode.UTF8, new Utf8StringEncoder());
ENCODERS.put(ByteEncodeMode.ASCII_FOLDING, new AsciiFoldingStringEncoder());
ENCODERS.put(ByteEncodeMode.COLLATOR, new CollatorStringEncoder());
}
/**
* The end-of-field marker consists of all-zero-bits bytes. This is to achieve the effect
* that shorter strings would always sort before those that contain an additional character.
* Supposing a zero is an allowed byte within an encoded string, the further bytes should
* again be zeros for the same purpose.
*
* <p>This makes the assumption that a sequence of zero bytes will not occur in an encoded
* string (see also the toBytes method where this is checked, and where the same sequence is also hardcoded!)
*/
private static final byte[] EOF_MARKER = new byte[] {0, 0, 0, 0};
public StringIndexFieldDefinition(String name) {
super(name, IndexValueType.STRING);
}
public StringIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.STRING, jsonObject);
if (jsonObject.get("locale") != null)
|
this.locale = LocaleHelper.parseLocale(jsonObject.get("locale").getTextValue());
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/main/java/org/lilycms/hbaseindex/StringIndexFieldDefinition.java
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
//
// Path: src/util/src/main/java/org/lilycms/util/LocaleHelper.java
// public class LocaleHelper {
// public static Locale parseLocale(String localeString) {
// StringTokenizer localeParser = new StringTokenizer(localeString, "-_");
//
// String lang = null, country = null, variant = null;
//
// if (localeParser.hasMoreTokens())
// lang = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// country = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// variant = localeParser.nextToken();
//
// if (lang != null && country != null && variant != null)
// return new Locale(lang, country, variant);
// else if (lang != null && country != null)
// return new Locale(lang, country);
// else if (lang != null)
// return new Locale(lang);
// else
// return new Locale("");
// }
//
// public static String getString(Locale locale) {
// return getString(locale, "_");
// }
//
// public static String getString(Locale locale, String separator) {
// boolean hasLanguage = !locale.getLanguage().equals("");
// boolean hasCountry = !locale.getCountry().equals("");
// boolean hasVariant = !locale.getVariant().equals("");
//
// if (hasLanguage && hasCountry && hasVariant)
// return locale.getLanguage() + separator + locale.getCountry() + separator + locale.getVariant();
// else if (hasLanguage && hasCountry)
// return locale.getLanguage() + separator + locale.getCountry();
// else if (hasLanguage)
// return locale.getLanguage();
// else
// return "";
// }
// }
|
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import org.lilycms.util.LocaleHelper;
import java.io.UnsupportedEncodingException;
import java.text.Collator;
import java.text.Normalizer;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* A string field in an index.
*
* <p>Strings can be of variable length, therefore the {#setLength} method returns -1.
*
* <p>Various options can be set for this field:
*
* <ul>
* <li>{@link #setByteEncodeMode}: the way a string should be mapped onto bytes: as utf8,
* by folding everything to ascii, or by using collation keys.
* <li>
* <li>{@link #setLocale}
* <li>{@link #setCaseSensitive}
* </ul>
*/
public class StringIndexFieldDefinition extends IndexFieldDefinition {
public enum ByteEncodeMode { UTF8, ASCII_FOLDING, COLLATOR }
private Locale locale = Locale.US;
private ByteEncodeMode byteEncodeMode = ByteEncodeMode.UTF8;
private boolean caseSensitive = true;
private static Map<ByteEncodeMode, StringEncoder> ENCODERS;
static {
ENCODERS = new HashMap<ByteEncodeMode, StringEncoder>();
ENCODERS.put(ByteEncodeMode.UTF8, new Utf8StringEncoder());
ENCODERS.put(ByteEncodeMode.ASCII_FOLDING, new AsciiFoldingStringEncoder());
ENCODERS.put(ByteEncodeMode.COLLATOR, new CollatorStringEncoder());
}
/**
* The end-of-field marker consists of all-zero-bits bytes. This is to achieve the effect
* that shorter strings would always sort before those that contain an additional character.
* Supposing a zero is an allowed byte within an encoded string, the further bytes should
* again be zeros for the same purpose.
*
* <p>This makes the assumption that a sequence of zero bytes will not occur in an encoded
* string (see also the toBytes method where this is checked, and where the same sequence is also hardcoded!)
*/
private static final byte[] EOF_MARKER = new byte[] {0, 0, 0, 0};
public StringIndexFieldDefinition(String name) {
super(name, IndexValueType.STRING);
}
public StringIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.STRING, jsonObject);
if (jsonObject.get("locale") != null)
this.locale = LocaleHelper.parseLocale(jsonObject.get("locale").getTextValue());
if (jsonObject.get("byteEncodeMode") != null)
this.byteEncodeMode = ByteEncodeMode.valueOf(jsonObject.get("byteEncodeMode").getTextValue());
if (jsonObject.get("caseSensitive") != null)
this.caseSensitive = jsonObject.get("caseSensitive").getBooleanValue();
}
public Locale getLocale() {
return locale;
}
/**
* The Locale to use. This locale is used to fold the case when
* case sensitivity is not desired, and is used in case the
* {@link ByteEncodeMode#COLLATOR} mode is selected.
*/
public void setLocale(Locale locale) {
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
//
// Path: src/util/src/main/java/org/lilycms/util/LocaleHelper.java
// public class LocaleHelper {
// public static Locale parseLocale(String localeString) {
// StringTokenizer localeParser = new StringTokenizer(localeString, "-_");
//
// String lang = null, country = null, variant = null;
//
// if (localeParser.hasMoreTokens())
// lang = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// country = localeParser.nextToken();
// if (localeParser.hasMoreTokens())
// variant = localeParser.nextToken();
//
// if (lang != null && country != null && variant != null)
// return new Locale(lang, country, variant);
// else if (lang != null && country != null)
// return new Locale(lang, country);
// else if (lang != null)
// return new Locale(lang);
// else
// return new Locale("");
// }
//
// public static String getString(Locale locale) {
// return getString(locale, "_");
// }
//
// public static String getString(Locale locale, String separator) {
// boolean hasLanguage = !locale.getLanguage().equals("");
// boolean hasCountry = !locale.getCountry().equals("");
// boolean hasVariant = !locale.getVariant().equals("");
//
// if (hasLanguage && hasCountry && hasVariant)
// return locale.getLanguage() + separator + locale.getCountry() + separator + locale.getVariant();
// else if (hasLanguage && hasCountry)
// return locale.getLanguage() + separator + locale.getCountry();
// else if (hasLanguage)
// return locale.getLanguage();
// else
// return "";
// }
// }
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/StringIndexFieldDefinition.java
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import org.lilycms.util.LocaleHelper;
import java.io.UnsupportedEncodingException;
import java.text.Collator;
import java.text.Normalizer;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* A string field in an index.
*
* <p>Strings can be of variable length, therefore the {#setLength} method returns -1.
*
* <p>Various options can be set for this field:
*
* <ul>
* <li>{@link #setByteEncodeMode}: the way a string should be mapped onto bytes: as utf8,
* by folding everything to ascii, or by using collation keys.
* <li>
* <li>{@link #setLocale}
* <li>{@link #setCaseSensitive}
* </ul>
*/
public class StringIndexFieldDefinition extends IndexFieldDefinition {
public enum ByteEncodeMode { UTF8, ASCII_FOLDING, COLLATOR }
private Locale locale = Locale.US;
private ByteEncodeMode byteEncodeMode = ByteEncodeMode.UTF8;
private boolean caseSensitive = true;
private static Map<ByteEncodeMode, StringEncoder> ENCODERS;
static {
ENCODERS = new HashMap<ByteEncodeMode, StringEncoder>();
ENCODERS.put(ByteEncodeMode.UTF8, new Utf8StringEncoder());
ENCODERS.put(ByteEncodeMode.ASCII_FOLDING, new AsciiFoldingStringEncoder());
ENCODERS.put(ByteEncodeMode.COLLATOR, new CollatorStringEncoder());
}
/**
* The end-of-field marker consists of all-zero-bits bytes. This is to achieve the effect
* that shorter strings would always sort before those that contain an additional character.
* Supposing a zero is an allowed byte within an encoded string, the further bytes should
* again be zeros for the same purpose.
*
* <p>This makes the assumption that a sequence of zero bytes will not occur in an encoded
* string (see also the toBytes method where this is checked, and where the same sequence is also hardcoded!)
*/
private static final byte[] EOF_MARKER = new byte[] {0, 0, 0, 0};
public StringIndexFieldDefinition(String name) {
super(name, IndexValueType.STRING);
}
public StringIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.STRING, jsonObject);
if (jsonObject.get("locale") != null)
this.locale = LocaleHelper.parseLocale(jsonObject.get("locale").getTextValue());
if (jsonObject.get("byteEncodeMode") != null)
this.byteEncodeMode = ByteEncodeMode.valueOf(jsonObject.get("byteEncodeMode").getTextValue());
if (jsonObject.get("caseSensitive") != null)
this.caseSensitive = jsonObject.get("caseSensitive").getBooleanValue();
}
public Locale getLocale() {
return locale;
}
/**
* The Locale to use. This locale is used to fold the case when
* case sensitivity is not desired, and is used in case the
* {@link ByteEncodeMode#COLLATOR} mode is selected.
*/
public void setLocale(Locale locale) {
|
ArgumentValidator.notNull(locale, "locale");
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/IndexTest.java
|
// Path: src/testfw/src/main/java/org/lilycms/testfw/TestHelper.java
// public class TestHelper {
// /**
// * Sets up logging such that errors are logged to the console, and info level
// * logging is sent to a file in target directory.
// */
// public static void setupLogging() throws IOException {
// final String LAYOUT = "[%t] %-5p %c - %m%n";
//
// Logger logger = Logger.getRootLogger();
// logger.removeAllAppenders();
// logger.setLevel(Level.INFO);
//
// //
// // Log to a file
// //
// FileAppender appender = new FileAppender();
// appender.setLayout(new PatternLayout(LAYOUT));
//
// // Maven sets a property basedir, but if the testcases are run outside Maven (e.g. by an IDE),
// // then fall back to the working directory
// String targetDir = System.getProperty("basedir");
// if (targetDir == null)
// targetDir = System.getProperty("user.dir");
// String logFileName = targetDir + "/target/log.txt";
//
// System.out.println("Log output will go to " + logFileName);
//
// appender.setFile(logFileName, false, false, 0);
//
// appender.activateOptions();
// logger.addAppender(appender);
//
// //
// // Add a console appender to show ERROR level errors on the console
// //
// ConsoleAppender consoleAppender = new ConsoleAppender();
// consoleAppender.setLayout(new PatternLayout(LAYOUT));
//
// LevelRangeFilter errorFilter = new LevelRangeFilter();
// errorFilter.setAcceptOnMatch(true);
// errorFilter.setLevelMin(Level.ERROR);
// errorFilter.setLevelMax(Level.ERROR);
// consoleAppender.addFilter(errorFilter);
// consoleAppender.activateOptions();
//
// logger.addAppender(consoleAppender);
// }
// }
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.lilycms.hbaseindex.*;
import org.lilycms.testfw.TestHelper;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class IndexTest {
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@BeforeClass
public static void setUpBeforeClass() throws Exception {
|
// Path: src/testfw/src/main/java/org/lilycms/testfw/TestHelper.java
// public class TestHelper {
// /**
// * Sets up logging such that errors are logged to the console, and info level
// * logging is sent to a file in target directory.
// */
// public static void setupLogging() throws IOException {
// final String LAYOUT = "[%t] %-5p %c - %m%n";
//
// Logger logger = Logger.getRootLogger();
// logger.removeAllAppenders();
// logger.setLevel(Level.INFO);
//
// //
// // Log to a file
// //
// FileAppender appender = new FileAppender();
// appender.setLayout(new PatternLayout(LAYOUT));
//
// // Maven sets a property basedir, but if the testcases are run outside Maven (e.g. by an IDE),
// // then fall back to the working directory
// String targetDir = System.getProperty("basedir");
// if (targetDir == null)
// targetDir = System.getProperty("user.dir");
// String logFileName = targetDir + "/target/log.txt";
//
// System.out.println("Log output will go to " + logFileName);
//
// appender.setFile(logFileName, false, false, 0);
//
// appender.activateOptions();
// logger.addAppender(appender);
//
// //
// // Add a console appender to show ERROR level errors on the console
// //
// ConsoleAppender consoleAppender = new ConsoleAppender();
// consoleAppender.setLayout(new PatternLayout(LAYOUT));
//
// LevelRangeFilter errorFilter = new LevelRangeFilter();
// errorFilter.setAcceptOnMatch(true);
// errorFilter.setLevelMin(Level.ERROR);
// errorFilter.setLevelMax(Level.ERROR);
// consoleAppender.addFilter(errorFilter);
// consoleAppender.activateOptions();
//
// logger.addAppender(consoleAppender);
// }
// }
// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/IndexTest.java
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.lilycms.hbaseindex.*;
import org.lilycms.testfw.TestHelper;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class IndexTest {
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@BeforeClass
public static void setUpBeforeClass() throws Exception {
|
TestHelper.setupLogging();
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/IdentifierEncodingTest.java
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IdentifierEncoding.java
// public class IdentifierEncoding {
// public static byte[] encode(byte[] bytes) {
// byte[] result = new byte[bytes.length + Bytes.SIZEOF_INT];
// System.arraycopy(bytes, 0, result, 0, bytes.length);
// Bytes.putInt(result, bytes.length, bytes.length);
// return result;
// }
//
// /**
// * Extracts the identifier from an index row key.
// *
// * @param bytes byte array containing an encoded row key at its end (and arbitrary bytes before that).
// * Note that this method modifies the bytes in case inverted is true!
// * @param inverted indicates if the bits in the row key are inverted (can be the case for descending ordering)
// */
// public static byte[] decode(byte[] bytes, boolean inverted) {
// if (inverted) {
// for (int i = 0; i < Bytes.SIZEOF_INT; i++) {
// int pos = bytes.length - i - 1;
// bytes[pos] = bytes[pos] ^= 0xFF;
// }
// }
//
// int keyLength = Bytes.toInt(bytes, bytes.length - Bytes.SIZEOF_INT);
// byte[] result = new byte[keyLength];
// System.arraycopy(bytes, bytes.length - keyLength - Bytes.SIZEOF_INT, result, 0, keyLength);
//
// if (inverted) {
// for (int j = 0; j < result.length; j++) {
// result[j] ^= 0xFF;
// }
// }
//
// return result;
// }
// }
|
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.IdentifierEncoding;
import static org.junit.Assert.*;
|
package org.lilycms.hbaseindex.test;
public class IdentifierEncodingTest {
@Test
public void test() {
byte[] key = Bytes.toBytes("foobar");
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IdentifierEncoding.java
// public class IdentifierEncoding {
// public static byte[] encode(byte[] bytes) {
// byte[] result = new byte[bytes.length + Bytes.SIZEOF_INT];
// System.arraycopy(bytes, 0, result, 0, bytes.length);
// Bytes.putInt(result, bytes.length, bytes.length);
// return result;
// }
//
// /**
// * Extracts the identifier from an index row key.
// *
// * @param bytes byte array containing an encoded row key at its end (and arbitrary bytes before that).
// * Note that this method modifies the bytes in case inverted is true!
// * @param inverted indicates if the bits in the row key are inverted (can be the case for descending ordering)
// */
// public static byte[] decode(byte[] bytes, boolean inverted) {
// if (inverted) {
// for (int i = 0; i < Bytes.SIZEOF_INT; i++) {
// int pos = bytes.length - i - 1;
// bytes[pos] = bytes[pos] ^= 0xFF;
// }
// }
//
// int keyLength = Bytes.toInt(bytes, bytes.length - Bytes.SIZEOF_INT);
// byte[] result = new byte[keyLength];
// System.arraycopy(bytes, bytes.length - keyLength - Bytes.SIZEOF_INT, result, 0, keyLength);
//
// if (inverted) {
// for (int j = 0; j < result.length; j++) {
// result[j] ^= 0xFF;
// }
// }
//
// return result;
// }
// }
// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/IdentifierEncodingTest.java
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.IdentifierEncoding;
import static org.junit.Assert.*;
package org.lilycms.hbaseindex.test;
public class IdentifierEncodingTest {
@Test
public void test() {
byte[] key = Bytes.toBytes("foobar");
|
assertEquals("foobar", Bytes.toString(IdentifierEncoding.decode(IdentifierEncoding.encode(key), false)));
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/main/java/org/lilycms/hbaseindex/DateTimeIndexFieldDefinition.java
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
|
import org.apache.hadoop.hbase.util.Bytes;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.util.*;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* Index field for datetimes, dates, times.
*
* <p>The instant is stored in the index as a long, or in case there is only a time
* component, as an integer.
*
* <p>This class accepts java.util.Date as date/time representation. It is up to the
* user to make sure any timezone corrections have happened already.
*/
public class DateTimeIndexFieldDefinition extends IndexFieldDefinition {
public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}
private Precision precision = Precision.DATETIME_NOMILLIS;
public DateTimeIndexFieldDefinition(String name) {
super(name, IndexValueType.DATETIME);
}
public DateTimeIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.DATETIME);
if (jsonObject.get("precision") != null)
this.precision = Precision.valueOf(jsonObject.get("precision").getTextValue());
}
public Precision getPrecision() {
return precision;
}
public void setPrecision(Precision precision) {
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/DateTimeIndexFieldDefinition.java
import org.apache.hadoop.hbase.util.Bytes;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.util.*;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* Index field for datetimes, dates, times.
*
* <p>The instant is stored in the index as a long, or in case there is only a time
* component, as an integer.
*
* <p>This class accepts java.util.Date as date/time representation. It is up to the
* user to make sure any timezone corrections have happened already.
*/
public class DateTimeIndexFieldDefinition extends IndexFieldDefinition {
public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}
private Precision precision = Precision.DATETIME_NOMILLIS;
public DateTimeIndexFieldDefinition(String name) {
super(name, IndexValueType.DATETIME);
}
public DateTimeIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, IndexValueType.DATETIME);
if (jsonObject.get("precision") != null)
this.precision = Precision.valueOf(jsonObject.get("precision").getTextValue());
}
public Precision getPrecision() {
return precision;
}
public void setPrecision(Precision precision) {
|
ArgumentValidator.notNull(precision, "precision");
|
adragomir/hbase-indexing-library
|
src/util/src/main/java/org/lilycms/util/location/LocationImpl.java
|
// Path: src/util/src/main/java/org/lilycms/util/ObjectUtils.java
// public class ObjectUtils {
// public static boolean safeEquals(Object obj1, Object obj2) {
// if (obj1 == null && obj2 == null)
// return true;
// else if (obj1 == null || obj2 == null)
// return false;
// else
// return obj1.equals(obj2);
// }
// }
|
import org.lilycms.util.ObjectUtils;
import java.io.Serializable;
|
return this.uri;
}
/**
* Get the line number of this location
*
* @return the line number (<code>-1</code> if unknown)
*/
public int getLineNumber() {
return this.line;
}
/**
* Get the column number of this location
*
* @return the column number (<code>-1</code> if unknown)
*/
public int getColumnNumber() {
return this.column;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Location) {
Location other = (Location) obj;
return this.line == other.getLineNumber() &&
this.column == other.getColumnNumber() &&
|
// Path: src/util/src/main/java/org/lilycms/util/ObjectUtils.java
// public class ObjectUtils {
// public static boolean safeEquals(Object obj1, Object obj2) {
// if (obj1 == null && obj2 == null)
// return true;
// else if (obj1 == null || obj2 == null)
// return false;
// else
// return obj1.equals(obj2);
// }
// }
// Path: src/util/src/main/java/org/lilycms/util/location/LocationImpl.java
import org.lilycms.util.ObjectUtils;
import java.io.Serializable;
return this.uri;
}
/**
* Get the line number of this location
*
* @return the line number (<code>-1</code> if unknown)
*/
public int getLineNumber() {
return this.line;
}
/**
* Get the column number of this location
*
* @return the column number (<code>-1</code> if unknown)
*/
public int getColumnNumber() {
return this.column;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Location) {
Location other = (Location) obj;
return this.line == other.getLineNumber() &&
this.column == other.getColumnNumber() &&
|
ObjectUtils.safeEquals(this.uri, other.getURI()) &&
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IndexDefinition.java
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
|
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.lang.reflect.Constructor;
import java.util.*;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* Defines the structure of an index.
*
* <p>An index is defined by instantiating an object of this class, adding one
* or more fields to it using the methods like {@link #addStringField},
* {@link #addIntegerField}, etc. Finally the index is created by calling
* {@link IndexManager#createIndex}. After creation, the definition of an index
* cannot be modified.
*/
public class IndexDefinition {
private String table;
private String name;
private List<IndexFieldDefinition> fields = new ArrayList<IndexFieldDefinition>();
private Map<String, IndexFieldDefinition> fieldsByName = new HashMap<String, IndexFieldDefinition>();
private Order identifierOrder = Order.ASCENDING;
public IndexDefinition(String table, String name) {
|
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
// public static void notNull(Object object, String argName) {
// if (object == null)
// throw new IllegalArgumentException("Null argument: " + argName);
// }
// }
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/IndexDefinition.java
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.lang.reflect.Constructor;
import java.util.*;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex;
/**
* Defines the structure of an index.
*
* <p>An index is defined by instantiating an object of this class, adding one
* or more fields to it using the methods like {@link #addStringField},
* {@link #addIntegerField}, etc. Finally the index is created by calling
* {@link IndexManager#createIndex}. After creation, the definition of an index
* cannot be modified.
*/
public class IndexDefinition {
private String table;
private String name;
private List<IndexFieldDefinition> fields = new ArrayList<IndexFieldDefinition>();
private Map<String, IndexFieldDefinition> fieldsByName = new HashMap<String, IndexFieldDefinition>();
private Order identifierOrder = Order.ASCENDING;
public IndexDefinition(String table, String name) {
|
ArgumentValidator.notNull(name, "table");
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/MergeJoinTest.java
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Conjunction.java
// public class Conjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
//
// public Conjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// byte[] key1 = result1.next();
// byte[] key2 = result2.next();
//
// if (key1 == null || key2 == null)
// return null;
//
// int cmp = Bytes.compareTo(key1, key2);
//
// while (cmp != 0) {
// if (cmp < 0) {
// while (cmp < 0) {
// key1 = result1.next();
// if (key1 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// } else if (cmp > 0) {
// while (cmp > 0) {
// key2 = result2.next();
// if (key2 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// }
// }
//
// currentQResult = result1;
// return key1;
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Disjunction.java
// public class Disjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
// private byte[] key1;
// private byte[] key2;
// private boolean init = false;
//
// public Disjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// if (!init) {
// key1 = result1.next();
// key2 = result2.next();
// init = true;
// }
//
// if (key1 == null && key2 == null) {
// return null;
// } else if (key1 == null) {
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// } else if (key2 == null) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// }
//
// int cmp = Bytes.compareTo(key1, key2);
//
// if (cmp == 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// key2 = result2.next();
// return result;
// } else if (cmp < 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// } else { // cmp > 0
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// }
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/QueryResult.java
// public interface QueryResult {
//
// /**
// * Move to and return the next result.
// *
// * @return the identifier of the next matching query result, or null if the end is reached.
// */
// public byte[] next() throws IOException;
//
// /**
// * Retrieves data that was stored as part of the {@link IndexEntry} from the current index
// * entry (corresponding to the last {@link #next} call).
// */
// public byte[] getData(byte[] qualifier);
//
// public byte[] getData(String qualifier);
//
// public String getDataAsString(String qualifier);
// }
|
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.Conjunction;
import org.lilycms.hbaseindex.Disjunction;
import org.lilycms.hbaseindex.QueryResult;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class MergeJoinTest {
@Test
public void testConjunction() throws Exception {
String[] values1 = {"a", "b", "c", "f", "g"};
String[] values2 = { "b", "c", "d", "e", "f"};
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Conjunction.java
// public class Conjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
//
// public Conjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// byte[] key1 = result1.next();
// byte[] key2 = result2.next();
//
// if (key1 == null || key2 == null)
// return null;
//
// int cmp = Bytes.compareTo(key1, key2);
//
// while (cmp != 0) {
// if (cmp < 0) {
// while (cmp < 0) {
// key1 = result1.next();
// if (key1 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// } else if (cmp > 0) {
// while (cmp > 0) {
// key2 = result2.next();
// if (key2 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// }
// }
//
// currentQResult = result1;
// return key1;
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Disjunction.java
// public class Disjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
// private byte[] key1;
// private byte[] key2;
// private boolean init = false;
//
// public Disjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// if (!init) {
// key1 = result1.next();
// key2 = result2.next();
// init = true;
// }
//
// if (key1 == null && key2 == null) {
// return null;
// } else if (key1 == null) {
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// } else if (key2 == null) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// }
//
// int cmp = Bytes.compareTo(key1, key2);
//
// if (cmp == 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// key2 = result2.next();
// return result;
// } else if (cmp < 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// } else { // cmp > 0
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// }
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/QueryResult.java
// public interface QueryResult {
//
// /**
// * Move to and return the next result.
// *
// * @return the identifier of the next matching query result, or null if the end is reached.
// */
// public byte[] next() throws IOException;
//
// /**
// * Retrieves data that was stored as part of the {@link IndexEntry} from the current index
// * entry (corresponding to the last {@link #next} call).
// */
// public byte[] getData(byte[] qualifier);
//
// public byte[] getData(String qualifier);
//
// public String getDataAsString(String qualifier);
// }
// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/MergeJoinTest.java
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.Conjunction;
import org.lilycms.hbaseindex.Disjunction;
import org.lilycms.hbaseindex.QueryResult;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class MergeJoinTest {
@Test
public void testConjunction() throws Exception {
String[] values1 = {"a", "b", "c", "f", "g"};
String[] values2 = { "b", "c", "d", "e", "f"};
|
QueryResult result = new Conjunction(buildQueryResult(values1), buildQueryResult(values2));
|
adragomir/hbase-indexing-library
|
src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/MergeJoinTest.java
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Conjunction.java
// public class Conjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
//
// public Conjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// byte[] key1 = result1.next();
// byte[] key2 = result2.next();
//
// if (key1 == null || key2 == null)
// return null;
//
// int cmp = Bytes.compareTo(key1, key2);
//
// while (cmp != 0) {
// if (cmp < 0) {
// while (cmp < 0) {
// key1 = result1.next();
// if (key1 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// } else if (cmp > 0) {
// while (cmp > 0) {
// key2 = result2.next();
// if (key2 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// }
// }
//
// currentQResult = result1;
// return key1;
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Disjunction.java
// public class Disjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
// private byte[] key1;
// private byte[] key2;
// private boolean init = false;
//
// public Disjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// if (!init) {
// key1 = result1.next();
// key2 = result2.next();
// init = true;
// }
//
// if (key1 == null && key2 == null) {
// return null;
// } else if (key1 == null) {
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// } else if (key2 == null) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// }
//
// int cmp = Bytes.compareTo(key1, key2);
//
// if (cmp == 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// key2 = result2.next();
// return result;
// } else if (cmp < 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// } else { // cmp > 0
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// }
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/QueryResult.java
// public interface QueryResult {
//
// /**
// * Move to and return the next result.
// *
// * @return the identifier of the next matching query result, or null if the end is reached.
// */
// public byte[] next() throws IOException;
//
// /**
// * Retrieves data that was stored as part of the {@link IndexEntry} from the current index
// * entry (corresponding to the last {@link #next} call).
// */
// public byte[] getData(byte[] qualifier);
//
// public byte[] getData(String qualifier);
//
// public String getDataAsString(String qualifier);
// }
|
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.Conjunction;
import org.lilycms.hbaseindex.Disjunction;
import org.lilycms.hbaseindex.QueryResult;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
|
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class MergeJoinTest {
@Test
public void testConjunction() throws Exception {
String[] values1 = {"a", "b", "c", "f", "g"};
String[] values2 = { "b", "c", "d", "e", "f"};
|
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Conjunction.java
// public class Conjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
//
// public Conjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// byte[] key1 = result1.next();
// byte[] key2 = result2.next();
//
// if (key1 == null || key2 == null)
// return null;
//
// int cmp = Bytes.compareTo(key1, key2);
//
// while (cmp != 0) {
// if (cmp < 0) {
// while (cmp < 0) {
// key1 = result1.next();
// if (key1 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// } else if (cmp > 0) {
// while (cmp > 0) {
// key2 = result2.next();
// if (key2 == null)
// return null;
// cmp = Bytes.compareTo(key1, key2);
// }
// }
// }
//
// currentQResult = result1;
// return key1;
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/Disjunction.java
// public class Disjunction extends BaseQueryResult {
// private QueryResult result1;
// private QueryResult result2;
// private byte[] key1;
// private byte[] key2;
// private boolean init = false;
//
// public Disjunction(QueryResult result1, QueryResult result2) {
// this.result1 = result1;
// this.result2 = result2;
// }
//
// public byte[] next() throws IOException {
// if (!init) {
// key1 = result1.next();
// key2 = result2.next();
// init = true;
// }
//
// if (key1 == null && key2 == null) {
// return null;
// } else if (key1 == null) {
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// } else if (key2 == null) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// }
//
// int cmp = Bytes.compareTo(key1, key2);
//
// if (cmp == 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// key2 = result2.next();
// return result;
// } else if (cmp < 0) {
// byte[] result = key1;
// currentQResult = result1;
// key1 = result1.next();
// return result;
// } else { // cmp > 0
// byte[] result = key2;
// currentQResult = result2;
// key2 = result2.next();
// return result;
// }
// }
// }
//
// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/QueryResult.java
// public interface QueryResult {
//
// /**
// * Move to and return the next result.
// *
// * @return the identifier of the next matching query result, or null if the end is reached.
// */
// public byte[] next() throws IOException;
//
// /**
// * Retrieves data that was stored as part of the {@link IndexEntry} from the current index
// * entry (corresponding to the last {@link #next} call).
// */
// public byte[] getData(byte[] qualifier);
//
// public byte[] getData(String qualifier);
//
// public String getDataAsString(String qualifier);
// }
// Path: src/hbaseindex/src/test/java/org/lilycms/hbaseindex/test/MergeJoinTest.java
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.lilycms.hbaseindex.Conjunction;
import org.lilycms.hbaseindex.Disjunction;
import org.lilycms.hbaseindex.QueryResult;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilycms.hbaseindex.test;
public class MergeJoinTest {
@Test
public void testConjunction() throws Exception {
String[] values1 = {"a", "b", "c", "f", "g"};
String[] values2 = { "b", "c", "d", "e", "f"};
|
QueryResult result = new Conjunction(buildQueryResult(values1), buildQueryResult(values2));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.