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 |
|---|---|---|---|---|---|---|
arconsis/droitatedDB | droitatedDB/src/main/java/org/droitateddb/EntityService.java | // Path: droitatedDB/src/main/java/org/droitateddb/schema/EntityInfo.java
// public class EntityInfo {
// private final String tableName;
// private final String className;
// private final Class<?> definition;
// private final boolean validation;
//
// public EntityInfo(final String className, final String tableName, final Class<?> definition) {
// this.className = className;
// this.tableName = tableName;
// this.definition = definition;
// this.validation = false;
// }
//
// public EntityInfo(final String className, final String tableName, final Class<?> definition, final boolean validation) {
// this.className = className;
// this.tableName = tableName;
// this.definition = definition;
// this.validation = validation;
// }
//
// public String className() {
// return className;
// }
//
// public String table() {
// return tableName;
// }
//
// public Class<?> definition() {
// return definition;
// }
//
// public boolean hasValidation() {
// return validation;
// }
// }
//
// Path: droitatedDB/src/main/java/org/droitateddb/Utilities.java
// static <T> T getFieldValue(Class<?> aClass, String fieldName, Object data) {
// return getFieldValue(data, getDeclaredField(aClass, fieldName));
// }
| import java.util.Collection;
import java.util.List;
import static org.droitateddb.Utilities.getFieldValue;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import org.droitateddb.cursor.CombinedCursorImpl;
import org.droitateddb.entity.Column;
import org.droitateddb.entity.Entity;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.schema.EntityInfo;
import org.droitateddb.validation.AccumulatedValidationResult;
import org.droitateddb.validation.InvalidEntityException;
import org.droitateddb.validation.ValidationToggle;
import java.lang.reflect.Field;
import java.util.ArrayList; | throw new InvalidEntityException(validationResult);
}
}
SQLiteDatabase database = openDB();
try {
final DatabaseSaver databaseSaver = new DatabaseSaver(database, maxDepth);
transactional(database, new DatabaseOperation<Void>() {
@Override
public Void execute() {
for (E object : data) {
databaseSaver.save(object);
}
return null;
}
});
} finally {
closeDB(database);
}
}
/**
* Deletes the given {@link Entity} from the database
*
* @param data {@link Entity} that should be deleted
* @return <code>true</code> if the {@link Entity} could be deleted, <code>false</code> otherwise
* @throws IllegalStateException When the {@link PrimaryKey} field and its value of the {@link Entity} could not be determined
* @throws IllegalArgumentException When the value of the {@link PrimaryKey} field is null
*/
public boolean delete(final E data) { | // Path: droitatedDB/src/main/java/org/droitateddb/schema/EntityInfo.java
// public class EntityInfo {
// private final String tableName;
// private final String className;
// private final Class<?> definition;
// private final boolean validation;
//
// public EntityInfo(final String className, final String tableName, final Class<?> definition) {
// this.className = className;
// this.tableName = tableName;
// this.definition = definition;
// this.validation = false;
// }
//
// public EntityInfo(final String className, final String tableName, final Class<?> definition, final boolean validation) {
// this.className = className;
// this.tableName = tableName;
// this.definition = definition;
// this.validation = validation;
// }
//
// public String className() {
// return className;
// }
//
// public String table() {
// return tableName;
// }
//
// public Class<?> definition() {
// return definition;
// }
//
// public boolean hasValidation() {
// return validation;
// }
// }
//
// Path: droitatedDB/src/main/java/org/droitateddb/Utilities.java
// static <T> T getFieldValue(Class<?> aClass, String fieldName, Object data) {
// return getFieldValue(data, getDeclaredField(aClass, fieldName));
// }
// Path: droitatedDB/src/main/java/org/droitateddb/EntityService.java
import java.util.Collection;
import java.util.List;
import static org.droitateddb.Utilities.getFieldValue;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import org.droitateddb.cursor.CombinedCursorImpl;
import org.droitateddb.entity.Column;
import org.droitateddb.entity.Entity;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.schema.EntityInfo;
import org.droitateddb.validation.AccumulatedValidationResult;
import org.droitateddb.validation.InvalidEntityException;
import org.droitateddb.validation.ValidationToggle;
import java.lang.reflect.Field;
import java.util.ArrayList;
throw new InvalidEntityException(validationResult);
}
}
SQLiteDatabase database = openDB();
try {
final DatabaseSaver databaseSaver = new DatabaseSaver(database, maxDepth);
transactional(database, new DatabaseOperation<Void>() {
@Override
public Void execute() {
for (E object : data) {
databaseSaver.save(object);
}
return null;
}
});
} finally {
closeDB(database);
}
}
/**
* Deletes the given {@link Entity} from the database
*
* @param data {@link Entity} that should be deleted
* @return <code>true</code> if the {@link Entity} could be deleted, <code>false</code> otherwise
* @throws IllegalStateException When the {@link PrimaryKey} field and its value of the {@link Entity} could not be determined
* @throws IllegalArgumentException When the value of the {@link PrimaryKey} field is null
*/
public boolean delete(final E data) { | Number id = getFieldValue(data, primaryKey); |
arconsis/droitatedDB | droitatedDB/src/main/java/org/droitateddb/Utilities.java | // Path: droitatedDB/src/main/java/org/droitateddb/schema/AbstractAttribute.java
// public abstract class AbstractAttribute {
//
// private final String fieldName;
// private final String columnName;
// private final Class<?> fieldType;
// private final ColumnType type;
// private final int columnIdx;
// private final ColumnValidator[] columnValidators;
//
// public AbstractAttribute(final ColumnType type, final String fieldName, final Class<?> fieldType, final int columnIdx, final ColumnValidator... columnValidators) {
// this(type, fieldName, fieldName, fieldType, columnIdx, columnValidators);
// }
//
// public AbstractAttribute(final ColumnType type, final String fieldName, final String columnName, final Class<?> fieldType, final int columnIdx, final ColumnValidator... columnValidators) {
// this.type = type;
// this.fieldName = fieldName;
// this.columnName = columnName;
// this.fieldType = fieldType;
// this.columnIdx = columnIdx;
// if (columnValidators == null) {
// this.columnValidators = new ColumnValidator[0];
// } else {
// this.columnValidators = columnValidators;
// }
// }
//
// public String fieldName() {
// return fieldName;
// }
//
// public String columnName() {
// return columnName;
// }
//
// public int columnIndex() {
// return columnIdx;
// }
//
// public Class<?> type() {
// return fieldType;
// }
//
// public ColumnType sqliteType() {
// return type;
// }
//
// public ColumnValidator[] getColumnValidators() {
// return columnValidators;
// }
//
// /**
// * Returns also the columnName of the attribute
// */
// @Override
// public String toString() {
// return columnName();
// }
//
// public Object getValueFromCursor(final Cursor originalCursor) {
// if (originalCursor.isNull(columnIdx) && !isPrimitiveField()) {
// return null;
// }
// return getNonNullValueFromCursor(originalCursor);
// }
//
// protected abstract Object getNonNullValueFromCursor(final Cursor originalCursor);
//
// private final boolean isPrimitiveField() {
// Class<?> paramType = type();
// return paramType.equals(java.lang.Boolean.TYPE) //
// || paramType.equals(java.lang.Integer.TYPE) //
// || paramType.equals(java.lang.Character.TYPE) //
// || paramType.equals(java.lang.Float.TYPE) //
// || paramType.equals(java.lang.Double.TYPE) //
// || paramType.equals(java.lang.Long.TYPE) //
// || paramType.equals(java.lang.Short.TYPE);
// }
// }
| import org.droitateddb.schema.AbstractAttribute;
import org.droitateddb.schema.SchemaConstants;
import java.lang.reflect.Field; | /*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb;
/**
* Provides utility methods for droitated DB.
*
* @author Falk Appel
* @author Alexander Frank
*/
public class Utilities {
public static RuntimeException handle(Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
static void setFieldValue(Field field, final Object data, Object value) {
try {
field.setAccessible(true);
field.set(data, value);
} catch (IllegalAccessException e) {
throw handle(e);
}
}
static String getLinkTableName(Class<?> linkTableSchema) {
return getStaticFieldValue(linkTableSchema, SchemaConstants.TABLE_NAME);
}
| // Path: droitatedDB/src/main/java/org/droitateddb/schema/AbstractAttribute.java
// public abstract class AbstractAttribute {
//
// private final String fieldName;
// private final String columnName;
// private final Class<?> fieldType;
// private final ColumnType type;
// private final int columnIdx;
// private final ColumnValidator[] columnValidators;
//
// public AbstractAttribute(final ColumnType type, final String fieldName, final Class<?> fieldType, final int columnIdx, final ColumnValidator... columnValidators) {
// this(type, fieldName, fieldName, fieldType, columnIdx, columnValidators);
// }
//
// public AbstractAttribute(final ColumnType type, final String fieldName, final String columnName, final Class<?> fieldType, final int columnIdx, final ColumnValidator... columnValidators) {
// this.type = type;
// this.fieldName = fieldName;
// this.columnName = columnName;
// this.fieldType = fieldType;
// this.columnIdx = columnIdx;
// if (columnValidators == null) {
// this.columnValidators = new ColumnValidator[0];
// } else {
// this.columnValidators = columnValidators;
// }
// }
//
// public String fieldName() {
// return fieldName;
// }
//
// public String columnName() {
// return columnName;
// }
//
// public int columnIndex() {
// return columnIdx;
// }
//
// public Class<?> type() {
// return fieldType;
// }
//
// public ColumnType sqliteType() {
// return type;
// }
//
// public ColumnValidator[] getColumnValidators() {
// return columnValidators;
// }
//
// /**
// * Returns also the columnName of the attribute
// */
// @Override
// public String toString() {
// return columnName();
// }
//
// public Object getValueFromCursor(final Cursor originalCursor) {
// if (originalCursor.isNull(columnIdx) && !isPrimitiveField()) {
// return null;
// }
// return getNonNullValueFromCursor(originalCursor);
// }
//
// protected abstract Object getNonNullValueFromCursor(final Cursor originalCursor);
//
// private final boolean isPrimitiveField() {
// Class<?> paramType = type();
// return paramType.equals(java.lang.Boolean.TYPE) //
// || paramType.equals(java.lang.Integer.TYPE) //
// || paramType.equals(java.lang.Character.TYPE) //
// || paramType.equals(java.lang.Float.TYPE) //
// || paramType.equals(java.lang.Double.TYPE) //
// || paramType.equals(java.lang.Long.TYPE) //
// || paramType.equals(java.lang.Short.TYPE);
// }
// }
// Path: droitatedDB/src/main/java/org/droitateddb/Utilities.java
import org.droitateddb.schema.AbstractAttribute;
import org.droitateddb.schema.SchemaConstants;
import java.lang.reflect.Field;
/*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb;
/**
* Provides utility methods for droitated DB.
*
* @author Falk Appel
* @author Alexander Frank
*/
public class Utilities {
public static RuntimeException handle(Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
static void setFieldValue(Field field, final Object data, Object value) {
try {
field.setAccessible(true);
field.set(data, value);
} catch (IllegalAccessException e) {
throw handle(e);
}
}
static String getLinkTableName(Class<?> linkTableSchema) {
return getStaticFieldValue(linkTableSchema, SchemaConstants.TABLE_NAME);
}
| static AbstractAttribute[] getLinkTableColumns(Class<?> linkTableSchema) { |
arconsis/droitatedDB | droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/TableReader.java | // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/Table.java
// public class Table {
//
// private final String name;
// private final String entityClassName;
//
// private final Set<Column> columns = new TreeSet<Column>(new Comparator<Column>() {
// @Override
// public int compare(final Column c1, final Column c2) {
// return c1.getNameInEntity().compareTo(c2.getNameInEntity());
// }
// });
// private final Set<Association> associations = new TreeSet<Association>(new Comparator<Association>() {
// @Override
// public int compare(final Association a1, final Association a2) {
// return a1.getNameInEntity().compareTo(a2.getNameInEntity());
// }
// });
//
// public Table(final String name, final String entityClassName) {
// this.name = name;
// this.entityClassName = entityClassName;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEntityClassName() {
// return entityClassName;
// }
//
// public Set<Column> getColumns() {
// return Collections.unmodifiableSet(columns);
// }
//
// public void addColumn(final Column column) {
// columns.add(column);
// }
//
// public Set<Association> getAssociations() {
// return Collections.unmodifiableSet(associations);
// }
//
// public void addAssociation(final Association association) {
// associations.add(association);
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/AssociationElementResolvingTypeVisitor.java
// public class AssociationElementResolvingTypeVisitor extends DefaultElementVisitor<VariableElement, Void> {
//
// @Override
// public VariableElement visitVariable(final VariableElement e, final Void p) {
// if (e.getAnnotation(Relationship.class) != null) {
// return e;
// } else {
// return null;
// }
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/EmptyContructorVisitor.java
// public class EmptyContructorVisitor extends DefaultElementVisitor<ExecutableElement, Void> {
// @Override
// public ExecutableElement visitExecutable(final ExecutableElement e, final Void p) {
// if ("<init>".equals(e.getSimpleName().toString()) && e.getParameters().size() == 0) {
// return e;
// }
// return null;
// }
// }
| import javax.tools.Diagnostic.Kind;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.droitateddb.builder.schema.data.Association;
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.Table;
import org.droitateddb.builder.schema.visitor.AssociationElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.ColumnElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.EmptyContructorVisitor;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.entity.Relationship;
import org.droitateddb.schema.AssociationType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements; | /*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb.builder.schema.reader;
/**
* @author Alexander Frank
* @author Falk Appel
*/
public class TableReader implements Reader<Table> {
private final TypeElement entity;
private final Set<String> entityNames;
private final Elements elements;
private final Messager messager;
public TableReader(final TypeElement entity, final Set<String> entityNames, final Elements elements, final Messager messager) {
this.entity = entity;
this.entityNames = entityNames;
this.elements = elements;
this.messager = messager;
}
@Override
public Table read() {
int primaryKeyCount = 0;
boolean noArgsConstructor = false;
Table table = new Table(entity.getSimpleName().toString(), entity.toString());
Map<String, AtomicInteger> countedToManyAssociations = new HashMap<String, AtomicInteger>();
for (Element child : entity.getEnclosedElements()) { | // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/Table.java
// public class Table {
//
// private final String name;
// private final String entityClassName;
//
// private final Set<Column> columns = new TreeSet<Column>(new Comparator<Column>() {
// @Override
// public int compare(final Column c1, final Column c2) {
// return c1.getNameInEntity().compareTo(c2.getNameInEntity());
// }
// });
// private final Set<Association> associations = new TreeSet<Association>(new Comparator<Association>() {
// @Override
// public int compare(final Association a1, final Association a2) {
// return a1.getNameInEntity().compareTo(a2.getNameInEntity());
// }
// });
//
// public Table(final String name, final String entityClassName) {
// this.name = name;
// this.entityClassName = entityClassName;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEntityClassName() {
// return entityClassName;
// }
//
// public Set<Column> getColumns() {
// return Collections.unmodifiableSet(columns);
// }
//
// public void addColumn(final Column column) {
// columns.add(column);
// }
//
// public Set<Association> getAssociations() {
// return Collections.unmodifiableSet(associations);
// }
//
// public void addAssociation(final Association association) {
// associations.add(association);
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/AssociationElementResolvingTypeVisitor.java
// public class AssociationElementResolvingTypeVisitor extends DefaultElementVisitor<VariableElement, Void> {
//
// @Override
// public VariableElement visitVariable(final VariableElement e, final Void p) {
// if (e.getAnnotation(Relationship.class) != null) {
// return e;
// } else {
// return null;
// }
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/EmptyContructorVisitor.java
// public class EmptyContructorVisitor extends DefaultElementVisitor<ExecutableElement, Void> {
// @Override
// public ExecutableElement visitExecutable(final ExecutableElement e, final Void p) {
// if ("<init>".equals(e.getSimpleName().toString()) && e.getParameters().size() == 0) {
// return e;
// }
// return null;
// }
// }
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/TableReader.java
import javax.tools.Diagnostic.Kind;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.droitateddb.builder.schema.data.Association;
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.Table;
import org.droitateddb.builder.schema.visitor.AssociationElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.ColumnElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.EmptyContructorVisitor;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.entity.Relationship;
import org.droitateddb.schema.AssociationType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
/*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb.builder.schema.reader;
/**
* @author Alexander Frank
* @author Falk Appel
*/
public class TableReader implements Reader<Table> {
private final TypeElement entity;
private final Set<String> entityNames;
private final Elements elements;
private final Messager messager;
public TableReader(final TypeElement entity, final Set<String> entityNames, final Elements elements, final Messager messager) {
this.entity = entity;
this.entityNames = entityNames;
this.elements = elements;
this.messager = messager;
}
@Override
public Table read() {
int primaryKeyCount = 0;
boolean noArgsConstructor = false;
Table table = new Table(entity.getSimpleName().toString(), entity.toString());
Map<String, AtomicInteger> countedToManyAssociations = new HashMap<String, AtomicInteger>();
for (Element child : entity.getEnclosedElements()) { | if (child.accept(new EmptyContructorVisitor(), null) != null) { |
arconsis/droitatedDB | droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/TableReader.java | // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/Table.java
// public class Table {
//
// private final String name;
// private final String entityClassName;
//
// private final Set<Column> columns = new TreeSet<Column>(new Comparator<Column>() {
// @Override
// public int compare(final Column c1, final Column c2) {
// return c1.getNameInEntity().compareTo(c2.getNameInEntity());
// }
// });
// private final Set<Association> associations = new TreeSet<Association>(new Comparator<Association>() {
// @Override
// public int compare(final Association a1, final Association a2) {
// return a1.getNameInEntity().compareTo(a2.getNameInEntity());
// }
// });
//
// public Table(final String name, final String entityClassName) {
// this.name = name;
// this.entityClassName = entityClassName;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEntityClassName() {
// return entityClassName;
// }
//
// public Set<Column> getColumns() {
// return Collections.unmodifiableSet(columns);
// }
//
// public void addColumn(final Column column) {
// columns.add(column);
// }
//
// public Set<Association> getAssociations() {
// return Collections.unmodifiableSet(associations);
// }
//
// public void addAssociation(final Association association) {
// associations.add(association);
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/AssociationElementResolvingTypeVisitor.java
// public class AssociationElementResolvingTypeVisitor extends DefaultElementVisitor<VariableElement, Void> {
//
// @Override
// public VariableElement visitVariable(final VariableElement e, final Void p) {
// if (e.getAnnotation(Relationship.class) != null) {
// return e;
// } else {
// return null;
// }
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/EmptyContructorVisitor.java
// public class EmptyContructorVisitor extends DefaultElementVisitor<ExecutableElement, Void> {
// @Override
// public ExecutableElement visitExecutable(final ExecutableElement e, final Void p) {
// if ("<init>".equals(e.getSimpleName().toString()) && e.getParameters().size() == 0) {
// return e;
// }
// return null;
// }
// }
| import javax.tools.Diagnostic.Kind;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.droitateddb.builder.schema.data.Association;
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.Table;
import org.droitateddb.builder.schema.visitor.AssociationElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.ColumnElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.EmptyContructorVisitor;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.entity.Relationship;
import org.droitateddb.schema.AssociationType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements; | @Override
public Table read() {
int primaryKeyCount = 0;
boolean noArgsConstructor = false;
Table table = new Table(entity.getSimpleName().toString(), entity.toString());
Map<String, AtomicInteger> countedToManyAssociations = new HashMap<String, AtomicInteger>();
for (Element child : entity.getEnclosedElements()) {
if (child.accept(new EmptyContructorVisitor(), null) != null) {
noArgsConstructor = true;
}
VariableElement column = child.accept(new ColumnElementResolvingTypeVisitor(), null);
if (column != null) {
if (hasAmbiguosAssociationDeclaration(column)) {
return null;
}
if (column.getAnnotation(PrimaryKey.class) != null && ++primaryKeyCount > 1) {
messager.printMessage(Kind.ERROR, "Only one @PrimaryKey is allowed within an @Entity", entity);
return null;
}
ColumnReader columnReader = new ColumnReader(column, elements, messager);
Column read = columnReader.read();
if (read != null) {
table.addColumn(read);
}
}
| // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/Table.java
// public class Table {
//
// private final String name;
// private final String entityClassName;
//
// private final Set<Column> columns = new TreeSet<Column>(new Comparator<Column>() {
// @Override
// public int compare(final Column c1, final Column c2) {
// return c1.getNameInEntity().compareTo(c2.getNameInEntity());
// }
// });
// private final Set<Association> associations = new TreeSet<Association>(new Comparator<Association>() {
// @Override
// public int compare(final Association a1, final Association a2) {
// return a1.getNameInEntity().compareTo(a2.getNameInEntity());
// }
// });
//
// public Table(final String name, final String entityClassName) {
// this.name = name;
// this.entityClassName = entityClassName;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEntityClassName() {
// return entityClassName;
// }
//
// public Set<Column> getColumns() {
// return Collections.unmodifiableSet(columns);
// }
//
// public void addColumn(final Column column) {
// columns.add(column);
// }
//
// public Set<Association> getAssociations() {
// return Collections.unmodifiableSet(associations);
// }
//
// public void addAssociation(final Association association) {
// associations.add(association);
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/AssociationElementResolvingTypeVisitor.java
// public class AssociationElementResolvingTypeVisitor extends DefaultElementVisitor<VariableElement, Void> {
//
// @Override
// public VariableElement visitVariable(final VariableElement e, final Void p) {
// if (e.getAnnotation(Relationship.class) != null) {
// return e;
// } else {
// return null;
// }
// }
//
// }
//
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/visitor/EmptyContructorVisitor.java
// public class EmptyContructorVisitor extends DefaultElementVisitor<ExecutableElement, Void> {
// @Override
// public ExecutableElement visitExecutable(final ExecutableElement e, final Void p) {
// if ("<init>".equals(e.getSimpleName().toString()) && e.getParameters().size() == 0) {
// return e;
// }
// return null;
// }
// }
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/TableReader.java
import javax.tools.Diagnostic.Kind;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.droitateddb.builder.schema.data.Association;
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.Table;
import org.droitateddb.builder.schema.visitor.AssociationElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.ColumnElementResolvingTypeVisitor;
import org.droitateddb.builder.schema.visitor.EmptyContructorVisitor;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.entity.Relationship;
import org.droitateddb.schema.AssociationType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
@Override
public Table read() {
int primaryKeyCount = 0;
boolean noArgsConstructor = false;
Table table = new Table(entity.getSimpleName().toString(), entity.toString());
Map<String, AtomicInteger> countedToManyAssociations = new HashMap<String, AtomicInteger>();
for (Element child : entity.getEnclosedElements()) {
if (child.accept(new EmptyContructorVisitor(), null) != null) {
noArgsConstructor = true;
}
VariableElement column = child.accept(new ColumnElementResolvingTypeVisitor(), null);
if (column != null) {
if (hasAmbiguosAssociationDeclaration(column)) {
return null;
}
if (column.getAnnotation(PrimaryKey.class) != null && ++primaryKeyCount > 1) {
messager.printMessage(Kind.ERROR, "Only one @PrimaryKey is allowed within an @Entity", entity);
return null;
}
ColumnReader columnReader = new ColumnReader(column, elements, messager);
Column read = columnReader.read();
if (read != null) {
table.addColumn(read);
}
}
| VariableElement association = child.accept(new AssociationElementResolvingTypeVisitor(), null); |
arconsis/droitatedDB | droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/writer/ColumnWriter.java | // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/ValidatorInfo.java
// public class ValidatorInfo {
// private String validatorClass;
// private String validatorAnnotation;
// private Map<String, Object> parameter;
//
// public ValidatorInfo(String validatorClass, String validatorAnnotation, Map<String, Object> parameter) {
// this.validatorClass = validatorClass;
// this.validatorAnnotation = validatorAnnotation;
// this.parameter = parameter;
// }
//
// public String getValidatorClass() {
// return validatorClass;
// }
//
// public String getValidatorAnnotation() {
// return validatorAnnotation;
// }
//
// public Map<String, Object> getParameter() {
// return parameter;
// }
//
// @Override
// public String toString() {
// return "ValidatorInfo{" +
// "validatorClass='" + validatorClass + '\'' +
// ", validatorAnnotation='" + validatorAnnotation + '\'' +
// ", parameter=" + parameter +
// '}';
// }
// }
| import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.ColumnValidation;
import org.droitateddb.builder.schema.data.ValidatorInfo;
import org.droitateddb.schema.ColumnValidator;
import org.droitateddb.schema.SchemaConstants;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.droitateddb.builder.Constants.CONSTANT_PREFIX;
import static org.droitateddb.builder.Constants.TAB; | .append(nameToUpper)
.append(" = new ")
.append(columnType)
.append(SchemaConstants.ATTRIBUTE_SUFFIX)
.append("(\"")
.append(column.getNameInEntity())
.append("\", ")
.append(column.getTypeInEntity())
.append(".class, ")
.append(columnIdx);
appendColumnValidators(builder);
builder.append(");\n");
return builder.toString();
}
private void appendColumnValidators(StringBuilder builder) {
ColumnValidation columnValidation = column.getColumnValidation();
int amountOfValidator = columnValidation.size();
if (amountOfValidator > 0) {
builder.append(", ");
for (int i = 0; i < amountOfValidator; i++) {
addColumnValidator(builder, columnValidation.get(i));
if (i < amountOfValidator - 1) {
builder.append(", ");
}
}
}
}
| // Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/data/ValidatorInfo.java
// public class ValidatorInfo {
// private String validatorClass;
// private String validatorAnnotation;
// private Map<String, Object> parameter;
//
// public ValidatorInfo(String validatorClass, String validatorAnnotation, Map<String, Object> parameter) {
// this.validatorClass = validatorClass;
// this.validatorAnnotation = validatorAnnotation;
// this.parameter = parameter;
// }
//
// public String getValidatorClass() {
// return validatorClass;
// }
//
// public String getValidatorAnnotation() {
// return validatorAnnotation;
// }
//
// public Map<String, Object> getParameter() {
// return parameter;
// }
//
// @Override
// public String toString() {
// return "ValidatorInfo{" +
// "validatorClass='" + validatorClass + '\'' +
// ", validatorAnnotation='" + validatorAnnotation + '\'' +
// ", parameter=" + parameter +
// '}';
// }
// }
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/writer/ColumnWriter.java
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.ColumnValidation;
import org.droitateddb.builder.schema.data.ValidatorInfo;
import org.droitateddb.schema.ColumnValidator;
import org.droitateddb.schema.SchemaConstants;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.droitateddb.builder.Constants.CONSTANT_PREFIX;
import static org.droitateddb.builder.Constants.TAB;
.append(nameToUpper)
.append(" = new ")
.append(columnType)
.append(SchemaConstants.ATTRIBUTE_SUFFIX)
.append("(\"")
.append(column.getNameInEntity())
.append("\", ")
.append(column.getTypeInEntity())
.append(".class, ")
.append(columnIdx);
appendColumnValidators(builder);
builder.append(");\n");
return builder.toString();
}
private void appendColumnValidators(StringBuilder builder) {
ColumnValidation columnValidation = column.getColumnValidation();
int amountOfValidator = columnValidation.size();
if (amountOfValidator > 0) {
builder.append(", ");
for (int i = 0; i < amountOfValidator; i++) {
addColumnValidator(builder, columnValidation.get(i));
if (i < amountOfValidator - 1) {
builder.append(", ");
}
}
}
}
| private void addColumnValidator(StringBuilder builder, ValidatorInfo validatorInfo) { |
arconsis/droitatedDB | droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/ColumnReader.java | // Path: droitatedDB/src/main/java/org/droitateddb/schema/ColumnType.java
// public enum ColumnType {
// INTEGER("Integer"), REAL("Real"), BLOB("Blob"), TEXT("Text");
//
// private final String readable;
//
// ColumnType(final String readable) {
// this.readable = readable;
// }
//
// public String getReadable() {
// return readable;
// }
//
// /**
// * Resolves the matching {@link ColumnType} to a fieldType.
// *
// * @param type String type to be resolved
// * @return The resolved ColumnType
// */
// public static ColumnType resolveColumnType(final String type) {
// if (matches(String.class, type)) {
// return ColumnType.TEXT;
// } else if (matches(Integer.class, type) || matches(int.class, type) || matches(Boolean.class, type) || matches(boolean.class, type) ||
// matches(Date.class, type) || matches(Long.class, type) || matches(long.class, type)) {
// return ColumnType.INTEGER;
// } else if (matches(Double.class, type) || matches(Float.class, type) || matches(double.class, type) || matches(float.class, type)) {
// return ColumnType.REAL;
// } else if (matches(byte[].class, type)) {
// return ColumnType.BLOB;
// } else {
// throw new IllegalStateException("The type " + type + " is no supported @Column type. Try @Relationship if you want to create an association.");
// }
// }
//
// private static boolean matches(final Class<?> ref, final String match) {
// return ref.getCanonicalName().equals(match);
// }
// }
| import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.ColumnValidation;
import org.droitateddb.entity.AutoIncrement;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.schema.ColumnType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic.Kind; | /*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb.builder.schema.reader;
/**
* @author Falk Appel
* @author Alexander Frank
*/
public class ColumnReader implements Reader<Column> {
private final VariableElement column;
private final Elements elements;
private final Messager messager;
public ColumnReader(final VariableElement column, final Elements elements, final Messager messager) {
this.column = column;
this.elements = elements;
this.messager = messager;
}
@Override
public Column read() {
String nameInEntity = column.getSimpleName().toString();
String typeInEntity = column.asType().toString();
try {
boolean isPrimaryKey = isPrimaryKeyAnnotated(column);
boolean isAutoincrementing = isAutoIncrementAnnotated(column);
checkPrimaryKeyAndAutoincrementLocation(isPrimaryKey, isAutoincrementing, column, typeInEntity);
ColumnValidation columnValidation = new ColumnValidationReader(column, elements, messager).read();
| // Path: droitatedDB/src/main/java/org/droitateddb/schema/ColumnType.java
// public enum ColumnType {
// INTEGER("Integer"), REAL("Real"), BLOB("Blob"), TEXT("Text");
//
// private final String readable;
//
// ColumnType(final String readable) {
// this.readable = readable;
// }
//
// public String getReadable() {
// return readable;
// }
//
// /**
// * Resolves the matching {@link ColumnType} to a fieldType.
// *
// * @param type String type to be resolved
// * @return The resolved ColumnType
// */
// public static ColumnType resolveColumnType(final String type) {
// if (matches(String.class, type)) {
// return ColumnType.TEXT;
// } else if (matches(Integer.class, type) || matches(int.class, type) || matches(Boolean.class, type) || matches(boolean.class, type) ||
// matches(Date.class, type) || matches(Long.class, type) || matches(long.class, type)) {
// return ColumnType.INTEGER;
// } else if (matches(Double.class, type) || matches(Float.class, type) || matches(double.class, type) || matches(float.class, type)) {
// return ColumnType.REAL;
// } else if (matches(byte[].class, type)) {
// return ColumnType.BLOB;
// } else {
// throw new IllegalStateException("The type " + type + " is no supported @Column type. Try @Relationship if you want to create an association.");
// }
// }
//
// private static boolean matches(final Class<?> ref, final String match) {
// return ref.getCanonicalName().equals(match);
// }
// }
// Path: droitatedDBProcessor/src/main/java/org/droitateddb/builder/schema/reader/ColumnReader.java
import org.droitateddb.builder.schema.data.Column;
import org.droitateddb.builder.schema.data.ColumnValidation;
import org.droitateddb.entity.AutoIncrement;
import org.droitateddb.entity.PrimaryKey;
import org.droitateddb.schema.ColumnType;
import javax.annotation.processing.Messager;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic.Kind;
/*
* Copyright (C) 2014 The droitated DB Authors
*
* 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.droitateddb.builder.schema.reader;
/**
* @author Falk Appel
* @author Alexander Frank
*/
public class ColumnReader implements Reader<Column> {
private final VariableElement column;
private final Elements elements;
private final Messager messager;
public ColumnReader(final VariableElement column, final Elements elements, final Messager messager) {
this.column = column;
this.elements = elements;
this.messager = messager;
}
@Override
public Column read() {
String nameInEntity = column.getSimpleName().toString();
String typeInEntity = column.asType().toString();
try {
boolean isPrimaryKey = isPrimaryKeyAnnotated(column);
boolean isAutoincrementing = isAutoIncrementAnnotated(column);
checkPrimaryKeyAndAutoincrementLocation(isPrimaryKey, isAutoincrementing, column, typeInEntity);
ColumnValidation columnValidation = new ColumnValidationReader(column, elements, messager).read();
| return new Column(nameInEntity, typeInEntity, ColumnType.resolveColumnType(typeInEntity), isPrimaryKey, isAutoincrementing, columnValidation); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/PcapTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapFindAllDevs(List<PcapIf> alldevsp, StringBuilder errbuf);
| import com.ardikars.common.net.Inet4Address;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs; | .source(source)
.pcapType(Pcap.PcapType.LIVE)
.build();
assert !live.isClosed();
live.close();
assert live.isClosed();
assert live.toString() != null;
}
assert !offline.isClosed();
dead.close();
assert dead.toString() != null;
assert dead.isClosed();
offline.close();
assert offline.isClosed();
assert offline.toString() != null;
}
@Test
public void equealsAndHashCodeTest() throws CloneNotSupportedException, IOException {
Pcap pcap = Pcap.dead(builder);
Pcap cln = pcap.clone();
assert pcap.equals(pcap);
assert !pcap.equals(null);
assert pcap.equals(cln);
assert cln.hashCode() == pcap.hashCode();
pcap.close();
}
private String findSource() {
List<PcapIf> alldevsp = new ArrayList<PcapIf>(); | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapFindAllDevs(List<PcapIf> alldevsp, StringBuilder errbuf);
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/PcapTest.java
import com.ardikars.common.net.Inet4Address;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs;
.source(source)
.pcapType(Pcap.PcapType.LIVE)
.build();
assert !live.isClosed();
live.close();
assert live.isClosed();
assert live.toString() != null;
}
assert !offline.isClosed();
dead.close();
assert dead.toString() != null;
assert dead.isClosed();
offline.close();
assert offline.isClosed();
assert offline.toString() != null;
}
@Test
public void equealsAndHashCodeTest() throws CloneNotSupportedException, IOException {
Pcap pcap = Pcap.dead(builder);
Pcap cln = pcap.clone();
assert pcap.equals(pcap);
assert !pcap.equals(null);
assert pcap.equals(cln);
assert cln.hashCode() == pcap.hashCode();
pcap.close();
}
private String findSource() {
List<PcapIf> alldevsp = new ArrayList<PcapIf>(); | if (PcapFindAllDevs(alldevsp, errbuf) != OK) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/PcapTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapFindAllDevs(List<PcapIf> alldevsp, StringBuilder errbuf);
| import com.ardikars.common.net.Inet4Address;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs; | .source(source)
.pcapType(Pcap.PcapType.LIVE)
.build();
assert !live.isClosed();
live.close();
assert live.isClosed();
assert live.toString() != null;
}
assert !offline.isClosed();
dead.close();
assert dead.toString() != null;
assert dead.isClosed();
offline.close();
assert offline.isClosed();
assert offline.toString() != null;
}
@Test
public void equealsAndHashCodeTest() throws CloneNotSupportedException, IOException {
Pcap pcap = Pcap.dead(builder);
Pcap cln = pcap.clone();
assert pcap.equals(pcap);
assert !pcap.equals(null);
assert pcap.equals(cln);
assert cln.hashCode() == pcap.hashCode();
pcap.close();
}
private String findSource() {
List<PcapIf> alldevsp = new ArrayList<PcapIf>(); | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapFindAllDevs(List<PcapIf> alldevsp, StringBuilder errbuf);
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/PcapTest.java
import com.ardikars.common.net.Inet4Address;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs;
.source(source)
.pcapType(Pcap.PcapType.LIVE)
.build();
assert !live.isClosed();
live.close();
assert live.isClosed();
assert live.toString() != null;
}
assert !offline.isClosed();
dead.close();
assert dead.toString() != null;
assert dead.isClosed();
offline.close();
assert offline.isClosed();
assert offline.toString() != null;
}
@Test
public void equealsAndHashCodeTest() throws CloneNotSupportedException, IOException {
Pcap pcap = Pcap.dead(builder);
Pcap cln = pcap.clone();
assert pcap.equals(pcap);
assert !pcap.equals(null);
assert pcap.equals(cln);
assert cln.hashCode() == pcap.hashCode();
pcap.close();
}
private String findSource() {
List<PcapIf> alldevsp = new ArrayList<PcapIf>(); | if (PcapFindAllDevs(alldevsp, errbuf) != OK) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/PcapIfTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
| import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.util.ArrayList; | PcapIf pcapIf4 = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert pcapIf0.equals(pcapIf0);
assert !pcapIf0.equals(null);
assert !pcapIf0.equals(pcapIf1);
assert !pcapIf0.equals(pcapIf2);
assert !pcapIf0.equals(pcapIf3);
assert pcapIf0.equals(pcapIf4);
assert pcapIf0.equals(pcapIf0.clone());
assert pcapIf0.hashCode() == pcapIf4.hashCode();
assert pcapIf0.hashCode() == pcapIf0.clone().hashCode();
}
@Test
@Override
public void toStringTest() {
PcapIf pcapIf = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert !pcapIf.toString().equals("");
}
@Test
@Override
public void getterTest() {
PcapIf pcapIf = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert pcapIf.getAddresses() != null;
assert pcapIf.getAddresses().isEmpty();
assert pcapIf.getDescription().equals("Ethernet 0");
assert pcapIf.getName().equals("en0");
assert pcapIf.getFlags() == 10;
}
| // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/PcapIfTest.java
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import java.util.ArrayList;
PcapIf pcapIf4 = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert pcapIf0.equals(pcapIf0);
assert !pcapIf0.equals(null);
assert !pcapIf0.equals(pcapIf1);
assert !pcapIf0.equals(pcapIf2);
assert !pcapIf0.equals(pcapIf3);
assert pcapIf0.equals(pcapIf4);
assert pcapIf0.equals(pcapIf0.clone());
assert pcapIf0.hashCode() == pcapIf4.hashCode();
assert pcapIf0.hashCode() == pcapIf0.clone().hashCode();
}
@Test
@Override
public void toStringTest() {
PcapIf pcapIf = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert !pcapIf.toString().equals("");
}
@Test
@Override
public void getterTest() {
PcapIf pcapIf = new PcapIf("en0", "Ethernet 0", new ArrayList<PcapAddr>(), 10);
assert pcapIf.getAddresses() != null;
assert pcapIf.getAddresses().isEmpty();
assert pcapIf.getDescription().equals("Ethernet 0");
assert pcapIf.getName().equals("en0");
assert pcapIf.getFlags() == 10;
}
| @Test(expected = OperationNotSupportedException.class) |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() { | pcap = PcapOpenDead(linkType.getValue(), snaplen); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() { | System.out.println("Pcap Error: " + PcapGetErr(pcap)); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() { | System.out.println("Data Link Type: " + PcapDataLink(pcap)); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
@RunWith(JUnit4.class)
public class FreakTest {
private Logger logger = Logger.getLogger(FreakTest.class.getName());
private Pcap pcap;
private int snaplen = 65535;
private DataLinkType linkType = DataLinkType.LINUX_SLL;
private int resultCode;
/**
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() { | System.out.println("Snapshot: " + PcapSnapshot(pcap)); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | * Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try { | if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | * Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
* Initialize
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try { | if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | */
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
*/
@Before
public void create() {
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) { | logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode)); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
} | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
pcap = PcapOpenDead(linkType.getValue(), snaplen);
if (pcap == null) {
logger.warning("create:PcapOpenDead(): ");
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
} | } catch (NativeException e) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
} | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
return;
}
}
@Test
public void Test01_PcapGetErr() {
System.out.println("Pcap Error: " + PcapGetErr(pcap));
}
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
} | } catch (PlatformNotSupportedException e) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; |
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try { | if (PcapCanSetRfMon(pcap) == 1) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | @Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try {
if (PcapCanSetRfMon(pcap) == 1) { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Test
public void Test02_PcapDatalink() {
System.out.println("Data Link Type: " + PcapDataLink(pcap));
}
@Test
public void Test03_PcapSnaplen() {
System.out.println("Snapshot: " + PcapSnapshot(pcap));
}
@Test
public void Test04_PcapSetDirection() {
try {
try {
if ((resultCode = PcapSetDirection(pcap, PcapDirection.PCAP_D_IN)) != OK) {
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try {
if (PcapCanSetRfMon(pcap) == 1) { | if ((resultCode = PcapSetRfMon(pcap, 1)) != OK) { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try {
if (PcapCanSetRfMon(pcap) == 1) {
if ((resultCode = PcapSetRfMon(pcap, 1)) != OK) {
logger.warning("PcapCanSetRfMonAndPcapSetRfMon:PcapCanSetRfMon(): " + PcapStrError(resultCode));
return;
}
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
}
/**
* Destroy
*/
@After
public void destroy() { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static final int OK = 0;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native void PcapClose(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapDataLink(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapGetErr(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native Pcap PcapOpenDead(int linktype, int snaplen);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException;
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java
// public static native String PcapStrError(int error);
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java
import static com.ardikars.jxnet.Jxnet.OK;
import static com.ardikars.jxnet.Jxnet.PcapCanSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapClose;
import static com.ardikars.jxnet.Jxnet.PcapDataLink;
import static com.ardikars.jxnet.Jxnet.PcapGetErr;
import static com.ardikars.jxnet.Jxnet.PcapOpenDead;
import static com.ardikars.jxnet.Jxnet.PcapSetDirection;
import static com.ardikars.jxnet.Jxnet.PcapSetRfMon;
import static com.ardikars.jxnet.Jxnet.PcapSnapshot;
import static com.ardikars.jxnet.Jxnet.PcapStrError;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.util.HashMap;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
logger.warning("PcapSetDirection:PcapSetDirection() " + PcapStrError(resultCode));
return;
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
} catch (PlatformNotSupportedException e) {
logger.warning(e.getMessage());
}
}
@Test
public void Test25_PcapCanSetRfMonAndPcapSetRfMon() {
try {
if (PcapCanSetRfMon(pcap) == 1) {
if ((resultCode = PcapSetRfMon(pcap, 1)) != OK) {
logger.warning("PcapCanSetRfMonAndPcapSetRfMon:PcapCanSetRfMon(): " + PcapStrError(resultCode));
return;
}
}
} catch (NativeException e) {
logger.warning(e.getMessage());
}
}
/**
* Destroy
*/
@After
public void destroy() { | PcapClose(pcap); |
jxnet/Jxnet | jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.util.Callback;
import com.ardikars.common.util.InternalNativeLibrary;
import com.ardikars.common.util.Loader;
import com.ardikars.common.util.Platforms;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.File; | if (Platforms.is64Bit()) {
nativeLibrary.register(LINUX_X64);
} else {
nativeLibrary.register(LINUX_X86);
}
break;
case WINDOWS:
File npcapFile = new File(NPCAP_DLL);
if (npcapFile.exists()) {
System.load(NPCAP_DLL);
} else {
File winpcapFile = new File(WPCAP_DLL);
if (winpcapFile.exists()) {
System.load(WPCAP_DLL);
} else {
callback.onFailure(new UnsatisfiedLinkError("Npcap or Winpcap is not installed yet."));
}
}
if (Platforms.is64Bit()) {
nativeLibrary.register(WINDOWS_X64);
} else {
nativeLibrary.register(WINDOWS_X86);
}
break;
case DARWIN:
if (Platforms.is64Bit()) {
nativeLibrary.register(DARWIN_X64);
}
break;
default: | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java
import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.util.Callback;
import com.ardikars.common.util.InternalNativeLibrary;
import com.ardikars.common.util.Loader;
import com.ardikars.common.util.Platforms;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.File;
if (Platforms.is64Bit()) {
nativeLibrary.register(LINUX_X64);
} else {
nativeLibrary.register(LINUX_X86);
}
break;
case WINDOWS:
File npcapFile = new File(NPCAP_DLL);
if (npcapFile.exists()) {
System.load(NPCAP_DLL);
} else {
File winpcapFile = new File(WPCAP_DLL);
if (winpcapFile.exists()) {
System.load(WPCAP_DLL);
} else {
callback.onFailure(new UnsatisfiedLinkError("Npcap or Winpcap is not installed yet."));
}
}
if (Platforms.is64Bit()) {
nativeLibrary.register(WINDOWS_X64);
} else {
nativeLibrary.register(WINDOWS_X86);
}
break;
case DARWIN:
if (Platforms.is64Bit()) {
nativeLibrary.register(DARWIN_X64);
}
break;
default: | throw new PlatformNotSupportedException("Your platform does't supported by dynamic jxnet."); |
jxnet/Jxnet | jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Platforms;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock; | this.dataLinkType = dataLinkType;
return this;
}
public Builder fileName(final String fileName) {
this.fileName = fileName;
return this;
}
public Builder pcapType(PcapType pcapType) {
this.pcapType = pcapType;
return this;
}
/**
* Build a live pcap handle.
* @return pcap handle.
*/
private Pcap buildLive() {
Validate.notIllegalArgument(source != null,
new IllegalArgumentException("Device name should be not null."));
Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536,
new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536."));
Validate.notIllegalArgument(timeout > 0,
new IllegalArgumentException("Timeout should be greater then 0."));
Validate.notIllegalArgument(errbuf != null,
new IllegalArgumentException("Error buffer should be not null."));
Pcap pcap = Jxnet.PcapCreate(source, errbuf);
if (Jxnet.PcapSetSnaplen(pcap, snaplen) < Jxnet.OK) { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java
import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Platforms;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
this.dataLinkType = dataLinkType;
return this;
}
public Builder fileName(final String fileName) {
this.fileName = fileName;
return this;
}
public Builder pcapType(PcapType pcapType) {
this.pcapType = pcapType;
return this;
}
/**
* Build a live pcap handle.
* @return pcap handle.
*/
private Pcap buildLive() {
Validate.notIllegalArgument(source != null,
new IllegalArgumentException("Device name should be not null."));
Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536,
new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536."));
Validate.notIllegalArgument(timeout > 0,
new IllegalArgumentException("Timeout should be greater then 0."));
Validate.notIllegalArgument(errbuf != null,
new IllegalArgumentException("Error buffer should be not null."));
Pcap pcap = Jxnet.PcapCreate(source, errbuf);
if (Jxnet.PcapSetSnaplen(pcap, snaplen) < Jxnet.OK) { | throw new NativeException(Jxnet.PcapGetErr(pcap)); |
jxnet/Jxnet | jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Platforms;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock; | /**
* Build a live pcap handle.
* @return pcap handle.
*/
private Pcap buildLive() {
Validate.notIllegalArgument(source != null,
new IllegalArgumentException("Device name should be not null."));
Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536,
new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536."));
Validate.notIllegalArgument(timeout > 0,
new IllegalArgumentException("Timeout should be greater then 0."));
Validate.notIllegalArgument(errbuf != null,
new IllegalArgumentException("Error buffer should be not null."));
Pcap pcap = Jxnet.PcapCreate(source, errbuf);
if (Jxnet.PcapSetSnaplen(pcap, snaplen) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (Jxnet.PcapSetPromisc(pcap, promiscuousMode.getValue()) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (Jxnet.PcapSetTimeout(pcap, timeout) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
setImmediateModeAndTimeStamp(pcap);
setEnableRfMon(pcap);
if (Jxnet.PcapActivate(pcap) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (!Platforms.isWindows() && Jxnet.PcapSetDirection(pcap, direction) < Jxnet.OK) { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java
import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Platforms;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Build a live pcap handle.
* @return pcap handle.
*/
private Pcap buildLive() {
Validate.notIllegalArgument(source != null,
new IllegalArgumentException("Device name should be not null."));
Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536,
new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536."));
Validate.notIllegalArgument(timeout > 0,
new IllegalArgumentException("Timeout should be greater then 0."));
Validate.notIllegalArgument(errbuf != null,
new IllegalArgumentException("Error buffer should be not null."));
Pcap pcap = Jxnet.PcapCreate(source, errbuf);
if (Jxnet.PcapSetSnaplen(pcap, snaplen) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (Jxnet.PcapSetPromisc(pcap, promiscuousMode.getValue()) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (Jxnet.PcapSetTimeout(pcap, timeout) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
setImmediateModeAndTimeStamp(pcap);
setEnableRfMon(pcap);
if (Jxnet.PcapActivate(pcap) < Jxnet.OK) {
throw new NativeException(Jxnet.PcapGetErr(pcap));
}
if (!Platforms.isWindows() && Jxnet.PcapSetDirection(pcap, direction) < Jxnet.OK) { | throw new PlatformNotSupportedException(); |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/PcapStatTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
| import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters; | PcapStat stat1 = new PcapStat(2L, 3L, 4L);
PcapStat stat2 = new PcapStat(1L, 1L, 4L);
PcapStat stat3 = new PcapStat(1L, 2L, 3L);
assert stat0.equals(stat0);
assert !stat0.equals(null);
assert !stat0.equals(stat1);
assert !stat0.equals(stat2);
assert stat0.equals(stat3);
assert stat.equals(stat0);
assert stat.equals(stat.clone());
assert stat.hashCode() == stat0.hashCode();
assert stat.hashCode() == stat.clone().hashCode();
}
@Test
@Override
public void toStringTest() {
PcapStat stat = new PcapStat(1L, 2L, 3L);
assert !stat.toString().equals("");
}
@Test
@Override
public void getterTest() {
PcapStat stat = new PcapStat(1L, 2L, 3L);
assert stat.getPsRecv() == 1L;
assert stat.getPsDrop() == 2L;
assert stat.getPsIfdrop() == 3L;
}
| // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/PcapStatTest.java
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
PcapStat stat1 = new PcapStat(2L, 3L, 4L);
PcapStat stat2 = new PcapStat(1L, 1L, 4L);
PcapStat stat3 = new PcapStat(1L, 2L, 3L);
assert stat0.equals(stat0);
assert !stat0.equals(null);
assert !stat0.equals(stat1);
assert !stat0.equals(stat2);
assert stat0.equals(stat3);
assert stat.equals(stat0);
assert stat.equals(stat.clone());
assert stat.hashCode() == stat0.hashCode();
assert stat.hashCode() == stat.clone().hashCode();
}
@Test
@Override
public void toStringTest() {
PcapStat stat = new PcapStat(1L, 2L, 3L);
assert !stat.toString().equals("");
}
@Test
@Override
public void getterTest() {
PcapStat stat = new PcapStat(1L, 2L, 3L);
assert stat.getPsRecv() == 1L;
assert stat.getPsDrop() == 2L;
assert stat.getPsIfdrop() == 3L;
}
| @Test(expected = OperationNotSupportedException.class) |
jxnet/Jxnet | jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock; | */
public Builder netmask(final int netmask) {
this.netmask = netmask;
return this;
}
/**
* Bpf compile mode.
* @param bpfCompileMode bpf compile mode.
* @return returns BpfProgram Builder.
*/
public Builder bpfCompileMode(final BpfCompileMode bpfCompileMode) {
this.bpfCompileMode = bpfCompileMode;
return this;
}
/**
* Create instance of BpfProgram.
* @return returns BpfProgram.
*/
private BpfProgram buildBpf() {
Validate.notIllegalArgument(pcap != null,
new IllegalArgumentException("Pcap handle should be not null."));
Validate.notIllegalArgument(!pcap.isClosed(),
new IllegalArgumentException("Pcap handle is closed."));
Validate.notIllegalArgument(filter != null && !filter.equals(""),
new IllegalArgumentException("Filter expression should be not null or empty."));
BpfProgram bpfProgram = new BpfProgram();
if (Jxnet.PcapCompile(pcap, bpfProgram, filter, bpfCompileMode.getValue(), netmask) < Jxnet.OK) { | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java
// public class NativeException extends RuntimeException {
//
// private static final long serialVersionUID = -3993889826336916332L;
//
// public NativeException() {
// this("");
// }
//
// public NativeException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public NativeException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public NativeException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java
import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.util.Validate;
import com.ardikars.jxnet.exception.NativeException;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
public Builder netmask(final int netmask) {
this.netmask = netmask;
return this;
}
/**
* Bpf compile mode.
* @param bpfCompileMode bpf compile mode.
* @return returns BpfProgram Builder.
*/
public Builder bpfCompileMode(final BpfCompileMode bpfCompileMode) {
this.bpfCompileMode = bpfCompileMode;
return this;
}
/**
* Create instance of BpfProgram.
* @return returns BpfProgram.
*/
private BpfProgram buildBpf() {
Validate.notIllegalArgument(pcap != null,
new IllegalArgumentException("Pcap handle should be not null."));
Validate.notIllegalArgument(!pcap.isClosed(),
new IllegalArgumentException("Pcap handle is closed."));
Validate.notIllegalArgument(filter != null && !filter.equals(""),
new IllegalArgumentException("Filter expression should be not null or empty."));
BpfProgram bpfProgram = new BpfProgram();
if (Jxnet.PcapCompile(pcap, bpfProgram, filter, bpfCompileMode.getValue(), netmask) < Jxnet.OK) { | throw new NativeException(Jxnet.PcapGetErr(pcap)); |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Application context for wrap a pcap handle.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.1.5
* @deprecated please use {@link com.ardikars.jxnet.context.ApplicationContext}.
*/
@Deprecated
public final class ApplicationContext implements Context {
private final com.ardikars.jxnet.context.Context ctx;
protected ApplicationContext(com.ardikars.jxnet.context.Context ctx) {
this.ctx = ctx;
}
@Override
public String getApplicationName() {
return ctx.getApplicationName();
}
@Override
public String getApplicationDisplayName() {
return ctx.getApplicationDisplayName();
}
@Override
public String getApplicationVersion() {
return ctx.getApplicationVersion();
}
@Override
public Context newInstance(Builder<Pcap, Void> builder) {
com.ardikars.jxnet.context.Context context = ctx.newInstance(builder);
return new ApplicationContext(context);
}
@Override | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Application context for wrap a pcap handle.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.1.5
* @deprecated please use {@link com.ardikars.jxnet.context.ApplicationContext}.
*/
@Deprecated
public final class ApplicationContext implements Context {
private final com.ardikars.jxnet.context.Context ctx;
protected ApplicationContext(com.ardikars.jxnet.context.Context ctx) {
this.ctx = ctx;
}
@Override
public String getApplicationName() {
return ctx.getApplicationName();
}
@Override
public String getApplicationDisplayName() {
return ctx.getApplicationDisplayName();
}
@Override
public String getApplicationVersion() {
return ctx.getApplicationVersion();
}
@Override
public Context newInstance(Builder<Pcap, Void> builder) {
com.ardikars.jxnet.context.Context context = ctx.newInstance(builder);
return new ApplicationContext(context);
}
@Override | public <T> PcapCode pcapLoop(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException { |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; |
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final ExecutorService executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapDispatch(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user);
}
@Override
public <T> PcapCode pcapDispatch(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user, executor);
}
@Override
public PcapCode pcapDumpOpen(String fname) throws PcapCloseException {
return ctx.pcapDumpOpen(fname);
}
@Override | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final ExecutorService executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapDispatch(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user);
}
@Override
public <T> PcapCode pcapDispatch(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user, executor);
}
@Override
public PcapCode pcapDumpOpen(String fname) throws PcapCloseException {
return ctx.pcapDumpOpen(fname);
}
@Override | public void pcapDump(PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException { |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; | }
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final ExecutorService executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapDispatch(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user);
}
@Override
public <T> PcapCode pcapDispatch(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user, executor);
}
@Override
public PcapCode pcapDumpOpen(String fname) throws PcapCloseException {
return ctx.pcapDumpOpen(fname);
}
@Override
public void pcapDump(PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException {
ctx.pcapDump(h, sp);
}
@Override | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
}
@Override
public <T> PcapCode pcapLoop(final int cnt, final PcapHandler<T> callback, final T user, final ExecutorService executor)
throws PcapCloseException {
return ctx.pcapLoop(cnt, callback, user, executor);
}
@Override
public <T> PcapCode pcapDispatch(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user);
}
@Override
public <T> PcapCode pcapDispatch(final int cnt, final PcapHandler<T> callback, final T user, final Executor executor)
throws PcapCloseException {
return ctx.pcapDispatch(cnt, callback, user, executor);
}
@Override
public PcapCode pcapDumpOpen(String fname) throws PcapCloseException {
return ctx.pcapDumpOpen(fname);
}
@Override
public void pcapDump(PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException {
ctx.pcapDump(h, sp);
}
@Override | public PcapCode pcapCompile(String str, BpfProgram.BpfCompileMode optimize, int netmask) throws PcapCloseException, BpfProgramCloseException { |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; | }
@Override
public void pcapFreeCode() throws BpfProgramCloseException {
ctx.pcapFreeCode();
}
@Override
public PcapCode pcapStats(PcapStat pcapStat) throws PcapCloseException {
return ctx.pcapStats(pcapStat);
}
@Override
public PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter,
BpfProgram.BpfCompileMode optimize, Inet4Address mask)
throws BpfProgramCloseException {
return ctx.pcapCompileNoPcap(snaplen, dataLinkType, filter, optimize, mask);
}
@Override
public void pcapPError(String prefix) throws PcapCloseException {
ctx.pcapPError(prefix);
}
@Override
public PcapCode pcapCanSetRfMon() throws PcapCloseException {
return ctx.pcapCanSetRfMon();
}
@Override | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
}
@Override
public void pcapFreeCode() throws BpfProgramCloseException {
ctx.pcapFreeCode();
}
@Override
public PcapCode pcapStats(PcapStat pcapStat) throws PcapCloseException {
return ctx.pcapStats(pcapStat);
}
@Override
public PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter,
BpfProgram.BpfCompileMode optimize, Inet4Address mask)
throws BpfProgramCloseException {
return ctx.pcapCompileNoPcap(snaplen, dataLinkType, filter, optimize, mask);
}
@Override
public void pcapPError(String prefix) throws PcapCloseException {
ctx.pcapPError(prefix);
}
@Override
public PcapCode pcapCanSetRfMon() throws PcapCloseException {
return ctx.pcapCanSetRfMon();
}
@Override | public PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException { |
jxnet/Jxnet | jxnet-core/src/test/java/com/ardikars/jxnet/PcapAddrTest.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters; | assert pcapAddr.equals(pcapAddr0);
assert pcapAddr.equals(pcapAddr.clone());
assert pcapAddr.hashCode() == pcapAddr0.hashCode();
assert pcapAddr.hashCode() == pcapAddr.clone().hashCode();
}
@Override
public void toStringTest() {
PcapAddr pcapAddr = new PcapAddr(sockAddr1, sockAddr2, sockAddr3, sockAddr4);
assert !pcapAddr.toString().equals("");
}
@Test
@Override
public void getterTest() {
SockAddr addr1 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.1").getAddress());
SockAddr addr2 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.2").getAddress());
SockAddr addr3 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.3").getAddress());
SockAddr addr4 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.4").getAddress());
PcapAddr pcapAddr = new PcapAddr(sockAddr1, sockAddr2, sockAddr3, sockAddr4);
assert pcapAddr.getAddr().equals(addr1);
assert pcapAddr.getNetmask().equals(addr2);
assert pcapAddr.getBroadAddr().equals(addr3);
assert pcapAddr.getDstAddr().equals(addr4);
}
| // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
// Path: jxnet-core/src/test/java/com/ardikars/jxnet/PcapAddrTest.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
assert pcapAddr.equals(pcapAddr0);
assert pcapAddr.equals(pcapAddr.clone());
assert pcapAddr.hashCode() == pcapAddr0.hashCode();
assert pcapAddr.hashCode() == pcapAddr.clone().hashCode();
}
@Override
public void toStringTest() {
PcapAddr pcapAddr = new PcapAddr(sockAddr1, sockAddr2, sockAddr3, sockAddr4);
assert !pcapAddr.toString().equals("");
}
@Test
@Override
public void getterTest() {
SockAddr addr1 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.1").getAddress());
SockAddr addr2 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.2").getAddress());
SockAddr addr3 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.3").getAddress());
SockAddr addr4 = new SockAddr(SockAddr.Family.AF_INET.getValue(),
Inet4Address.valueOf("192.168.1.4").getAddress());
PcapAddr pcapAddr = new PcapAddr(sockAddr1, sockAddr2, sockAddr3, sockAddr4);
assert pcapAddr.getAddr().equals(addr1);
assert pcapAddr.getNetmask().equals(addr2);
assert pcapAddr.getBroadAddr().equals(addr3);
assert pcapAddr.getDstAddr().equals(addr4);
}
| @Test(expected = OperationNotSupportedException.class) |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/Context.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.common.util.Factory;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Application context for wrap a pcap handle.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.1.5
* @deprecated please use {@link com.ardikars.jxnet.context.Context}.
*/
@Deprecated
public interface Context extends Factory<Context, Builder<Pcap, Void>> {
String getApplicationName();
String getApplicationDisplayName();
String getApplicationVersion();
/**
* Native function mapping
*/
/**
* Collect a group of packets.
* Callback argument already asyncronous.
* @param cnt maximum iteration, -1 is infinite iteration.
* @param callback callback funtion.
* @param user args
* @param <T> args type.
* @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a
* savefile, no more packets are available. It returns -1 if an error
* occurs or -2 if the loop terminated due to a call to PcapBreakLoop()
* before any packets were processed. It does not return when live packet
* buffer timeouts occur; instead, it attempts to read more packets.
* @throws PcapCloseException pcap close exception.
* @since 1.1.4
*/ | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/Context.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.common.util.Factory;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Application context for wrap a pcap handle.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.1.5
* @deprecated please use {@link com.ardikars.jxnet.context.Context}.
*/
@Deprecated
public interface Context extends Factory<Context, Builder<Pcap, Void>> {
String getApplicationName();
String getApplicationDisplayName();
String getApplicationVersion();
/**
* Native function mapping
*/
/**
* Collect a group of packets.
* Callback argument already asyncronous.
* @param cnt maximum iteration, -1 is infinite iteration.
* @param callback callback funtion.
* @param user args
* @param <T> args type.
* @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a
* savefile, no more packets are available. It returns -1 if an error
* occurs or -2 if the loop terminated due to a call to PcapBreakLoop()
* before any packets were processed. It does not return when live packet
* buffer timeouts occur; instead, it attempts to read more packets.
* @throws PcapCloseException pcap close exception.
* @since 1.1.4
*/ | <T> PcapCode pcapLoop(int cnt, PcapHandler<T> callback, T user) throws PcapCloseException; |
jxnet/Jxnet | jxnet-context/src/main/java/com/ardikars/jxnet/Context.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
| import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.common.util.Factory;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; | * return value indicates what error condition occurred. The possible
* error values are:
* PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist.
* PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported.
* PCAP_ERROR_ACTIVATED(-3): The capture handle has already been activated.
* PCAP_ERROR(-1): Generic error.
* @throws PcapCloseException pcap close exception.
* @since 1.1.4
*/
PcapCode pcapCanSetRfMon() throws PcapCloseException;
/**
* used to specify a direction that packets will be
* captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or
* PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the
* device, PCAP_D_OUT will only capture packets sent by the device and
* PCAP_D_INOUT will capture packets received by or sent by the device.
* PCAP_D_INOUT is the default setting if this function is not called.
*
* <p>PcapSetdirection() isn't necessarily fully supported on all platforms;
* some platforms might return an error for all values, and some other
* platforms might not support PCAP_D_OUT.</p>
*
* <p>This operation is not supported if a savefile is being read.</p>
* @param direction direction.
* @return returns 0 on success and -1 on failure (not supported by operating system).
* @throws PcapCloseException pcap close exception.
* @throws PlatformNotSupportedException platform not supported exception.
* @since 1.1.4
*/ | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java
// public class BpfProgramCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 981862853161292421L;
//
// public BpfProgramCloseException() {
// this("");
// }
//
// public BpfProgramCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public BpfProgramCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public BpfProgramCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java
// public class PcapCloseException extends RuntimeException {
//
// private static final long serialVersionUID = 8393262940022738877L;
//
// public PcapCloseException() {
// this("");
// }
//
// public PcapCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java
// public class PcapDumperCloseException extends RuntimeException {
//
// private static final long serialVersionUID = -3728289207910510051L;
//
// public PcapDumperCloseException() {
// this("");
// }
//
// public PcapDumperCloseException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PcapDumperCloseException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PcapDumperCloseException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/PlatformNotSupportedException.java
// public class PlatformNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = -5714154798477963289L;
//
// public PlatformNotSupportedException() {
// this("");
// }
//
// public PlatformNotSupportedException(final String message) {
// this(message, new RuntimeException(message));
// }
//
// public PlatformNotSupportedException(final Throwable cause) {
// this(cause.getMessage(), cause);
// }
//
// public PlatformNotSupportedException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// }
// Path: jxnet-context/src/main/java/com/ardikars/jxnet/Context.java
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.util.Builder;
import com.ardikars.common.util.Factory;
import com.ardikars.jxnet.exception.BpfProgramCloseException;
import com.ardikars.jxnet.exception.PcapCloseException;
import com.ardikars.jxnet.exception.PcapDumperCloseException;
import com.ardikars.jxnet.exception.PlatformNotSupportedException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
* return value indicates what error condition occurred. The possible
* error values are:
* PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist.
* PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported.
* PCAP_ERROR_ACTIVATED(-3): The capture handle has already been activated.
* PCAP_ERROR(-1): Generic error.
* @throws PcapCloseException pcap close exception.
* @since 1.1.4
*/
PcapCode pcapCanSetRfMon() throws PcapCloseException;
/**
* used to specify a direction that packets will be
* captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or
* PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the
* device, PCAP_D_OUT will only capture packets sent by the device and
* PCAP_D_INOUT will capture packets received by or sent by the device.
* PCAP_D_INOUT is the default setting if this function is not called.
*
* <p>PcapSetdirection() isn't necessarily fully supported on all platforms;
* some platforms might return an error for all values, and some other
* platforms might not support PCAP_D_OUT.</p>
*
* <p>This operation is not supported if a savefile is being read.</p>
* @param direction direction.
* @return returns 0 on success and -1 on failure (not supported by operating system).
* @throws PcapCloseException pcap close exception.
* @throws PlatformNotSupportedException platform not supported exception.
* @since 1.1.4
*/ | PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; |
jxnet/Jxnet | jxnet-core/src/main/java/com/ardikars/jxnet/SockAddr.java | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
| import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.net.Inet6Address;
import com.ardikars.common.util.NamedNumber;
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Socket address.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.0.0
*/
@Mutable(volatiles = { "sa_family", "data" })
public final class SockAddr implements Cloneable {
private volatile short sa_family;
private volatile byte[] data = new byte[0];
protected SockAddr() {
this((short) 0, new byte[] {});
}
protected SockAddr(short saFamily, byte[] data) {
this.sa_family = saFamily;
if (data == null) {
this.data = new byte[0];
} else {
this.data = Arrays.copyOf(data, data.length);
}
}
/**
* This method will throws {@code OperationNotSupportedException}.
* See {@link Jxnet#PcapFindAllDevs(List, StringBuilder)}.
* @return nothing.
* @throws OperationNotSupportedException throws {@code OperationNotSupportedException}.
*/ | // Path: jxnet-core/src/main/java/com/ardikars/jxnet/exception/OperationNotSupportedException.java
// public class OperationNotSupportedException extends RuntimeException {
//
// private static final long serialVersionUID = 4918064360828376142L;
//
// public OperationNotSupportedException() {
// this("");
// }
//
// public OperationNotSupportedException(final String s) {
// this(s, new RuntimeException(s));
// }
//
// public OperationNotSupportedException(final Throwable throwable) {
// this(throwable.getMessage(), throwable);
// }
//
// public OperationNotSupportedException(final String s, final Throwable throwable) {
// super(s, throwable);
// }
//
// }
// Path: jxnet-core/src/main/java/com/ardikars/jxnet/SockAddr.java
import com.ardikars.common.annotation.Mutable;
import com.ardikars.common.net.Inet4Address;
import com.ardikars.common.net.Inet6Address;
import com.ardikars.common.util.NamedNumber;
import com.ardikars.jxnet.exception.OperationNotSupportedException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Copyright (C) 2015-2018 Jxnet
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ardikars.jxnet;
/**
* Socket address.
*
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
* @since 1.0.0
*/
@Mutable(volatiles = { "sa_family", "data" })
public final class SockAddr implements Cloneable {
private volatile short sa_family;
private volatile byte[] data = new byte[0];
protected SockAddr() {
this((short) 0, new byte[] {});
}
protected SockAddr(short saFamily, byte[] data) {
this.sa_family = saFamily;
if (data == null) {
this.data = new byte[0];
} else {
this.data = Arrays.copyOf(data, data.length);
}
}
/**
* This method will throws {@code OperationNotSupportedException}.
* See {@link Jxnet#PcapFindAllDevs(List, StringBuilder)}.
* @return nothing.
* @throws OperationNotSupportedException throws {@code OperationNotSupportedException}.
*/ | public static SockAddr newInstance() throws OperationNotSupportedException { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/general/ObjectValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.general;
/**
*
*/
public class ObjectValidator implements Validator<Object> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/general/ObjectValidator.java
import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.general;
/**
*
*/
public class ObjectValidator implements Validator<Object> {
@Override | public ValidationResult validate(final Object item, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/general/ObjectValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.general;
/**
*
*/
public class ObjectValidator implements Validator<Object> {
@Override
public ValidationResult validate(final Object item, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(NotNull.class)) {
return handleNotNull(item);
} else if (type.equals(IsNull.class)) {
return handleIsNull(item);
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleIsNull(final Object item) {
if (item == null) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/general/ObjectValidator.java
import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.general;
/**
*
*/
public class ObjectValidator implements Validator<Object> {
@Override
public ValidationResult validate(final Object item, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(NotNull.class)) {
return handleNotNull(item);
} else if (type.equals(IsNull.class)) {
return handleIsNull(item);
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleIsNull(final Object item) {
if (item == null) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.INVALID_VALUE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMaxLength.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMaxLength.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/array/ArrayValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.array;
/**
*
*/
public class ArrayValidator implements Validator<Class<?>[]> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/array/ArrayValidator.java
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.array;
/**
*
*/
public class ArrayValidator implements Validator<Class<?>[]> {
@Override | public ValidationResult validate(final Class<?>[] array, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/array/ArrayValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.array;
/**
*
*/
public class ArrayValidator implements Validator<Class<?>[]> {
@Override
public ValidationResult validate(final Class<?>[] array, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ArrayIsNotEmpty.class)) {
return handleIsNotEmpty(array);
} else if (type.equals(ArrayContainsNoNulls.class)) {
return handleContainsNoNulls(array);
} else if (type.equals(ArrayContainsValue.class)) {
return handleContainsValue(array, ((ArrayContainsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleContainsValue(final Class<?>[] array,
final Class<?> value) {
if (array == null || value == null) {
return ValidationResult.nullValue();
} else if (array.length == 0) { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/array/ArrayValidator.java
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.array;
/**
*
*/
public class ArrayValidator implements Validator<Class<?>[]> {
@Override
public ValidationResult validate(final Class<?>[] array, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ArrayIsNotEmpty.class)) {
return handleIsNotEmpty(array);
} else if (type.equals(ArrayContainsNoNulls.class)) {
return handleContainsNoNulls(array);
} else if (type.equals(ArrayContainsValue.class)) {
return handleContainsValue(array, ((ArrayContainsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleContainsValue(final Class<?>[] array,
final Class<?> value) {
if (array == null || value == null) {
return ValidationResult.nullValue();
} else if (array.length == 0) { | return new ValidationResult(ValidationStatus.EMPTY_COLLECTION); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextDateFormat.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextDateFormat.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/test/com/michaelfotiadis/validator/annotated/parser/FieldParserTest.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
| import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import org.junit.Test;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; | package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class FieldParserTest {
@Test
public void isWrapperType() throws Exception {
assertTrue(FieldParser.isWrapperType(String.class));
assertTrue(FieldParser.isWrapperType(Integer.class));
assertTrue(FieldParser.isWrapperType(Float.class));
assertTrue(FieldParser.isWrapperType(BigInteger.class));
assertTrue(FieldParser.isWrapperType(Byte.class));
assertFalse(FieldParser.isWrapperType(Collection.class));
assertFalse(FieldParser.isWrapperType(Map.class));
assertFalse(FieldParser.isWrapperType(Iterable.class));
assertFalse(FieldParser.isWrapperType(TestItem1.class));
assertFalse(FieldParser.isWrapperType(TestNestedItem1.class));
}
@Test
public void getAllFieldsShallow() throws Exception {
final TestItem1 item1 = new TestItem1();
| // Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
// Path: src/test/com/michaelfotiadis/validator/annotated/parser/FieldParserTest.java
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import org.junit.Test;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class FieldParserTest {
@Test
public void isWrapperType() throws Exception {
assertTrue(FieldParser.isWrapperType(String.class));
assertTrue(FieldParser.isWrapperType(Integer.class));
assertTrue(FieldParser.isWrapperType(Float.class));
assertTrue(FieldParser.isWrapperType(BigInteger.class));
assertTrue(FieldParser.isWrapperType(Byte.class));
assertFalse(FieldParser.isWrapperType(Collection.class));
assertFalse(FieldParser.isWrapperType(Map.class));
assertFalse(FieldParser.isWrapperType(Iterable.class));
assertFalse(FieldParser.isWrapperType(TestItem1.class));
assertFalse(FieldParser.isWrapperType(TestNestedItem1.class));
}
@Test
public void getAllFieldsShallow() throws Exception {
final TestItem1 item1 = new TestItem1();
| final List<Field> fields = FieldParser.getAnnotatedFields(item1, SearchPolicy.SHALLOW); |
MikeFot/java-lib-annotated-validator | src/test/com/michaelfotiadis/validator/annotated/processor/AnnotatedValidatorProcessorTest.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue; | package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public class AnnotatedValidatorProcessorTest {
private AnnotatedValidatorProcessor processor;
@Before
public void setUp() throws Exception {
processor = new AnnotatedValidatorProcessor();
}
@Test
public void canSupportAllAnnotationCategories() {
| // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/test/com/michaelfotiadis/validator/annotated/processor/AnnotatedValidatorProcessorTest.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public class AnnotatedValidatorProcessorTest {
private AnnotatedValidatorProcessor processor;
@Before
public void setUp() throws Exception {
processor = new AnnotatedValidatorProcessor();
}
@Test
public void canSupportAllAnnotationCategories() {
| for (final AnnotationCategory category : AnnotationCategory.values()) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/general/NotNull.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.general;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/general/NotNull.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.general;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.GENERAL) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ByteValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ByteValidator implements Validator<Byte> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ByteValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ByteValidator implements Validator<Byte> {
@Override | public ValidationResult validate(final Byte value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ByteValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ByteValidator implements Validator<Byte> {
@Override
public ValidationResult validate(final Byte value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ByteEqualsValue.class)) {
return handleEqualsValue(value, ((ByteEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Byte value, final byte equalsValue) {
if (value == null) {
return ValidationResult.nullValue();
} else if (value.equals(equalsValue)) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ByteValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ByteValidator implements Validator<Byte> {
@Override
public ValidationResult validate(final Byte value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ByteEqualsValue.class)) {
return handleEqualsValue(value, ((ByteEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Byte value, final byte equalsValue) {
if (value == null) {
return ValidationResult.nullValue();
} else if (value.equals(equalsValue)) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.BYTE_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionContainsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionContainsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.COLLECTION) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatMaxValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatMaxValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.FLOAT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/FloatValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class FloatValidator implements Validator<Float> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/FloatValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class FloatValidator implements Validator<Float> {
@Override | public ValidationResult validate(final Float value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/FloatValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class FloatValidator implements Validator<Float> {
@Override
public ValidationResult validate(final Float value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(FloatMaxValue.class)) {
final FloatMaxValue clazz = ((FloatMaxValue) annotation);
return handleMaxValue(value, clazz.max(), clazz.epsilon());
} else if (type.equals(FloatMinValue.class)) {
final FloatMinValue clazz = ((FloatMinValue) annotation);
return handleMinValue(value, clazz.min(), clazz.epsilon());
} else if (type.equals(FloatEqualsValue.class)) {
final FloatEqualsValue clazz = ((FloatEqualsValue) annotation);
return handleEqualsValue(value, clazz.value(), clazz.epsilon());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Float number,
final float equalsValue,
final double epsilon) {
if (number == null) {
return ValidationResult.nullValue();
} else if (Math.abs(number - equalsValue) <= epsilon) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/FloatValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class FloatValidator implements Validator<Float> {
@Override
public ValidationResult validate(final Float value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(FloatMaxValue.class)) {
final FloatMaxValue clazz = ((FloatMaxValue) annotation);
return handleMaxValue(value, clazz.max(), clazz.epsilon());
} else if (type.equals(FloatMinValue.class)) {
final FloatMinValue clazz = ((FloatMinValue) annotation);
return handleMinValue(value, clazz.min(), clazz.epsilon());
} else if (type.equals(FloatEqualsValue.class)) {
final FloatEqualsValue clazz = ((FloatEqualsValue) annotation);
return handleEqualsValue(value, clazz.value(), clazz.epsilon());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Float number,
final float equalsValue,
final double epsilon) {
if (number == null) {
return ValidationResult.nullValue();
} else if (Math.abs(number - equalsValue) <= epsilon) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.FLOAT_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionIsNotEmpty.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionIsNotEmpty.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.COLLECTION) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerMinValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerMinValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.INTEGER) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.DOUBLE) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/collection/CollectionValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Iterator; | package com.michaelfotiadis.validator.annotated.validators.collection;
/**
*
*/
public class CollectionValidator implements Validator<Collection<?>> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/collection/CollectionValidator.java
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Iterator;
package com.michaelfotiadis.validator.annotated.validators.collection;
/**
*
*/
public class CollectionValidator implements Validator<Collection<?>> {
@Override | public ValidationResult validate(final Collection<?> collection, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/collection/CollectionValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Iterator; | } else {
return ValidationResult.failure();
}
}
private static ValidationResult handleContainsValue(final Collection<?> collection,
final Class<?> value) {
final ValidationResult isNotEmpty = handleIsNotEmpty(collection);
if (isNotEmpty.isValid()) {
if (value == null) {
return ValidationResult.nullValue();
}
// get the class of the first item
Class genericClass = null;
final Iterator it = collection.iterator();
if (it.hasNext()) {
genericClass = it.next().getClass();
}
if (genericClass != null) {
// This is considered a failure if the two classes do not match
if (value.getClass().equals(genericClass)) {
if (collection.contains(value)) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/collection/CollectionValidator.java
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Iterator;
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleContainsValue(final Collection<?> collection,
final Class<?> value) {
final ValidationResult isNotEmpty = handleIsNotEmpty(collection);
if (isNotEmpty.isValid()) {
if (value == null) {
return ValidationResult.nullValue();
}
// get the class of the first item
Class genericClass = null;
final Iterator it = collection.iterator();
if (it.hasNext()) {
genericClass = it.next().getClass();
}
if (genericClass != null) {
// This is considered a failure if the two classes do not match
if (value.getClass().equals(genericClass)) {
if (collection.contains(value)) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.INVALID_VALUE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortMinValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortMinValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.SHORT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/general/IsNull.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.general;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/general/IsNull.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.general;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.GENERAL) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/IntegerValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class IntegerValidator implements Validator<Integer> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/IntegerValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class IntegerValidator implements Validator<Integer> {
@Override | public ValidationResult validate(final Integer value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/IntegerValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class IntegerValidator implements Validator<Integer> {
@Override
public ValidationResult validate(final Integer value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(IntegerMaxValue.class)) {
return handleMaxValue(value, ((IntegerMaxValue) annotation).value());
} else if (type.equals(IntegerMinValue.class)) {
return handleMinValue(value, ((IntegerMinValue) annotation).value());
} else if (type.equals(IntegerEqualsValue.class)) {
return handleEqualsValue(value, ((IntegerEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Integer number, final int equalsValue) {
if (number == null) {
return ValidationResult.nullValue();
} else if (number == equalsValue) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/IntegerValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class IntegerValidator implements Validator<Integer> {
@Override
public ValidationResult validate(final Integer value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(IntegerMaxValue.class)) {
return handleMaxValue(value, ((IntegerMaxValue) annotation).value());
} else if (type.equals(IntegerMinValue.class)) {
return handleMinValue(value, ((IntegerMinValue) annotation).value());
} else if (type.equals(IntegerEqualsValue.class)) {
return handleEqualsValue(value, ((IntegerEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Integer number, final int equalsValue) {
if (number == null) {
return ValidationResult.nullValue();
} else if (number == equalsValue) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.INTEGER_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayIsNotEmpty.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayIsNotEmpty.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.ARRAY) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionContainsNoNulls.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/collection/CollectionContainsNoNulls.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.collection;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.COLLECTION) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.INTEGER) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/DoubleValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class DoubleValidator implements Validator<Double> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/DoubleValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class DoubleValidator implements Validator<Double> {
@Override | public ValidationResult validate(final Double value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/DoubleValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class DoubleValidator implements Validator<Double> {
@Override
public ValidationResult validate(final Double value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(DoubleMaxValue.class)) {
final DoubleMaxValue clazz = ((DoubleMaxValue) annotation);
return handleMaxValue(value, clazz.max(), clazz.epsilon());
} else if (type.equals(DoubleMinValue.class)) {
final DoubleMinValue clazz = ((DoubleMinValue) annotation);
return handleMinValue(value, clazz.min(), clazz.epsilon());
} else if (type.equals(DoubleEqualsValue.class)) {
final DoubleEqualsValue clazz = ((DoubleEqualsValue) annotation);
return handleEqualsValue(value, clazz.value(), clazz.epsilon());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Double number,
final double equalsValue,
final double epsilon) {
if (number == null) {
return ValidationResult.nullValue();
} else if (Math.abs(number - equalsValue) <= epsilon) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/DoubleValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class DoubleValidator implements Validator<Double> {
@Override
public ValidationResult validate(final Double value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(DoubleMaxValue.class)) {
final DoubleMaxValue clazz = ((DoubleMaxValue) annotation);
return handleMaxValue(value, clazz.max(), clazz.epsilon());
} else if (type.equals(DoubleMinValue.class)) {
final DoubleMinValue clazz = ((DoubleMinValue) annotation);
return handleMinValue(value, clazz.min(), clazz.epsilon());
} else if (type.equals(DoubleEqualsValue.class)) {
final DoubleEqualsValue clazz = ((DoubleEqualsValue) annotation);
return handleEqualsValue(value, clazz.value(), clazz.epsilon());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Double number,
final double equalsValue,
final double epsilon) {
if (number == null) {
return ValidationResult.nullValue();
} else if (Math.abs(number - equalsValue) <= epsilon) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.DOUBLE_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/conditional/BooleanEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.conditional;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/conditional/BooleanEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.conditional;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.BOOLEAN) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayContainsNoNulls.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayContainsNoNulls.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.ARRAY) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ShortValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ShortValidator implements Validator<Short> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ShortValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ShortValidator implements Validator<Short> {
@Override | public ValidationResult validate(final Short value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ShortValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ShortValidator implements Validator<Short> {
@Override
public ValidationResult validate(final Short value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ShortMaxValue.class)) {
return handleMaxValue(value, ((ShortMaxValue) annotation).value());
} else if (type.equals(ShortMinValue.class)) {
return handleMinValue(value, ((ShortMinValue) annotation).value());
} else if (type.equals(ShortEqualsValue.class)) {
return handleEqualsValue(value, ((ShortEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Short number, final short equalsValue) {
if (number == null) {
return ValidationResult.nullValue();
} else if (number == equalsValue) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/numeric/ShortValidator.java
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.numeric;
/**
*
*/
public class ShortValidator implements Validator<Short> {
@Override
public ValidationResult validate(final Short value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(ShortMaxValue.class)) {
return handleMaxValue(value, ((ShortMaxValue) annotation).value());
} else if (type.equals(ShortMinValue.class)) {
return handleMinValue(value, ((ShortMinValue) annotation).value());
} else if (type.equals(ShortEqualsValue.class)) {
return handleEqualsValue(value, ((ShortEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Short number, final short equalsValue) {
if (number == null) {
return ValidationResult.nullValue();
} else if (number == equalsValue) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.INTEGER_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortMaxValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortMaxValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.SHORT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextNotNullOrEmpty.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextNotNullOrEmpty.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.FLOAT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/utils/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// // NOOP
// }
//
// /**
// * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
// *
// * @param packageName The base package
// * @return The classes
// * @throws ClassNotFoundException
// * @throws IOException
// */
// public static Class[] getClasses(final String packageName) throws ClassNotFoundException, IOException {
// final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// assert classLoader != null;
// final String path = packageName.replace('.', '/');
// final Enumeration<URL> resources = classLoader.getResources(path);
// final List<File> dirs = new ArrayList<>();
// while (resources.hasMoreElements()) {
// final URL resource = resources.nextElement();
// dirs.add(new File(resource.getFile()));
// }
// final ArrayList<Class> classes = new ArrayList<>();
// for (final File directory : dirs) {
// classes.addAll(findClasses(directory, packageName));
// }
// return classes.toArray(new Class[classes.size()]);
// }
//
// /**
// * Recursive method used to find all classes in a given directory and subdirs.
// *
// * @param directory The base directory
// * @param packageName The package name for classes found inside the base directory
// * @return The classes
// * @throws ClassNotFoundException
// */
// public static List<Class> findClasses(final File directory, final String packageName) throws ClassNotFoundException {
// final List<Class> classes = new ArrayList<>();
// if (!directory.exists()) {
// return classes;
// }
// final File[] files = directory.listFiles();
// if (files != null) {
// for (final File file : files) {
// if (file.isDirectory()) {
// assert !file.getName().contains(".");
// classes.addAll(findClasses(file, packageName + "." + file.getName()));
// } else if (file.getName().endsWith(".class")) {
// classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
// }
// }
// }
// return classes;
// }
//
// }
| import com.michaelfotiadis.validator.annotated.utils.ReflectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; | package com.michaelfotiadis.validator.annotated;
/**
*
*/
public final class SupportedAnnotationContainer {
private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
private SupportedAnnotationContainer() {
// NOOP
}
/*package*/
static boolean isSupported(final Class<?> type) {
return getSupportedClasses().contains(type);
}
public static List<Class> getSupportedClasses() {
if (SUPPORTED_CLASSES.isEmpty()) {
final Class[] supportedArray;
try { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/utils/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// // NOOP
// }
//
// /**
// * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
// *
// * @param packageName The base package
// * @return The classes
// * @throws ClassNotFoundException
// * @throws IOException
// */
// public static Class[] getClasses(final String packageName) throws ClassNotFoundException, IOException {
// final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// assert classLoader != null;
// final String path = packageName.replace('.', '/');
// final Enumeration<URL> resources = classLoader.getResources(path);
// final List<File> dirs = new ArrayList<>();
// while (resources.hasMoreElements()) {
// final URL resource = resources.nextElement();
// dirs.add(new File(resource.getFile()));
// }
// final ArrayList<Class> classes = new ArrayList<>();
// for (final File directory : dirs) {
// classes.addAll(findClasses(directory, packageName));
// }
// return classes.toArray(new Class[classes.size()]);
// }
//
// /**
// * Recursive method used to find all classes in a given directory and subdirs.
// *
// * @param directory The base directory
// * @param packageName The package name for classes found inside the base directory
// * @return The classes
// * @throws ClassNotFoundException
// */
// public static List<Class> findClasses(final File directory, final String packageName) throws ClassNotFoundException {
// final List<Class> classes = new ArrayList<>();
// if (!directory.exists()) {
// return classes;
// }
// final File[] files = directory.listFiles();
// if (files != null) {
// for (final File file : files) {
// if (file.isDirectory()) {
// assert !file.getName().contains(".");
// classes.addAll(findClasses(file, packageName + "." + file.getName()));
// } else if (file.getName().endsWith(".class")) {
// classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
// }
// }
// }
// return classes;
// }
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java
import com.michaelfotiadis.validator.annotated.utils.ReflectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
package com.michaelfotiadis.validator.annotated;
/**
*
*/
public final class SupportedAnnotationContainer {
private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
private SupportedAnnotationContainer() {
// NOOP
}
/*package*/
static boolean isSupported(final Class<?> type) {
return getSupportedClasses().contains(type);
}
public static List<Class> getSupportedClasses() {
if (SUPPORTED_CLASSES.isEmpty()) {
final Class[] supportedArray;
try { | supportedArray = ReflectionUtils.getClasses(PACKAGE_NAME); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/processor/AnnotationProcessorUtils.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
| import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import java.util.ArrayList;
import java.util.List; | package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public final class AnnotationProcessorUtils {
private AnnotationProcessorUtils() {
// NOOP
}
| // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/AnnotationProcessorUtils.java
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import java.util.ArrayList;
import java.util.List;
package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public final class AnnotationProcessorUtils {
private AnnotationProcessorUtils() {
// NOOP
}
| public static List<ValidationStatus> getFailures(final List<ValidationResult> results) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/processor/AnnotationProcessorUtils.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
| import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import java.util.ArrayList;
import java.util.List; | package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public final class AnnotationProcessorUtils {
private AnnotationProcessorUtils() {
// NOOP
}
| // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/AnnotationProcessorUtils.java
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import java.util.ArrayList;
import java.util.List;
package com.michaelfotiadis.validator.annotated.processor;
/**
*
*/
public final class AnnotationProcessorUtils {
private AnnotationProcessorUtils() {
// NOOP
}
| public static List<ValidationStatus> getFailures(final List<ValidationResult> results) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/bytenum/ByteEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/bytenum/ByteEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.BYTE) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayContainsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/array/ArrayContainsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.array;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.ARRAY) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMatchesExpression.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMatchesExpression.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatMinValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/floatnum/FloatMinValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.FLOAT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortEqualsValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/shortnum/ShortEqualsValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.SHORT) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleMaxValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleMaxValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.DOUBLE) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerMaxValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/integernum/IntegerMaxValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.integernum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.INTEGER) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/text/StringValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern; | package com.michaelfotiadis.validator.annotated.validators.text;
/**
*
*/
public class StringValidator implements Validator<String> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/text/StringValidator.java
import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
package com.michaelfotiadis.validator.annotated.validators.text;
/**
*
*/
public class StringValidator implements Validator<String> {
@Override | public ValidationResult validate(final String value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/text/StringValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern; | } else if (type.equals(TextEmail.class)) {
return handleEmail(value);
} else if (type.equals(TextUrl.class)) {
return handleUrl(value);
} else if (type.equals(TextMatchesExpression.class)) {
return handleMatchesExpression(value, ((TextMatchesExpression) annotation).expression());
} else if (type.equals(TextExactLength.class)) {
return handleExactLength(value, ((TextExactLength) annotation).value());
} else if (type.equals(TextMinLength.class)) {
return handleMinLength(value, ((TextMinLength) annotation).value());
} else if (type.equals(TextMaxLength.class)) {
return handleMaxLength(value, ((TextMaxLength) annotation).value());
} else if (type.equals(TextIsNumeric.class)) {
return handleIsNumeric(value);
} else if (type.equals(TextDateFormat.class)) {
return handleIsOfDateFormat(value, ((TextDateFormat) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleMatchesExpression(final String value, final String expression) {
final ValidationResult notEmptyResult = handleNotNullOrEmpty(value);
if (notEmptyResult.isValid()) {
if (Pattern.compile(expression).matcher(value).matches()) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/text/StringValidator.java
import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
} else if (type.equals(TextEmail.class)) {
return handleEmail(value);
} else if (type.equals(TextUrl.class)) {
return handleUrl(value);
} else if (type.equals(TextMatchesExpression.class)) {
return handleMatchesExpression(value, ((TextMatchesExpression) annotation).expression());
} else if (type.equals(TextExactLength.class)) {
return handleExactLength(value, ((TextExactLength) annotation).value());
} else if (type.equals(TextMinLength.class)) {
return handleMinLength(value, ((TextMinLength) annotation).value());
} else if (type.equals(TextMaxLength.class)) {
return handleMaxLength(value, ((TextMaxLength) annotation).value());
} else if (type.equals(TextIsNumeric.class)) {
return handleIsNumeric(value);
} else if (type.equals(TextDateFormat.class)) {
return handleIsOfDateFormat(value, ((TextDateFormat) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleMatchesExpression(final String value, final String expression) {
final ValidationResult notEmptyResult = handleNotNullOrEmpty(value);
if (notEmptyResult.isValid()) {
if (Pattern.compile(expression).matcher(value).matches()) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.PATTERN_DID_NOT_MATCH); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/parser/FieldParser.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java
// public final class SupportedAnnotationContainer {
//
// private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
// private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
//
// private SupportedAnnotationContainer() {
// // NOOP
// }
//
// /*package*/
// static boolean isSupported(final Class<?> type) {
// return getSupportedClasses().contains(type);
// }
//
// public static List<Class> getSupportedClasses() {
// if (SUPPORTED_CLASSES.isEmpty()) {
// final Class[] supportedArray;
// try {
// supportedArray = ReflectionUtils.getClasses(PACKAGE_NAME);
// SUPPORTED_CLASSES.addAll(Arrays.asList(supportedArray));
// } catch (ClassNotFoundException | IOException e) {
// e.printStackTrace();
// }
// }
// return SUPPORTED_CLASSES;
// }
//
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
| import com.michaelfotiadis.validator.annotated.SupportedAnnotationContainer;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; | package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class FieldParser {
private static final Set<Class<?>> WRAPPER_TYPES = getWrapperTypes();
private final Set<Object> visitedFields;
public FieldParser() {
this.visitedFields = new HashSet<>();
}
public static boolean isWrapperType(final Class<?> clazz) {
return WRAPPER_TYPES.contains(clazz);
}
private static Set<Class<?>> getWrapperTypes() {
final Set<Class<?>> primitiveWrappers = new HashSet<>();
primitiveWrappers.add(Boolean.class);
primitiveWrappers.add(Character.class);
primitiveWrappers.add(Byte.class);
primitiveWrappers.add(Short.class);
primitiveWrappers.add(Integer.class);
primitiveWrappers.add(Long.class);
primitiveWrappers.add(Float.class);
primitiveWrappers.add(String.class);
primitiveWrappers.add(Number.class);
primitiveWrappers.add(BigInteger.class);
primitiveWrappers.add(BigDecimal.class);
primitiveWrappers.add(String.class);
primitiveWrappers.add(Double.class);
primitiveWrappers.add(Void.class);
return primitiveWrappers;
}
/**
* Gets all declared {@link Field}s in a class
*
* @param obj {@link Object} to be processed
* @return {@link List} of {@link Field} found
*/ | // Path: src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java
// public final class SupportedAnnotationContainer {
//
// private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
// private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
//
// private SupportedAnnotationContainer() {
// // NOOP
// }
//
// /*package*/
// static boolean isSupported(final Class<?> type) {
// return getSupportedClasses().contains(type);
// }
//
// public static List<Class> getSupportedClasses() {
// if (SUPPORTED_CLASSES.isEmpty()) {
// final Class[] supportedArray;
// try {
// supportedArray = ReflectionUtils.getClasses(PACKAGE_NAME);
// SUPPORTED_CLASSES.addAll(Arrays.asList(supportedArray));
// } catch (ClassNotFoundException | IOException e) {
// e.printStackTrace();
// }
// }
// return SUPPORTED_CLASSES;
// }
//
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/parser/FieldParser.java
import com.michaelfotiadis.validator.annotated.SupportedAnnotationContainer;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class FieldParser {
private static final Set<Class<?>> WRAPPER_TYPES = getWrapperTypes();
private final Set<Object> visitedFields;
public FieldParser() {
this.visitedFields = new HashSet<>();
}
public static boolean isWrapperType(final Class<?> clazz) {
return WRAPPER_TYPES.contains(clazz);
}
private static Set<Class<?>> getWrapperTypes() {
final Set<Class<?>> primitiveWrappers = new HashSet<>();
primitiveWrappers.add(Boolean.class);
primitiveWrappers.add(Character.class);
primitiveWrappers.add(Byte.class);
primitiveWrappers.add(Short.class);
primitiveWrappers.add(Integer.class);
primitiveWrappers.add(Long.class);
primitiveWrappers.add(Float.class);
primitiveWrappers.add(String.class);
primitiveWrappers.add(Number.class);
primitiveWrappers.add(BigInteger.class);
primitiveWrappers.add(BigDecimal.class);
primitiveWrappers.add(String.class);
primitiveWrappers.add(Double.class);
primitiveWrappers.add(Void.class);
return primitiveWrappers;
}
/**
* Gets all declared {@link Field}s in a class
*
* @param obj {@link Object} to be processed
* @return {@link List} of {@link Field} found
*/ | public <T> List<Field> getDeclaredFields(final T obj, final SearchPolicy searchPolicy) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/parser/FieldParser.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java
// public final class SupportedAnnotationContainer {
//
// private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
// private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
//
// private SupportedAnnotationContainer() {
// // NOOP
// }
//
// /*package*/
// static boolean isSupported(final Class<?> type) {
// return getSupportedClasses().contains(type);
// }
//
// public static List<Class> getSupportedClasses() {
// if (SUPPORTED_CLASSES.isEmpty()) {
// final Class[] supportedArray;
// try {
// supportedArray = ReflectionUtils.getClasses(PACKAGE_NAME);
// SUPPORTED_CLASSES.addAll(Arrays.asList(supportedArray));
// } catch (ClassNotFoundException | IOException e) {
// e.printStackTrace();
// }
// }
// return SUPPORTED_CLASSES;
// }
//
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
| import com.michaelfotiadis.validator.annotated.SupportedAnnotationContainer;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; | public static List<Field> getAnnotatedFields(final Object root,
final SearchPolicy searchPolicy) throws ReflectiveOperationException {
return getAnnotatedFields(root, searchPolicy, new HashSet<>());
}
private static List<Field> getAnnotatedFields(final Object root,
final SearchPolicy searchPolicy,
final Set<Object> inspected) throws ReflectiveOperationException {
final List<Field> annotatedValues = new ArrayList<>();
if (inspected.contains(root)) { // Prevents stack overflow.
System.out.println("*** Breaking for already inspected");
return Collections.emptyList();
}
if (isWrapperType(root.getClass())) { // Prevents stack overflow.
System.out.println("*** Breaking for wrapper class");
return Collections.emptyList();
}
for (final Field field : gatherFields(root.getClass())) {
field.setAccessible(true);
final Object currentValue = field.get(root);
field.setAccessible(false);
if (field.getAnnotations().length != 0) {
// Found required value, search finished:
for (final Annotation annotation : field.getAnnotations()) { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainer.java
// public final class SupportedAnnotationContainer {
//
// private static final String PACKAGE_NAME = "com.michaelfotiadis.validator.annotated.annotations";
// private static final List<Class> SUPPORTED_CLASSES = new ArrayList<>();
//
// private SupportedAnnotationContainer() {
// // NOOP
// }
//
// /*package*/
// static boolean isSupported(final Class<?> type) {
// return getSupportedClasses().contains(type);
// }
//
// public static List<Class> getSupportedClasses() {
// if (SUPPORTED_CLASSES.isEmpty()) {
// final Class[] supportedArray;
// try {
// supportedArray = ReflectionUtils.getClasses(PACKAGE_NAME);
// SUPPORTED_CLASSES.addAll(Arrays.asList(supportedArray));
// } catch (ClassNotFoundException | IOException e) {
// e.printStackTrace();
// }
// }
// return SUPPORTED_CLASSES;
// }
//
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/processor/SearchPolicy.java
// public enum SearchPolicy {
// SHALLOW,
// DEEP
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/parser/FieldParser.java
import com.michaelfotiadis.validator.annotated.SupportedAnnotationContainer;
import com.michaelfotiadis.validator.annotated.processor.SearchPolicy;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public static List<Field> getAnnotatedFields(final Object root,
final SearchPolicy searchPolicy) throws ReflectiveOperationException {
return getAnnotatedFields(root, searchPolicy, new HashSet<>());
}
private static List<Field> getAnnotatedFields(final Object root,
final SearchPolicy searchPolicy,
final Set<Object> inspected) throws ReflectiveOperationException {
final List<Field> annotatedValues = new ArrayList<>();
if (inspected.contains(root)) { // Prevents stack overflow.
System.out.println("*** Breaking for already inspected");
return Collections.emptyList();
}
if (isWrapperType(root.getClass())) { // Prevents stack overflow.
System.out.println("*** Breaking for wrapper class");
return Collections.emptyList();
}
for (final Field field : gatherFields(root.getClass())) {
field.setAccessible(true);
final Object currentValue = field.get(root);
field.setAccessible(false);
if (field.getAnnotations().length != 0) {
// Found required value, search finished:
for (final Annotation annotation : field.getAnnotations()) { | if (SupportedAnnotationContainer.getSupportedClasses().contains(annotation.annotationType())) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextExactLength.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextExactLength.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/test/com/michaelfotiadis/validator/annotated/parser/AnnotationParserTest.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import org.junit.Test;
import java.lang.annotation.Annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; | package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class AnnotationParserTest {
@Test
public void getCategoryOfAnnotation() throws Exception {
TestInteger testInteger = new TestInteger();
Annotation annotation = AnnotationParser.getAnnotation(testInteger, IntegerMinValue.class);
assertNotNull(annotation);
| // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/test/com/michaelfotiadis/validator/annotated/parser/AnnotationParserTest.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import org.junit.Test;
import java.lang.annotation.Annotation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
package com.michaelfotiadis.validator.annotated.parser;
/**
*
*/
public class AnnotationParserTest {
@Test
public void getCategoryOfAnnotation() throws Exception {
TestInteger testInteger = new TestInteger();
Annotation annotation = AnnotationParser.getAnnotation(testInteger, IntegerMinValue.class);
assertNotNull(annotation);
| AnnotationCategory category = AnnotationParser.getCategoryOfAnnotation(annotation); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/conditional/BooleanValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.conditional;
/**
*
*/
public class BooleanValidator implements Validator<Boolean> {
@Override | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/conditional/BooleanValidator.java
import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.conditional;
/**
*
*/
public class BooleanValidator implements Validator<Boolean> {
@Override | public ValidationResult validate(final Boolean value, final Annotation annotation) { |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/validators/conditional/BooleanValidator.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation; | package com.michaelfotiadis.validator.annotated.validators.conditional;
/**
*
*/
public class BooleanValidator implements Validator<Boolean> {
@Override
public ValidationResult validate(final Boolean value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(BooleanEqualsValue.class)) {
return handleEqualsValue(value, ((BooleanEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Boolean bool, final boolean equalsValue) {
if (bool == null) {
return ValidationResult.nullValue();
} else if (bool.equals(equalsValue)) {
return ValidationResult.success();
} else { | // Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationResult.java
// public class ValidationResult {
//
// private final ValidationStatus status;
//
// public ValidationResult(final ValidationStatus status) {
// this.status = status;
// }
//
// public ValidationResult(final boolean isValid) {
// if (isValid) {
// this.status = ValidationStatus.SUCCESS;
// } else {
// this.status = ValidationStatus.UNDEFINED_FAILURE;
// }
// }
//
// /**
// * Static factory
// *
// * @return successful {@link ValidationResult}
// */
// public static ValidationResult success() {
// return new ValidationResult(ValidationStatus.SUCCESS);
// }
//
// /**
// * Static factory
// *
// * @return failed {@link ValidationResult}
// */
// public static ValidationResult failure() {
// return new ValidationResult(ValidationStatus.UNDEFINED_FAILURE);
// }
//
// /**
// * Static factory
// *
// * @return null max {@link ValidationResult}
// */
// public static ValidationResult nullValue() {
// return new ValidationResult(ValidationStatus.NULL_VALUE);
// }
//
// public ValidationStatus getStatus() {
// return this.status;
// }
//
// public boolean isValid() {
// return this.status == ValidationStatus.SUCCESS;
// }
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/model/ValidationStatus.java
// public enum ValidationStatus {
//
// UNDEFINED_FAILURE,
// NULL_VALUE,
// EMPTY_COLLECTION,
// COLLECTION_CONTAINS_NULL,
// PATTERN_DID_NOT_MATCH,
// EMPTY_STRING,
// INVALID_VALUE,
// WRONG_TYPE_ARGUMENTS,
// VALUE_OUT_OF_RANGE,
// NUMBER_OUT_OF_RANGE,
// INTEGER_OUT_OF_RANGE,
// BYTE_OUT_OF_RANGE,
// DOUBLE_OUT_OF_RANGE,
// FLOAT_OUT_OF_RANGE,
// EXCEPTION,
// SUCCESS
//
// }
//
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/Validator.java
// public interface Validator<T> {
//
// ValidationResult validate(T item, Annotation annotation);
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/validators/conditional/BooleanValidator.java
import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.model.ValidationResult;
import com.michaelfotiadis.validator.annotated.model.ValidationStatus;
import com.michaelfotiadis.validator.annotated.validators.Validator;
import java.lang.annotation.Annotation;
package com.michaelfotiadis.validator.annotated.validators.conditional;
/**
*
*/
public class BooleanValidator implements Validator<Boolean> {
@Override
public ValidationResult validate(final Boolean value, final Annotation annotation) {
final Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(BooleanEqualsValue.class)) {
return handleEqualsValue(value, ((BooleanEqualsValue) annotation).value());
} else {
return ValidationResult.failure();
}
}
private static ValidationResult handleEqualsValue(final Boolean bool, final boolean equalsValue) {
if (bool == null) {
return ValidationResult.nullValue();
} else if (bool.equals(equalsValue)) {
return ValidationResult.success();
} else { | return new ValidationResult(ValidationStatus.INTEGER_OUT_OF_RANGE); |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMinLength.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextMinLength.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleMinValue.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/numeric/doublenum/DoubleMinValue.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.DOUBLE) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextEmail.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextEmail.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextUrl.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextUrl.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextIsNumeric.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; | package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/text/TextIsNumeric.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
package com.michaelfotiadis.validator.annotated.annotations.text;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) | @Category(type = AnnotationCategory.STRING) |
MikeFot/java-lib-annotated-validator | src/test/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainerTest.java | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
| import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; | checkIsSupported(DoubleEqualsValue.class);
// Float annotations
checkIsSupported(FloatMinValue.class);
checkIsSupported(FloatMaxValue.class);
checkIsSupported(FloatEqualsValue.class);
// Short annotations
checkIsSupported(ShortMinValue.class);
checkIsSupported(ShortMaxValue.class);
checkIsSupported(ShortEqualsValue.class);
// String annotations
checkIsSupported(TextDateFormat.class);
checkIsSupported(TextEmail.class);
checkIsSupported(TextExactLength.class);
checkIsSupported(TextIsNumeric.class);
checkIsSupported(TextMatchesExpression.class);
checkIsSupported(TextMaxLength.class);
checkIsSupported(TextMinLength.class);
checkIsSupported(TextNotNullOrEmpty.class);
checkIsSupported(TextUrl.class);
}
@Test
public void isCorrectCategory() throws Exception {
// collection annotations | // Path: src/main/java/com/michaelfotiadis/validator/annotated/annotations/AnnotationCategory.java
// public enum AnnotationCategory {
//
// UNUSED,
// GENERAL,
// BYTE,
// BOOLEAN,
// INTEGER,
// DOUBLE,
// FLOAT,
// SHORT,
// STRING,
// COLLECTION,
// ARRAY
//
// }
// Path: src/test/com/michaelfotiadis/validator/annotated/SupportedAnnotationContainerTest.java
import com.michaelfotiadis.validator.annotated.annotations.AnnotationCategory;
import com.michaelfotiadis.validator.annotated.annotations.Category;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.array.ArrayIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsNoNulls;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionContainsValue;
import com.michaelfotiadis.validator.annotated.annotations.collection.CollectionIsNotEmpty;
import com.michaelfotiadis.validator.annotated.annotations.conditional.BooleanEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.general.IsNull;
import com.michaelfotiadis.validator.annotated.annotations.general.NotNull;
import com.michaelfotiadis.validator.annotated.annotations.numeric.bytenum.ByteEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.doublenum.DoubleMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.floatnum.FloatMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.integernum.IntegerMinValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortEqualsValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMaxValue;
import com.michaelfotiadis.validator.annotated.annotations.numeric.shortnum.ShortMinValue;
import com.michaelfotiadis.validator.annotated.annotations.text.TextDateFormat;
import com.michaelfotiadis.validator.annotated.annotations.text.TextEmail;
import com.michaelfotiadis.validator.annotated.annotations.text.TextExactLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextIsNumeric;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMatchesExpression;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMaxLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextMinLength;
import com.michaelfotiadis.validator.annotated.annotations.text.TextNotNullOrEmpty;
import com.michaelfotiadis.validator.annotated.annotations.text.TextUrl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
checkIsSupported(DoubleEqualsValue.class);
// Float annotations
checkIsSupported(FloatMinValue.class);
checkIsSupported(FloatMaxValue.class);
checkIsSupported(FloatEqualsValue.class);
// Short annotations
checkIsSupported(ShortMinValue.class);
checkIsSupported(ShortMaxValue.class);
checkIsSupported(ShortEqualsValue.class);
// String annotations
checkIsSupported(TextDateFormat.class);
checkIsSupported(TextEmail.class);
checkIsSupported(TextExactLength.class);
checkIsSupported(TextIsNumeric.class);
checkIsSupported(TextMatchesExpression.class);
checkIsSupported(TextMaxLength.class);
checkIsSupported(TextMinLength.class);
checkIsSupported(TextNotNullOrEmpty.class);
checkIsSupported(TextUrl.class);
}
@Test
public void isCorrectCategory() throws Exception {
// collection annotations | checkCategory(CollectionContainsNoNulls.class, AnnotationCategory.COLLECTION); |
noboomu/proteus | proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java | // Path: proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java
// public class ServerException extends RuntimeException
// {
// /**
// *
// */
// private static final long serialVersionUID = 8360356916374374408L;
//
// private Integer status = Status.BAD_REQUEST.getStatusCode();
//
// public ServerException(int status)
// {
// super();
//
// this.status = status;
// }
//
// public ServerException(Status status)
// {
// super();
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @param message
// */
// public ServerException(String message, int status)
// {
// super(message);
//
// this.status = status;
// }
//
// /**
// * @param message
// */
// public ServerException(String message, Status status)
// {
// super(message);
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @param cause
// */
// public ServerException(Throwable cause, int status)
// {
// super(cause);
//
// this.status = status;
// }
//
// /**
// * @param cause
// */
// public ServerException(Throwable cause, Status status)
// {
// super(cause);
//
// this.status = status.getStatusCode();
// }
//
// public ServerException(String message, Throwable cause, int status)
// {
// super(message, cause);
//
// this.status = status;
// }
//
// public ServerException(String message, Throwable cause, Status status)
// {
// super(message, cause);
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @return the status
// */
// public Integer getStatus()
// {
// return status;
// }
//
// /**
// * @param status the status to set
// */
// public void setStatus(Integer status)
// {
// this.status = status;
// }
// }
| import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import io.sinistral.proteus.server.exceptions.ServerException;
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpHandler;
import io.undertow.util.AttachmentKey;
import io.undertow.util.HttpString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
import java.util.Optional; | package io.sinistral.proteus.openapi.wrappers;
@Singleton
public class HeaderApiKeyWrapper implements HandlerWrapper
{
private static final Logger logger = LoggerFactory.getLogger(HeaderApiKeyWrapper.class.getName());
public static final AttachmentKey<Throwable> THROWABLE = AttachmentKey.create(Throwable.class);
@Inject
@Named("openapi.securitySchemes.ApiKeyAuth.name")
protected static String AUTH_KEY_NAME;
@Inject(optional = true)
@Named("security.apiKey")
protected static String API_KEY;
private final HttpString API_KEY_HEADER;
public HeaderApiKeyWrapper()
{
API_KEY_HEADER = new HttpString(AUTH_KEY_NAME);
}
@Override
public HttpHandler wrap(HttpHandler handler)
{
return exchange -> {
if(API_KEY == null)
{
handler.handleRequest(exchange);
return;
}
Optional<String> keyValue = Optional.ofNullable(exchange.getRequestHeaders().getFirst(API_KEY_HEADER));
if(!keyValue.isPresent() || !keyValue.get().equals(API_KEY))
{
logger.error("Missing security credentials"); | // Path: proteus-core/src/main/java/io/sinistral/proteus/server/exceptions/ServerException.java
// public class ServerException extends RuntimeException
// {
// /**
// *
// */
// private static final long serialVersionUID = 8360356916374374408L;
//
// private Integer status = Status.BAD_REQUEST.getStatusCode();
//
// public ServerException(int status)
// {
// super();
//
// this.status = status;
// }
//
// public ServerException(Status status)
// {
// super();
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @param message
// */
// public ServerException(String message, int status)
// {
// super(message);
//
// this.status = status;
// }
//
// /**
// * @param message
// */
// public ServerException(String message, Status status)
// {
// super(message);
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @param cause
// */
// public ServerException(Throwable cause, int status)
// {
// super(cause);
//
// this.status = status;
// }
//
// /**
// * @param cause
// */
// public ServerException(Throwable cause, Status status)
// {
// super(cause);
//
// this.status = status.getStatusCode();
// }
//
// public ServerException(String message, Throwable cause, int status)
// {
// super(message, cause);
//
// this.status = status;
// }
//
// public ServerException(String message, Throwable cause, Status status)
// {
// super(message, cause);
//
// this.status = status.getStatusCode();
// }
//
// /**
// * @return the status
// */
// public Integer getStatus()
// {
// return status;
// }
//
// /**
// * @param status the status to set
// */
// public void setStatus(Integer status)
// {
// this.status = status;
// }
// }
// Path: proteus-openapi/src/main/java/io/sinistral/proteus/openapi/wrappers/HeaderApiKeyWrapper.java
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import io.sinistral.proteus.server.exceptions.ServerException;
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpHandler;
import io.undertow.util.AttachmentKey;
import io.undertow.util.HttpString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
import java.util.Optional;
package io.sinistral.proteus.openapi.wrappers;
@Singleton
public class HeaderApiKeyWrapper implements HandlerWrapper
{
private static final Logger logger = LoggerFactory.getLogger(HeaderApiKeyWrapper.class.getName());
public static final AttachmentKey<Throwable> THROWABLE = AttachmentKey.create(Throwable.class);
@Inject
@Named("openapi.securitySchemes.ApiKeyAuth.name")
protected static String AUTH_KEY_NAME;
@Inject(optional = true)
@Named("security.apiKey")
protected static String API_KEY;
private final HttpString API_KEY_HEADER;
public HeaderApiKeyWrapper()
{
API_KEY_HEADER = new HttpString(AUTH_KEY_NAME);
}
@Override
public HttpHandler wrap(HttpHandler handler)
{
return exchange -> {
if(API_KEY == null)
{
handler.handleRequest(exchange);
return;
}
Optional<String> keyValue = Optional.ofNullable(exchange.getRequestHeaders().getFirst(API_KEY_HEADER));
if(!keyValue.isPresent() || !keyValue.get().equals(API_KEY))
{
logger.error("Missing security credentials"); | exchange.putAttachment(THROWABLE, new ServerException("Unauthorized access", Response.Status.UNAUTHORIZED)); |
noboomu/proteus | proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java | // Path: proteus-core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java
// public class ServerPredicates
// {
// public static final String JSON_REGEX = "^(application\\/(json|x-javascript)|text\\/(json|x-javascript|x-json))(;.*)?$";
// public static final String XML_REGEX = "^(application\\/(xml|xhtml\\+xml)|text\\/xml)(;.*)?$";
// public static final String HTML_REGEX = "^(text\\/html)(;.*)?$";
// public static final String TEXT_PLAIN_REGEX = "^(text\\/plain)(;.*)?$";
// public static final String TEXT_REGEX = "^(?!(text)$).*";
//
//
// public static final Predicate JSON_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), JSON_REGEX);
// public static final Predicate XML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), XML_REGEX);
// public static final Predicate HTML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), HTML_REGEX);
// public static final Predicate BINARY_STREAM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE),
// MediaType.APPLICATION_OCTET_STREAM.contentType());
// public static final Predicate WILDCARD_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.contentType());
// public static final Predicate NO_WILDCARD_PREDICATE = Predicates.not(Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.contentType()));
// public static final Predicate ACCEPT_JSON_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), JSON_REGEX);
// public static final Predicate ACCEPT_XML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), XML_REGEX);
// public static final Predicate ACCEPT_HTML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), HTML_REGEX);
// public static final Predicate ACCEPT_TEXT_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), TEXT_PLAIN_REGEX);
// public static final Predicate ACCEPT_XML_EXCLUSIVE_PREDICATE = Predicates.and(ACCEPT_XML_PREDICATE, NO_WILDCARD_PREDICATE);
// public static final Predicate MAX_CONTENT_SIZE_PREDICATE = new MaxRequestContentLengthPredicate.Builder().build(Collections.singletonMap("value", 0L));
// public static final Predicate STRING_BODY_PREDICATE = Predicates.and(Predicates.or(JSON_PREDICATE, XML_PREDICATE), MAX_CONTENT_SIZE_PREDICATE);
// public static final Predicate MULTIPART_FORM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE),
// MultiPartParserDefinition.MULTIPART_FORM_DATA);
// public static final Predicate URL_ENCODED_FORM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), FormEncodedDataDefinition.APPLICATION_X_WWW_FORM_URLENCODED);
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.inject.Inject;
import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;
import io.undertow.util.StatusCodes; | /**
*
*/
package io.sinistral.proteus.server.handlers;
/**
* @author jbauer
*/
public class ServerFallbackHandler implements HttpHandler
{
@Inject
protected XmlMapper xmlMapper;
@Inject
protected ObjectMapper objectMapper;
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception
{
final int statusCode = 404;
exchange.setStatusCode(statusCode);
final String responseBody;
final String reason = StatusCodes.getReason(statusCode);
| // Path: proteus-core/src/main/java/io/sinistral/proteus/server/predicates/ServerPredicates.java
// public class ServerPredicates
// {
// public static final String JSON_REGEX = "^(application\\/(json|x-javascript)|text\\/(json|x-javascript|x-json))(;.*)?$";
// public static final String XML_REGEX = "^(application\\/(xml|xhtml\\+xml)|text\\/xml)(;.*)?$";
// public static final String HTML_REGEX = "^(text\\/html)(;.*)?$";
// public static final String TEXT_PLAIN_REGEX = "^(text\\/plain)(;.*)?$";
// public static final String TEXT_REGEX = "^(?!(text)$).*";
//
//
// public static final Predicate JSON_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), JSON_REGEX);
// public static final Predicate XML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), XML_REGEX);
// public static final Predicate HTML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), HTML_REGEX);
// public static final Predicate BINARY_STREAM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE),
// MediaType.APPLICATION_OCTET_STREAM.contentType());
// public static final Predicate WILDCARD_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.contentType());
// public static final Predicate NO_WILDCARD_PREDICATE = Predicates.not(Predicates.contains(ExchangeAttributes.requestHeader(Headers.ACCEPT), MediaType.ANY.contentType()));
// public static final Predicate ACCEPT_JSON_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), JSON_REGEX);
// public static final Predicate ACCEPT_XML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), XML_REGEX);
// public static final Predicate ACCEPT_HTML_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), HTML_REGEX);
// public static final Predicate ACCEPT_TEXT_PREDICATE = Predicates.regex(ExchangeAttributes.requestHeader(Headers.ACCEPT), TEXT_PLAIN_REGEX);
// public static final Predicate ACCEPT_XML_EXCLUSIVE_PREDICATE = Predicates.and(ACCEPT_XML_PREDICATE, NO_WILDCARD_PREDICATE);
// public static final Predicate MAX_CONTENT_SIZE_PREDICATE = new MaxRequestContentLengthPredicate.Builder().build(Collections.singletonMap("value", 0L));
// public static final Predicate STRING_BODY_PREDICATE = Predicates.and(Predicates.or(JSON_PREDICATE, XML_PREDICATE), MAX_CONTENT_SIZE_PREDICATE);
// public static final Predicate MULTIPART_FORM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE),
// MultiPartParserDefinition.MULTIPART_FORM_DATA);
// public static final Predicate URL_ENCODED_FORM_PREDICATE = Predicates.contains(ExchangeAttributes.requestHeader(Headers.CONTENT_TYPE), FormEncodedDataDefinition.APPLICATION_X_WWW_FORM_URLENCODED);
// }
// Path: proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerFallbackHandler.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.inject.Inject;
import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;
import io.undertow.util.StatusCodes;
/**
*
*/
package io.sinistral.proteus.server.handlers;
/**
* @author jbauer
*/
public class ServerFallbackHandler implements HttpHandler
{
@Inject
protected XmlMapper xmlMapper;
@Inject
protected ObjectMapper objectMapper;
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception
{
final int statusCode = 404;
exchange.setStatusCode(statusCode);
final String responseBody;
final String reason = StatusCodes.getReason(statusCode);
| if (ServerPredicates.ACCEPT_JSON_PREDICATE.resolve(exchange)) { |
jemygraw/ShootPlane | ShootPlane/src/com/beancore/util/FileUtil.java | // Path: ShootPlane/src/com/beancore/entity/Score.java
// public class Score implements Serializable, Comparable<Score> {
// private static final long serialVersionUID = 1L;
// private Date scoreDateTime;
// private int score;
// private long lastSeconds;
//
// public Score() {
// super();
// }
//
// public Score(Date scoreDateTime, int score, long lastSeconds) {
// super();
// this.scoreDateTime = scoreDateTime;
// this.score = score;
// this.lastSeconds = lastSeconds;
// }
//
// public Date getScoreDateTime() {
// return scoreDateTime;
// }
//
// public void setScoreDateTime(Date scoreDateTime) {
// this.scoreDateTime = scoreDateTime;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// public long getLastSeconds() {
// return lastSeconds;
// }
//
// public void setLastSeconds(long lastSeconds) {
// this.lastSeconds = lastSeconds;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + score;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Score other = (Score) obj;
// if (score != other.score)
// return false;
// return true;
// }
//
// @Override
// public int compareTo(Score score) {
// return this.score - score.getScore();
// }
//
// }
| import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import com.beancore.entity.Score; | package com.beancore.util;
public class FileUtil {
public static String readFileToString(String filePath) throws IOException {
StringBuilder sb = new StringBuilder();
File file = new File(filePath);
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(new String(line.getBytes(),"utf-8")).append("\r\n");
}
br.close();
return sb.toString();
}
| // Path: ShootPlane/src/com/beancore/entity/Score.java
// public class Score implements Serializable, Comparable<Score> {
// private static final long serialVersionUID = 1L;
// private Date scoreDateTime;
// private int score;
// private long lastSeconds;
//
// public Score() {
// super();
// }
//
// public Score(Date scoreDateTime, int score, long lastSeconds) {
// super();
// this.scoreDateTime = scoreDateTime;
// this.score = score;
// this.lastSeconds = lastSeconds;
// }
//
// public Date getScoreDateTime() {
// return scoreDateTime;
// }
//
// public void setScoreDateTime(Date scoreDateTime) {
// this.scoreDateTime = scoreDateTime;
// }
//
// public int getScore() {
// return score;
// }
//
// public void setScore(int score) {
// this.score = score;
// }
//
// public long getLastSeconds() {
// return lastSeconds;
// }
//
// public void setLastSeconds(long lastSeconds) {
// this.lastSeconds = lastSeconds;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + score;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Score other = (Score) obj;
// if (score != other.score)
// return false;
// return true;
// }
//
// @Override
// public int compareTo(Score score) {
// return this.score - score.getScore();
// }
//
// }
// Path: ShootPlane/src/com/beancore/util/FileUtil.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import com.beancore.entity.Score;
package com.beancore.util;
public class FileUtil {
public static String readFileToString(String filePath) throws IOException {
StringBuilder sb = new StringBuilder();
File file = new File(filePath);
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(new String(line.getBytes(),"utf-8")).append("\r\n");
}
br.close();
return sb.toString();
}
| public static void writeScore(List<Score> scoreList, String filePath) throws FileNotFoundException, IOException { |
projectodd/wunderboss | caching/src/main/java/org/projectodd/wunderboss/caching/Caching.java | // Path: core/src/main/java/org/projectodd/wunderboss/Component.java
// public interface Component {
//
// void start() throws Exception;
//
// void stop() throws Exception;
//
// boolean isRunning();
//
// String name();
// }
//
// Path: core/src/main/java/org/projectodd/wunderboss/Option.java
// public class Option {
//
// public String name;
// public Object defaultValue;
//
// public Option() {}
//
// public String toString() {
// return "[" + this.getClass().getName() + ": " + name + ", default = " + defaultValue + "]";
// }
//
// public static <T extends Option> T opt(String name, Class T) {
// return opt(name, null, T);
// }
//
// public static <T extends Option> T opt(String name, Object defaultValue, Class T) {
// T opt = null;
// try {
// opt = (T)T.newInstance();
// opt.name = name;
// opt.defaultValue = defaultValue;
// rememberOption(opt);
// } catch (InstantiationException | IllegalAccessException e) {
// e.printStackTrace();
// }
//
// return opt;
// }
//
// public static Set<Option> optsFor(Class clazz) {
// Set<Option> opts = new HashSet<>();
// while(Option.class.isAssignableFrom(clazz)) {
// if (knownOptions.containsKey(clazz)) {
// opts.addAll(knownOptions.get(clazz));
// }
// clazz = clazz.getSuperclass();
// }
//
// return opts;
// }
//
// private static void rememberOption(Option opt) {
// Set<Option> opts = knownOptions.get(opt.getClass());
// if (opts == null) {
// opts = new HashSet<>();
// knownOptions.put(opt.getClass(), opts);
// }
// opts.add(opt);
// }
//
// private static final Map<Class, Set<Option>> knownOptions = new HashMap<>();
// }
//
// Path: core/src/main/java/org/projectodd/wunderboss/codecs/Codec.java
// public interface Codec<E,D> {
//
// E encode(D data);
//
// D decode(E encoded);
//
// Class<E> encodesTo();
//
// String name();
//
// String contentType();
// }
| import org.infinispan.Cache;
import org.projectodd.wunderboss.Component;
import org.projectodd.wunderboss.Option;
import org.projectodd.wunderboss.codecs.Codec;
import java.util.Map; | /*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.caching;
public interface Caching extends Component {
class CreateOption extends Option {
public static final CreateOption CONFIGURATION = opt("configuration", CreateOption.class);
public static final CreateOption TRANSACTIONAL = opt("transactional", false, CreateOption.class);
public static final CreateOption LOCKING = opt("locking", "OPTIMISTIC", CreateOption.class);
public static final CreateOption PERSIST = opt("persist", false, CreateOption.class);
public static final CreateOption MODE = opt("mode", CreateOption.class);
public static final CreateOption EVICTION = opt("eviction", "NONE", CreateOption.class);
public static final CreateOption MAX_ENTRIES = opt("max_entries", -1, CreateOption.class);
public static final CreateOption IDLE = opt("idle", -1, CreateOption.class);
public static final CreateOption TTL = opt("ttl", -1, CreateOption.class);
}
Cache findOrCreate(String name, Map<CreateOption,Object> options);
Cache find(String name); | // Path: core/src/main/java/org/projectodd/wunderboss/Component.java
// public interface Component {
//
// void start() throws Exception;
//
// void stop() throws Exception;
//
// boolean isRunning();
//
// String name();
// }
//
// Path: core/src/main/java/org/projectodd/wunderboss/Option.java
// public class Option {
//
// public String name;
// public Object defaultValue;
//
// public Option() {}
//
// public String toString() {
// return "[" + this.getClass().getName() + ": " + name + ", default = " + defaultValue + "]";
// }
//
// public static <T extends Option> T opt(String name, Class T) {
// return opt(name, null, T);
// }
//
// public static <T extends Option> T opt(String name, Object defaultValue, Class T) {
// T opt = null;
// try {
// opt = (T)T.newInstance();
// opt.name = name;
// opt.defaultValue = defaultValue;
// rememberOption(opt);
// } catch (InstantiationException | IllegalAccessException e) {
// e.printStackTrace();
// }
//
// return opt;
// }
//
// public static Set<Option> optsFor(Class clazz) {
// Set<Option> opts = new HashSet<>();
// while(Option.class.isAssignableFrom(clazz)) {
// if (knownOptions.containsKey(clazz)) {
// opts.addAll(knownOptions.get(clazz));
// }
// clazz = clazz.getSuperclass();
// }
//
// return opts;
// }
//
// private static void rememberOption(Option opt) {
// Set<Option> opts = knownOptions.get(opt.getClass());
// if (opts == null) {
// opts = new HashSet<>();
// knownOptions.put(opt.getClass(), opts);
// }
// opts.add(opt);
// }
//
// private static final Map<Class, Set<Option>> knownOptions = new HashMap<>();
// }
//
// Path: core/src/main/java/org/projectodd/wunderboss/codecs/Codec.java
// public interface Codec<E,D> {
//
// E encode(D data);
//
// D decode(E encoded);
//
// Class<E> encodesTo();
//
// String name();
//
// String contentType();
// }
// Path: caching/src/main/java/org/projectodd/wunderboss/caching/Caching.java
import org.infinispan.Cache;
import org.projectodd.wunderboss.Component;
import org.projectodd.wunderboss.Option;
import org.projectodd.wunderboss.codecs.Codec;
import java.util.Map;
/*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.caching;
public interface Caching extends Component {
class CreateOption extends Option {
public static final CreateOption CONFIGURATION = opt("configuration", CreateOption.class);
public static final CreateOption TRANSACTIONAL = opt("transactional", false, CreateOption.class);
public static final CreateOption LOCKING = opt("locking", "OPTIMISTIC", CreateOption.class);
public static final CreateOption PERSIST = opt("persist", false, CreateOption.class);
public static final CreateOption MODE = opt("mode", CreateOption.class);
public static final CreateOption EVICTION = opt("eviction", "NONE", CreateOption.class);
public static final CreateOption MAX_ENTRIES = opt("max_entries", -1, CreateOption.class);
public static final CreateOption IDLE = opt("idle", -1, CreateOption.class);
public static final CreateOption TTL = opt("ttl", -1, CreateOption.class);
}
Cache findOrCreate(String name, Map<CreateOption,Object> options);
Cache find(String name); | Cache withCodec(Cache cache, Codec codec); |
projectodd/wunderboss | wildfly/transactions/src/main/java/org/projectodd/wunderboss/as/transactions/ASTransactionProvider.java | // Path: core/src/main/java/org/projectodd/wunderboss/Options.java
// public class Options<T> extends HashMap<T, Object> {
//
// public Options() {
// this(null);
// }
//
// public Options(Map<T, Object> options) {
// if (options != null) {
// putAll(options);
// }
// }
//
// /**
// * Looks up key in the options.
// *
// * If key is an Option, its default value will be returned if the key
// * isn't found.
// *
// * @param key
// * @return
// */
// public Object get(Object key) {
// Object val = super.get(key);
// if (val == null && key instanceof Option) {
// val = ((Option)key).defaultValue;
// }
//
// return val;
// }
//
// public Object get(T key, Object defaultValue) {
// return get(key) != null ? get(key) : defaultValue;
// }
//
// public Boolean getBoolean(T key) {
// return getBoolean(key, null);
// }
//
// public Boolean getBoolean(T key, Boolean defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Boolean)) {
// value = Boolean.parseBoolean(value.toString());
// }
//
// return (Boolean)value;
// }
//
// public Integer getInt(T key) {
// return getInt(key, null);
// }
//
// public Integer getInt(T key, Integer defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Integer)) {
// value = Integer.parseInt(value.toString());
// }
//
// return (Integer)value;
// }
//
// public Long getLong(T key) {
// return getLong(key, null);
// }
//
// public Long getLong(T key, Long defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Long)) {
// value = Long.parseLong(value.toString());
// }
//
// return (Long)value;
// }
//
// public Double getDouble(T key) {
// return getDouble(key, null);
// }
//
// public Double getDouble(T key, Double defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Double)) {
// value = Double.parseDouble(value.toString());
// }
//
// return (Double)value;
// }
//
// public String getString(T key) {
// return getString(key, null);
// }
//
// public String getString(T key, String defaultValue) {
// return get(key) != null ? get(key).toString() : defaultValue;
// }
//
// public Date getDate(T key) {
// return getDate(key, null);
// }
//
// public Date getDate(T key, Date defaultValue) {
// return get(key) != null ? (Date)get(key) : defaultValue;
// }
//
// public List getList(T key) {
// Object v = get(key);
// if (v instanceof List || v == null) {
// return (List) v;
// }
// return Arrays.asList(v);
// }
//
// public Options put(T key, Object value) {
// super.put(key, value);
//
// return this;
// }
//
// /**
// * Returns true if key resolves to a *non-null value* (considering
// * a possible default), false otherwise.
// */
// public boolean has(T key) {
// return get(key) != null;
// }
//
// public Options<T> merge(Options<T> otherOptions) {
// Options mergedOptions = new Options();
// for (T key : this.keySet()) {
// mergedOptions.put(key, this.get(key));
// }
// for (T key : otherOptions.keySet()) {
// mergedOptions.put(key, otherOptions.get(key));
// }
// return mergedOptions;
// }
// }
//
// Path: transactions/src/main/java/org/projectodd/wunderboss/transactions/Transaction.java
// public interface Transaction extends Component {
// TransactionManager manager();
//
// Object required(Callable f) throws Exception;
// Object requiresNew(Callable f) throws Exception;
// Object notSupported(Callable f) throws Exception;
// Object supports(Callable f) throws Exception;
// Object mandatory(Callable f) throws Exception;
// Object never(Callable f) throws Exception;
// }
| import org.projectodd.wunderboss.ComponentProvider;
import org.projectodd.wunderboss.Options;
import org.projectodd.wunderboss.transactions.Transaction; | /*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.as.transactions;
public class ASTransactionProvider implements ComponentProvider<Transaction> {
@Override | // Path: core/src/main/java/org/projectodd/wunderboss/Options.java
// public class Options<T> extends HashMap<T, Object> {
//
// public Options() {
// this(null);
// }
//
// public Options(Map<T, Object> options) {
// if (options != null) {
// putAll(options);
// }
// }
//
// /**
// * Looks up key in the options.
// *
// * If key is an Option, its default value will be returned if the key
// * isn't found.
// *
// * @param key
// * @return
// */
// public Object get(Object key) {
// Object val = super.get(key);
// if (val == null && key instanceof Option) {
// val = ((Option)key).defaultValue;
// }
//
// return val;
// }
//
// public Object get(T key, Object defaultValue) {
// return get(key) != null ? get(key) : defaultValue;
// }
//
// public Boolean getBoolean(T key) {
// return getBoolean(key, null);
// }
//
// public Boolean getBoolean(T key, Boolean defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Boolean)) {
// value = Boolean.parseBoolean(value.toString());
// }
//
// return (Boolean)value;
// }
//
// public Integer getInt(T key) {
// return getInt(key, null);
// }
//
// public Integer getInt(T key, Integer defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Integer)) {
// value = Integer.parseInt(value.toString());
// }
//
// return (Integer)value;
// }
//
// public Long getLong(T key) {
// return getLong(key, null);
// }
//
// public Long getLong(T key, Long defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Long)) {
// value = Long.parseLong(value.toString());
// }
//
// return (Long)value;
// }
//
// public Double getDouble(T key) {
// return getDouble(key, null);
// }
//
// public Double getDouble(T key, Double defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Double)) {
// value = Double.parseDouble(value.toString());
// }
//
// return (Double)value;
// }
//
// public String getString(T key) {
// return getString(key, null);
// }
//
// public String getString(T key, String defaultValue) {
// return get(key) != null ? get(key).toString() : defaultValue;
// }
//
// public Date getDate(T key) {
// return getDate(key, null);
// }
//
// public Date getDate(T key, Date defaultValue) {
// return get(key) != null ? (Date)get(key) : defaultValue;
// }
//
// public List getList(T key) {
// Object v = get(key);
// if (v instanceof List || v == null) {
// return (List) v;
// }
// return Arrays.asList(v);
// }
//
// public Options put(T key, Object value) {
// super.put(key, value);
//
// return this;
// }
//
// /**
// * Returns true if key resolves to a *non-null value* (considering
// * a possible default), false otherwise.
// */
// public boolean has(T key) {
// return get(key) != null;
// }
//
// public Options<T> merge(Options<T> otherOptions) {
// Options mergedOptions = new Options();
// for (T key : this.keySet()) {
// mergedOptions.put(key, this.get(key));
// }
// for (T key : otherOptions.keySet()) {
// mergedOptions.put(key, otherOptions.get(key));
// }
// return mergedOptions;
// }
// }
//
// Path: transactions/src/main/java/org/projectodd/wunderboss/transactions/Transaction.java
// public interface Transaction extends Component {
// TransactionManager manager();
//
// Object required(Callable f) throws Exception;
// Object requiresNew(Callable f) throws Exception;
// Object notSupported(Callable f) throws Exception;
// Object supports(Callable f) throws Exception;
// Object mandatory(Callable f) throws Exception;
// Object never(Callable f) throws Exception;
// }
// Path: wildfly/transactions/src/main/java/org/projectodd/wunderboss/as/transactions/ASTransactionProvider.java
import org.projectodd.wunderboss.ComponentProvider;
import org.projectodd.wunderboss.Options;
import org.projectodd.wunderboss.transactions.Transaction;
/*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.as.transactions;
public class ASTransactionProvider implements ComponentProvider<Transaction> {
@Override | public Transaction create(String name, Options options) { |
projectodd/wunderboss | caching/src/main/java/org/projectodd/wunderboss/caching/CachingProvider.java | // Path: core/src/main/java/org/projectodd/wunderboss/Options.java
// public class Options<T> extends HashMap<T, Object> {
//
// public Options() {
// this(null);
// }
//
// public Options(Map<T, Object> options) {
// if (options != null) {
// putAll(options);
// }
// }
//
// /**
// * Looks up key in the options.
// *
// * If key is an Option, its default value will be returned if the key
// * isn't found.
// *
// * @param key
// * @return
// */
// public Object get(Object key) {
// Object val = super.get(key);
// if (val == null && key instanceof Option) {
// val = ((Option)key).defaultValue;
// }
//
// return val;
// }
//
// public Object get(T key, Object defaultValue) {
// return get(key) != null ? get(key) : defaultValue;
// }
//
// public Boolean getBoolean(T key) {
// return getBoolean(key, null);
// }
//
// public Boolean getBoolean(T key, Boolean defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Boolean)) {
// value = Boolean.parseBoolean(value.toString());
// }
//
// return (Boolean)value;
// }
//
// public Integer getInt(T key) {
// return getInt(key, null);
// }
//
// public Integer getInt(T key, Integer defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Integer)) {
// value = Integer.parseInt(value.toString());
// }
//
// return (Integer)value;
// }
//
// public Long getLong(T key) {
// return getLong(key, null);
// }
//
// public Long getLong(T key, Long defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Long)) {
// value = Long.parseLong(value.toString());
// }
//
// return (Long)value;
// }
//
// public Double getDouble(T key) {
// return getDouble(key, null);
// }
//
// public Double getDouble(T key, Double defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Double)) {
// value = Double.parseDouble(value.toString());
// }
//
// return (Double)value;
// }
//
// public String getString(T key) {
// return getString(key, null);
// }
//
// public String getString(T key, String defaultValue) {
// return get(key) != null ? get(key).toString() : defaultValue;
// }
//
// public Date getDate(T key) {
// return getDate(key, null);
// }
//
// public Date getDate(T key, Date defaultValue) {
// return get(key) != null ? (Date)get(key) : defaultValue;
// }
//
// public List getList(T key) {
// Object v = get(key);
// if (v instanceof List || v == null) {
// return (List) v;
// }
// return Arrays.asList(v);
// }
//
// public Options put(T key, Object value) {
// super.put(key, value);
//
// return this;
// }
//
// /**
// * Returns true if key resolves to a *non-null value* (considering
// * a possible default), false otherwise.
// */
// public boolean has(T key) {
// return get(key) != null;
// }
//
// public Options<T> merge(Options<T> otherOptions) {
// Options mergedOptions = new Options();
// for (T key : this.keySet()) {
// mergedOptions.put(key, this.get(key));
// }
// for (T key : otherOptions.keySet()) {
// mergedOptions.put(key, otherOptions.get(key));
// }
// return mergedOptions;
// }
// }
| import org.projectodd.wunderboss.ComponentProvider;
import org.projectodd.wunderboss.Options; | /*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.caching;
public class CachingProvider implements ComponentProvider<Caching> {
@Override | // Path: core/src/main/java/org/projectodd/wunderboss/Options.java
// public class Options<T> extends HashMap<T, Object> {
//
// public Options() {
// this(null);
// }
//
// public Options(Map<T, Object> options) {
// if (options != null) {
// putAll(options);
// }
// }
//
// /**
// * Looks up key in the options.
// *
// * If key is an Option, its default value will be returned if the key
// * isn't found.
// *
// * @param key
// * @return
// */
// public Object get(Object key) {
// Object val = super.get(key);
// if (val == null && key instanceof Option) {
// val = ((Option)key).defaultValue;
// }
//
// return val;
// }
//
// public Object get(T key, Object defaultValue) {
// return get(key) != null ? get(key) : defaultValue;
// }
//
// public Boolean getBoolean(T key) {
// return getBoolean(key, null);
// }
//
// public Boolean getBoolean(T key, Boolean defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Boolean)) {
// value = Boolean.parseBoolean(value.toString());
// }
//
// return (Boolean)value;
// }
//
// public Integer getInt(T key) {
// return getInt(key, null);
// }
//
// public Integer getInt(T key, Integer defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Integer)) {
// value = Integer.parseInt(value.toString());
// }
//
// return (Integer)value;
// }
//
// public Long getLong(T key) {
// return getLong(key, null);
// }
//
// public Long getLong(T key, Long defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Long)) {
// value = Long.parseLong(value.toString());
// }
//
// return (Long)value;
// }
//
// public Double getDouble(T key) {
// return getDouble(key, null);
// }
//
// public Double getDouble(T key, Double defaultValue) {
// Object value = get(key);
// if (value == null) {
// value = defaultValue;
// } else if (!(value instanceof Double)) {
// value = Double.parseDouble(value.toString());
// }
//
// return (Double)value;
// }
//
// public String getString(T key) {
// return getString(key, null);
// }
//
// public String getString(T key, String defaultValue) {
// return get(key) != null ? get(key).toString() : defaultValue;
// }
//
// public Date getDate(T key) {
// return getDate(key, null);
// }
//
// public Date getDate(T key, Date defaultValue) {
// return get(key) != null ? (Date)get(key) : defaultValue;
// }
//
// public List getList(T key) {
// Object v = get(key);
// if (v instanceof List || v == null) {
// return (List) v;
// }
// return Arrays.asList(v);
// }
//
// public Options put(T key, Object value) {
// super.put(key, value);
//
// return this;
// }
//
// /**
// * Returns true if key resolves to a *non-null value* (considering
// * a possible default), false otherwise.
// */
// public boolean has(T key) {
// return get(key) != null;
// }
//
// public Options<T> merge(Options<T> otherOptions) {
// Options mergedOptions = new Options();
// for (T key : this.keySet()) {
// mergedOptions.put(key, this.get(key));
// }
// for (T key : otherOptions.keySet()) {
// mergedOptions.put(key, otherOptions.get(key));
// }
// return mergedOptions;
// }
// }
// Path: caching/src/main/java/org/projectodd/wunderboss/caching/CachingProvider.java
import org.projectodd.wunderboss.ComponentProvider;
import org.projectodd.wunderboss.Options;
/*
* Copyright 2014-2016 Red Hat, Inc, and individual contributors.
*
* 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.projectodd.wunderboss.caching;
public class CachingProvider implements ComponentProvider<Caching> {
@Override | public Caching create(String name, Options opts) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.