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
|
---|---|---|---|---|---|---|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/IntegerFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
import com.bing.excel.vo.OutValue.OutType;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-10 Description:
*/
public final class IntegerFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(int.class) || clz.equals(Integer.class);
}
/**
* @return return the long value; return Long.decode(str),only in this case the str start with "0x"
*/
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/IntegerFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
import com.bing.excel.vo.OutValue.OutType;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-10 Description:
*/
public final class IntegerFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(int.class) || clz.equals(Integer.class);
}
/**
* @return return the long value; return Long.decode(str),only in this case the str start with "0x"
*/
@Override
|
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/IntegerFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
import com.bing.excel.vo.OutValue.OutType;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-10 Description:
*/
public final class IntegerFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(int.class) || clz.equals(Integer.class);
}
/**
* @return return the long value; return Long.decode(str),only in this case the str start with "0x"
*/
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
long value= Long.decode(cell).longValue();
if(value < Integer.MIN_VALUE || value > 0xFFFFFFFFl) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Integer((int)value);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/IntegerFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
import com.bing.excel.vo.OutValue.OutType;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-10 Description:
*/
public final class IntegerFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(int.class) || clz.equals(Integer.class);
}
/**
* @return return the long value; return Long.decode(str),only in this case the str start with "0x"
*/
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
long value= Long.decode(cell).longValue();
if(value < Integer.MIN_VALUE || value > 0xFFFFFFFFl) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Integer((int)value);
}
@Override
|
public OutValue toObject(Object source,ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/FloatFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class FloatFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(float.class) || clz.equals(Float.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/FloatFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class FloatFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(float.class) || clz.equals(Float.class);
}
@Override
|
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/FloatFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class FloatFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(float.class) || clz.equals(Float.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if(Strings.isNullOrEmpty(cell)){
return null;
}
return Float.valueOf(cell);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/FloatFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class FloatFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(float.class) || clz.equals(Float.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if(Strings.isNullOrEmpty(cell)){
return null;
}
return Float.valueOf(cell);
}
@Override
|
public OutValue toObject(Object source,ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/mapper/ExcelConverterMapperHandler.java
|
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/mapper/ConversionMapper.java
// public static class FieldConverterMapper {
//
// private int index;
// private boolean isPrimitive = true;
// private Class<?> clazz;
// private FieldValueConverter converter;
// private String alias;
// private boolean readRequired = false;
//
// private Class container;
//
// public Class getContainer() {
// return container;
// }
//
// public void setContainer(Class container) {
// this.container = container;
// }
//
// public int getIndex() {
// return index;
// }
//
// public boolean isPrimitive() {
// return isPrimitive;
// }
//
// public Class<?> getFieldClass() {
// return clazz;
// }
//
// public String getAlias() {
// return alias;
// }
//
//
// public boolean isReadRequired() {
// return readRequired;
// }
//
// public FieldValueConverter getFieldConverter() {
// return converter;
// }
//
// public void setFieldConverter(FieldValueConverter converter) {
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz, boolean readRequired) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.readRequired = readRequired;
// this.converter = converter;
// }
//
// }
|
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.mapper.ConversionMapper.FieldConverterMapper;
|
package com.bing.excel.mapper;
public interface ExcelConverterMapperHandler {
ConversionMapper getObjConversionMapper();
@Deprecated
|
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/mapper/ConversionMapper.java
// public static class FieldConverterMapper {
//
// private int index;
// private boolean isPrimitive = true;
// private Class<?> clazz;
// private FieldValueConverter converter;
// private String alias;
// private boolean readRequired = false;
//
// private Class container;
//
// public Class getContainer() {
// return container;
// }
//
// public void setContainer(Class container) {
// this.container = container;
// }
//
// public int getIndex() {
// return index;
// }
//
// public boolean isPrimitive() {
// return isPrimitive;
// }
//
// public Class<?> getFieldClass() {
// return clazz;
// }
//
// public String getAlias() {
// return alias;
// }
//
//
// public boolean isReadRequired() {
// return readRequired;
// }
//
// public FieldValueConverter getFieldConverter() {
// return converter;
// }
//
// public void setFieldConverter(FieldValueConverter converter) {
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz, boolean readRequired) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.readRequired = readRequired;
// this.converter = converter;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/mapper/ExcelConverterMapperHandler.java
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.mapper.ConversionMapper.FieldConverterMapper;
package com.bing.excel.mapper;
public interface ExcelConverterMapperHandler {
ConversionMapper getObjConversionMapper();
@Deprecated
|
FieldValueConverter getLocalConverter(Class definedIn,
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/mapper/ExcelConverterMapperHandler.java
|
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/mapper/ConversionMapper.java
// public static class FieldConverterMapper {
//
// private int index;
// private boolean isPrimitive = true;
// private Class<?> clazz;
// private FieldValueConverter converter;
// private String alias;
// private boolean readRequired = false;
//
// private Class container;
//
// public Class getContainer() {
// return container;
// }
//
// public void setContainer(Class container) {
// this.container = container;
// }
//
// public int getIndex() {
// return index;
// }
//
// public boolean isPrimitive() {
// return isPrimitive;
// }
//
// public Class<?> getFieldClass() {
// return clazz;
// }
//
// public String getAlias() {
// return alias;
// }
//
//
// public boolean isReadRequired() {
// return readRequired;
// }
//
// public FieldValueConverter getFieldConverter() {
// return converter;
// }
//
// public void setFieldConverter(FieldValueConverter converter) {
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz, boolean readRequired) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.readRequired = readRequired;
// this.converter = converter;
// }
//
// }
|
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.mapper.ConversionMapper.FieldConverterMapper;
|
package com.bing.excel.mapper;
public interface ExcelConverterMapperHandler {
ConversionMapper getObjConversionMapper();
@Deprecated
FieldValueConverter getLocalConverter(Class definedIn,
String fieldName);
|
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/mapper/ConversionMapper.java
// public static class FieldConverterMapper {
//
// private int index;
// private boolean isPrimitive = true;
// private Class<?> clazz;
// private FieldValueConverter converter;
// private String alias;
// private boolean readRequired = false;
//
// private Class container;
//
// public Class getContainer() {
// return container;
// }
//
// public void setContainer(Class container) {
// this.container = container;
// }
//
// public int getIndex() {
// return index;
// }
//
// public boolean isPrimitive() {
// return isPrimitive;
// }
//
// public Class<?> getFieldClass() {
// return clazz;
// }
//
// public String getAlias() {
// return alias;
// }
//
//
// public boolean isReadRequired() {
// return readRequired;
// }
//
// public FieldValueConverter getFieldConverter() {
// return converter;
// }
//
// public void setFieldConverter(FieldValueConverter converter) {
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.converter = converter;
// }
//
// public FieldConverterMapper(int index, FieldValueConverter converter,
// String alias, Class<?> clazz, boolean readRequired) {
// super();
// this.index = index;
// this.isPrimitive = clazz.isPrimitive();
// this.clazz = clazz;
// this.alias = alias;
// this.readRequired = readRequired;
// this.converter = converter;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/mapper/ExcelConverterMapperHandler.java
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.mapper.ConversionMapper.FieldConverterMapper;
package com.bing.excel.mapper;
public interface ExcelConverterMapperHandler {
ConversionMapper getObjConversionMapper();
@Deprecated
FieldValueConverter getLocalConverter(Class definedIn,
String fieldName);
|
FieldConverterMapper getLocalFieldConverterMapper(Class definedIn,
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/DoubleFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import org.apache.commons.lang3.StringUtils;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
|
package com.bing.excel.converter.base;
public final class DoubleFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class type) {
return type.equals(double.class) || type.equals(Double.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/DoubleFieldConverter.java
import java.lang.reflect.Type;
import org.apache.commons.lang3.StringUtils;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
package com.bing.excel.converter.base;
public final class DoubleFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class type) {
return type.equals(double.class) || type.equals(Double.class);
}
@Override
|
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/DoubleFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import org.apache.commons.lang3.StringUtils;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
|
package com.bing.excel.converter.base;
public final class DoubleFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class type) {
return type.equals(double.class) || type.equals(Double.class);
}
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if(StringUtils.isBlank(cell)){
return null;
}
return Double.valueOf( cell);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/DoubleFieldConverter.java
import java.lang.reflect.Type;
import org.apache.commons.lang3.StringUtils;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.vo.OutValue;
package com.bing.excel.converter.base;
public final class DoubleFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class type) {
return type.equals(double.class) || type.equals(Double.class);
}
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if(StringUtils.isBlank(cell)){
return null;
}
return Double.valueOf( cell);
}
@Override
|
public OutValue toObject(Object source,ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/StringFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
|
package com.bing.excel.converter.base;
public final class StringFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(String.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/StringFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
package com.bing.excel.converter.base;
public final class StringFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(String.class);
}
@Override
|
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/ByteFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class ByteFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(byte.class) || clz.equals(Byte.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/ByteFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class ByteFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(byte.class) || clz.equals(Byte.class);
}
@Override
|
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/ByteFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class ByteFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(byte.class) || clz.equals(Byte.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
int value = Integer.decode(cell).intValue();
if(value < Byte.MIN_VALUE || value > 0xFF) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Byte((byte)value);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/ByteFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
* @author shizhongtao
*
* date 2016-3-21
* Description:
*/
public final class ByteFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(byte.class) || clz.equals(Byte.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
int value = Integer.decode(cell).intValue();
if(value < Byte.MIN_VALUE || value > 0xFF) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Byte((byte)value);
}
@Override
|
public OutValue toObject(Object source,ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/ShortFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
public final class ShortFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(short.class) || clz.equals(Short.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/ShortFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
public final class ShortFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(short.class) || clz.equals(Short.class);
}
@Override
|
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/ShortFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
public final class ShortFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(short.class) || clz.equals(Short.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if(Strings.isNullOrEmpty(cell)){
return null;
}
int value = Integer.valueOf(cell).intValue();
if(value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Short((short)value);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/ShortFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
public final class ShortFieldConverter extends AbstractFieldConvertor {
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(short.class) || clz.equals(Short.class);
}
@Override
public Object fromString(String cell, ConverterHandler converterHandler, Type targetType) {
if(Strings.isNullOrEmpty(cell)){
return null;
}
int value = Integer.valueOf(cell).intValue();
if(value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
throw new NumberFormatException("For input string: \"" + cell + '"');
}
return new Short((short)value);
}
@Override
|
public OutValue toObject(Object source,ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
*
* @author shizhongtao
*
* date 2016-3-21
* Description: thanks for Joe Walnes and David Blevins
*/
public final class BooleanFieldConverter extends AbstractFieldConvertor {
private final boolean caseSensitive;
private final String trueCaseStr;
private final String falseCaseStr;
/**
* @param trueCaseStr 为真时候的输入
* @param falseCaseStr 为家时候的输入
* @param caseSensitive 是不是忽略大小写
*/
public BooleanFieldConverter(String trueCaseStr, String falseCaseStr,
boolean caseSensitive) {
this.caseSensitive = caseSensitive;
this.trueCaseStr = trueCaseStr;
this.falseCaseStr = falseCaseStr;
}
/**
* 默认的boolean类型转换器,支持"TRUE", "FALSE"字符的转换
*/
public BooleanFieldConverter() {
this("TRUE", "FALSE", false);
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(boolean.class) || clz.equals(Boolean.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
*
* @author shizhongtao
*
* date 2016-3-21
* Description: thanks for Joe Walnes and David Blevins
*/
public final class BooleanFieldConverter extends AbstractFieldConvertor {
private final boolean caseSensitive;
private final String trueCaseStr;
private final String falseCaseStr;
/**
* @param trueCaseStr 为真时候的输入
* @param falseCaseStr 为家时候的输入
* @param caseSensitive 是不是忽略大小写
*/
public BooleanFieldConverter(String trueCaseStr, String falseCaseStr,
boolean caseSensitive) {
this.caseSensitive = caseSensitive;
this.trueCaseStr = trueCaseStr;
this.falseCaseStr = falseCaseStr;
}
/**
* 默认的boolean类型转换器,支持"TRUE", "FALSE"字符的转换
*/
public BooleanFieldConverter() {
this("TRUE", "FALSE", false);
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(boolean.class) || clz.equals(Boolean.class);
}
@Override
|
public OutValue toObject(Object source, ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.base;
/**
*
* @author shizhongtao
*
* date 2016-3-21
* Description: thanks for Joe Walnes and David Blevins
*/
public final class BooleanFieldConverter extends AbstractFieldConvertor {
private final boolean caseSensitive;
private final String trueCaseStr;
private final String falseCaseStr;
/**
* @param trueCaseStr 为真时候的输入
* @param falseCaseStr 为家时候的输入
* @param caseSensitive 是不是忽略大小写
*/
public BooleanFieldConverter(String trueCaseStr, String falseCaseStr,
boolean caseSensitive) {
this.caseSensitive = caseSensitive;
this.trueCaseStr = trueCaseStr;
this.falseCaseStr = falseCaseStr;
}
/**
* 默认的boolean类型转换器,支持"TRUE", "FALSE"字符的转换
*/
public BooleanFieldConverter() {
this("TRUE", "FALSE", false);
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(boolean.class) || clz.equals(Boolean.class);
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.base;
/**
*
* @author shizhongtao
*
* date 2016-3-21
* Description: thanks for Joe Walnes and David Blevins
*/
public final class BooleanFieldConverter extends AbstractFieldConvertor {
private final boolean caseSensitive;
private final String trueCaseStr;
private final String falseCaseStr;
/**
* @param trueCaseStr 为真时候的输入
* @param falseCaseStr 为家时候的输入
* @param caseSensitive 是不是忽略大小写
*/
public BooleanFieldConverter(String trueCaseStr, String falseCaseStr,
boolean caseSensitive) {
this.caseSensitive = caseSensitive;
this.trueCaseStr = trueCaseStr;
this.falseCaseStr = falseCaseStr;
}
/**
* 默认的boolean类型转换器,支持"TRUE", "FALSE"字符的转换
*/
public BooleanFieldConverter() {
this("TRUE", "FALSE", false);
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.equals(boolean.class) || clz.equals(Boolean.class);
}
@Override
|
public OutValue toObject(Object source, ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
if(source==null){
return null;
}
String re;
if((boolean)source){
re=trueCaseStr;
}else{
re=falseCaseStr;
}
return OutValue.stringValue(re);
}
/*
* in other case ,return false?FIXME
*/
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
Boolean re;
if (caseSensitive) {
re = trueCaseStr.equals(cell) ? Boolean.TRUE : Boolean.FALSE;
} else {
re = trueCaseStr.equalsIgnoreCase(cell) ? Boolean.TRUE
: Boolean.FALSE;
}
if (!re) {
if (caseSensitive) {
if (!falseCaseStr.equals(cell)) {
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/base/BooleanFieldConverter.java
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
if(source==null){
return null;
}
String re;
if((boolean)source){
re=trueCaseStr;
}else{
re=falseCaseStr;
}
return OutValue.stringValue(re);
}
/*
* in other case ,return false?FIXME
*/
@Override
public Object fromString(String cell,ConverterHandler converterHandler,Type targetType) {
if (Strings.isNullOrEmpty(cell)) {
return null;
}
Boolean re;
if (caseSensitive) {
re = trueCaseStr.equals(cell) ? Boolean.TRUE : Boolean.FALSE;
} else {
re = trueCaseStr.equalsIgnoreCase(cell) ? Boolean.TRUE
: Boolean.FALSE;
}
if (!re) {
if (caseSensitive) {
if (!falseCaseStr.equals(cell)) {
|
throw new ConversionException("Cann't parse value '"+cell+"' to java.lang.Boolean");
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
|
public OutValue toObject(Object source, ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
|
public OutValue toObject(Object source, ConverterHandler converterHandler) {
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
public OutValue toObject(Object source, ConverterHandler converterHandler) {
if(source==null){
return null;
}
Class<?> type = source.getClass().getComponentType();
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
public OutValue toObject(Object source, ConverterHandler converterHandler) {
if(source==null){
return null;
}
Class<?> type = source.getClass().getComponentType();
|
FieldValueConverter converter = converterHandler.getLocalConverter(type);
|
bingyulei007/bingexcel
|
excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
|
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
|
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
public OutValue toObject(Object source, ConverterHandler converterHandler) {
if(source==null){
return null;
}
Class<?> type = source.getClass().getComponentType();
FieldValueConverter converter = converterHandler.getLocalConverter(type);
if(converter==null){
|
// Path: excel/src/main/java/com/bing/excel/converter/AbstractFieldConvertor.java
// public class AbstractFieldConvertor implements FieldValueConverter {
//
// @Override
// public boolean canConvert(Class<?> clz) {
//
// return false;
// }
//
// @Override
// public OutValue toObject(Object source, ConverterHandler converterHandler) {
// if(source==null){
// return null;
// }
// return new OutValue(OutValue.OutType.STRING, source.toString());
// }
//
// @Override
// public Object fromString(String cell, ConverterHandler converterHandler,
// Type targetType) {
// if (cell == null) {
// return null;
// }
// return cell;
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/converter/FieldValueConverter.java
// public interface FieldValueConverter extends ConverterMatcher {
// OutValue toObject(Object source,ConverterHandler converterHandler);
// Object fromString(String cell,ConverterHandler converterHandler,Type targetType);
// }
//
// Path: excel/src/main/java/com/bing/excel/core/handler/ConverterHandler.java
// public interface ConverterHandler {
//
//
// /**
// * Get default FieldConverter which is difined by <code>BaseGlobalConverterMapper</code> or user.
// * @param keyFieldType
// * @return defaultConvetter or null
// */
// FieldValueConverter getLocalConverter(Class<?> keyFieldType);
//
// /**
// * Registe converter for this {@code Class} clazz.
// * @param clazz
// * @param converter
// */
// void registerConverter(Class<?> clazz, FieldValueConverter converter);
//
//
// }
//
// Path: excel/src/main/java/com/bing/excel/exception/ConversionException.java
// public class ConversionException extends RuntimeException {
//
// public ConversionException() {
// super();
// }
//
// public ConversionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public ConversionException(String message) {
// super(message);
// }
//
// public ConversionException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: excel/src/main/java/com/bing/excel/vo/OutValue.java
// public class OutValue {
// public enum OutType {
// INTEGER, LONG, DOUBLE, STRING, DATE, UNDEFINED
// }
//
// private OutType outType;
// private Object value;
//
//
//
// public OutValue(OutType outType, Object value) {
// super();
// this.outType = outType;
// this.value = value;
// }
// public static OutValue intValue(Object obj){
// return new OutValue(OutType.INTEGER,obj);
// }
// public static OutValue doubleValue(Object obj){
// return new OutValue(OutType.DOUBLE,obj);
// }
// public static OutValue longValue(Object obj){
// return new OutValue(OutType.LONG,obj);
// }
// public static OutValue stringValue(Object obj){
// return new OutValue(OutType.STRING,obj);
// }
// public static OutValue dateValue(Object obj){
// return new OutValue(OutType.DATE,obj);
// }
// public OutType getOutType() {
// return outType;
// }
// public void setOutType(OutType outType) {
// this.outType = outType;
// }
// public Object getValue() {
// return value;
// }
// public void setValue(Object value) {
// this.value = value;
// }
//
// }
// Path: excel/src/main/java/com/bing/excel/converter/collections/ArrayConverter.java
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import com.bing.excel.converter.AbstractFieldConvertor;
import com.bing.excel.converter.FieldValueConverter;
import com.bing.excel.core.handler.ConverterHandler;
import com.bing.excel.exception.ConversionException;
import com.bing.excel.vo.OutValue;
import com.google.common.base.Strings;
package com.bing.excel.converter.collections;
/**
* @author shizhongtao
*
* date 2016-3-24
* Description:
*/
// TODO 等待完善
@Deprecated
public class ArrayConverter extends AbstractFieldConvertor {
private final String splitCharacter;
public final static String SPACE_SPLIT=" ";
public final static String SPACE_COMMA=",";
public final static String SPACE_SEMICOLON=";";
public ArrayConverter() {
splitCharacter=SPACE_COMMA;
}
public ArrayConverter(String splitCharacter) {
this.splitCharacter=splitCharacter;
}
@Override
public boolean canConvert(Class<?> clz) {
return clz.isArray();
}
@Override
public OutValue toObject(Object source, ConverterHandler converterHandler) {
if(source==null){
return null;
}
Class<?> type = source.getClass().getComponentType();
FieldValueConverter converter = converterHandler.getLocalConverter(type);
if(converter==null){
|
throw new ConversionException("can find the converter for type ["
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/MainPresenter.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.BasePresenter;
|
package io.nlopez.drebin.sample;
public class MainPresenter extends BasePresenter<MainBO, MainViewComponent> {
@Inject
public MainPresenter(@NonNull MainBO businessObject) {
super(businessObject);
}
public void loadData() {
List elements = bo().getElements();
view().fillListWithData(elements);
}
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.BasePresenter;
package io.nlopez.drebin.sample;
public class MainPresenter extends BasePresenter<MainBO, MainViewComponent> {
@Inject
public MainPresenter(@NonNull MainBO businessObject) {
super(businessObject);
}
public void loadData() {
List elements = bo().getElements();
view().fillListWithData(elements);
}
|
public void placeSelected(final Place place) {
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/MainPresenter.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.BasePresenter;
|
package io.nlopez.drebin.sample;
public class MainPresenter extends BasePresenter<MainBO, MainViewComponent> {
@Inject
public MainPresenter(@NonNull MainBO businessObject) {
super(businessObject);
}
public void loadData() {
List elements = bo().getElements();
view().fillListWithData(elements);
}
public void placeSelected(final Place place) {
view().showPlaceInfo(place);
}
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.BasePresenter;
package io.nlopez.drebin.sample;
public class MainPresenter extends BasePresenter<MainBO, MainViewComponent> {
@Inject
public MainPresenter(@NonNull MainBO businessObject) {
super(businessObject);
}
public void loadData() {
List elements = bo().getElements();
view().fillListWithData(elements);
}
public void placeSelected(final Place place) {
view().showPlaceInfo(place);
}
|
public void userSelected(final User user) {
|
mrmans0n/drebin
|
library/src/test/java/drebin/DrebinTest.java
|
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
// public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
//
// private final List mItems;
// private final SparseArrayCompat<Binder> mBinderCache;
// private final Context mContext;
// private final BinderSelectorMapper mMapper;
// private final BinderEnvironment mEnvironment;
// private final StableIdsResolver mIdResolver;
//
// public BinderRecyclerViewAdapter(Context context, List<?> items, BinderEnvironment environment, BinderSelectorMapper mapper, StableIdsResolver stableIdsResolver) {
// mContext = context;
// mEnvironment = environment;
// mBinderCache = new SparseArrayCompat<>();
// mItems = items;
// mMapper = mapper;
// mIdResolver = stableIdsResolver;
// setHasStableIds(mIdResolver != null);
// }
//
// public void add(Object item) {
// mItems.add(item);
// }
//
// public void addAll(List items) {
// mItems.addAll(items);
// }
//
// public void clear() {
// mItems.clear();
// }
//
// @Override public int getItemViewType(final int position) {
// Object rawItem = mItems.get(position);
// Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
// mBinderCache.put(binder.hashCode(), binder);
// return binder.hashCode();
// }
//
// @Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// Binder binder = mBinderCache.get(viewType);
// ViewHost viewHost = binder.createViewHost(binder.getViewFactory().create(mContext, parent));
// return new BinderViewHolder(viewHost, binder, mEnvironment);
// }
//
// @Override public void onBindViewHolder(final BinderRecyclerViewAdapter.BinderViewHolder holder, final int position) {
// Object item = mItems.get(position);
// holder.bind(item);
// }
//
// @Override public void onViewDetachedFromWindow(final BinderViewHolder holder) {
// holder.unbind();
// }
//
// @Override public int getItemCount() {
// return mItems.size();
// }
//
// @Override public long getItemId(final int position) {
// if (hasStableIds()) {
// return mIdResolver.getId(mItems.get(position), mEnvironment);
// }
// return super.getItemId(position);
// }
//
// static class BinderViewHolder extends RecyclerView.ViewHolder {
// private ViewHost mViewHost;
// private BinderEnvironment mBinderEnvironment;
// private Binder mBinder;
//
// BinderViewHolder(final ViewHost viewHost, final Binder binder, final BinderEnvironment binderEnvironment) {
// super(viewHost.rootView);
// mViewHost = viewHost;
// mBinder = binder;
// mBinderEnvironment = binderEnvironment;
// }
//
// public void bind(Object object) {
// mBinder.bind(object, mViewHost, mBinderEnvironment);
// }
//
// public void unbind() {
// mBinder.unbind(mViewHost, mBinderEnvironment);
// }
// }
// }
|
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import drebin.core.StableIdsResolver;
import drebin.util.BinderRecyclerViewAdapter;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
|
package drebin;
/**
* Tests {@link Drebin}
*/
@RunWith(RobolectricTestRunner.class)
public class DrebinTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public RecyclerView mRecyclerView;
private Drebin.DrebinBuilder mBuilder;
@Before
public void setup() {
mBuilder = Drebin.with(RuntimeEnvironment.application);
}
@Test
public void testAttachToRecyclerView() {
mBuilder.into(mRecyclerView);
|
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
// public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
//
// private final List mItems;
// private final SparseArrayCompat<Binder> mBinderCache;
// private final Context mContext;
// private final BinderSelectorMapper mMapper;
// private final BinderEnvironment mEnvironment;
// private final StableIdsResolver mIdResolver;
//
// public BinderRecyclerViewAdapter(Context context, List<?> items, BinderEnvironment environment, BinderSelectorMapper mapper, StableIdsResolver stableIdsResolver) {
// mContext = context;
// mEnvironment = environment;
// mBinderCache = new SparseArrayCompat<>();
// mItems = items;
// mMapper = mapper;
// mIdResolver = stableIdsResolver;
// setHasStableIds(mIdResolver != null);
// }
//
// public void add(Object item) {
// mItems.add(item);
// }
//
// public void addAll(List items) {
// mItems.addAll(items);
// }
//
// public void clear() {
// mItems.clear();
// }
//
// @Override public int getItemViewType(final int position) {
// Object rawItem = mItems.get(position);
// Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
// mBinderCache.put(binder.hashCode(), binder);
// return binder.hashCode();
// }
//
// @Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// Binder binder = mBinderCache.get(viewType);
// ViewHost viewHost = binder.createViewHost(binder.getViewFactory().create(mContext, parent));
// return new BinderViewHolder(viewHost, binder, mEnvironment);
// }
//
// @Override public void onBindViewHolder(final BinderRecyclerViewAdapter.BinderViewHolder holder, final int position) {
// Object item = mItems.get(position);
// holder.bind(item);
// }
//
// @Override public void onViewDetachedFromWindow(final BinderViewHolder holder) {
// holder.unbind();
// }
//
// @Override public int getItemCount() {
// return mItems.size();
// }
//
// @Override public long getItemId(final int position) {
// if (hasStableIds()) {
// return mIdResolver.getId(mItems.get(position), mEnvironment);
// }
// return super.getItemId(position);
// }
//
// static class BinderViewHolder extends RecyclerView.ViewHolder {
// private ViewHost mViewHost;
// private BinderEnvironment mBinderEnvironment;
// private Binder mBinder;
//
// BinderViewHolder(final ViewHost viewHost, final Binder binder, final BinderEnvironment binderEnvironment) {
// super(viewHost.rootView);
// mViewHost = viewHost;
// mBinder = binder;
// mBinderEnvironment = binderEnvironment;
// }
//
// public void bind(Object object) {
// mBinder.bind(object, mViewHost, mBinderEnvironment);
// }
//
// public void unbind() {
// mBinder.unbind(mViewHost, mBinderEnvironment);
// }
// }
// }
// Path: library/src/test/java/drebin/DrebinTest.java
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import drebin.core.StableIdsResolver;
import drebin.util.BinderRecyclerViewAdapter;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package drebin;
/**
* Tests {@link Drebin}
*/
@RunWith(RobolectricTestRunner.class)
public class DrebinTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public RecyclerView mRecyclerView;
private Drebin.DrebinBuilder mBuilder;
@Before
public void setup() {
mBuilder = Drebin.with(RuntimeEnvironment.application);
}
@Test
public void testAttachToRecyclerView() {
mBuilder.into(mRecyclerView);
|
verify(mRecyclerView).setAdapter(any(BinderRecyclerViewAdapter.class));
|
mrmans0n/drebin
|
library/src/test/java/drebin/DrebinTest.java
|
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
// public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
//
// private final List mItems;
// private final SparseArrayCompat<Binder> mBinderCache;
// private final Context mContext;
// private final BinderSelectorMapper mMapper;
// private final BinderEnvironment mEnvironment;
// private final StableIdsResolver mIdResolver;
//
// public BinderRecyclerViewAdapter(Context context, List<?> items, BinderEnvironment environment, BinderSelectorMapper mapper, StableIdsResolver stableIdsResolver) {
// mContext = context;
// mEnvironment = environment;
// mBinderCache = new SparseArrayCompat<>();
// mItems = items;
// mMapper = mapper;
// mIdResolver = stableIdsResolver;
// setHasStableIds(mIdResolver != null);
// }
//
// public void add(Object item) {
// mItems.add(item);
// }
//
// public void addAll(List items) {
// mItems.addAll(items);
// }
//
// public void clear() {
// mItems.clear();
// }
//
// @Override public int getItemViewType(final int position) {
// Object rawItem = mItems.get(position);
// Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
// mBinderCache.put(binder.hashCode(), binder);
// return binder.hashCode();
// }
//
// @Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// Binder binder = mBinderCache.get(viewType);
// ViewHost viewHost = binder.createViewHost(binder.getViewFactory().create(mContext, parent));
// return new BinderViewHolder(viewHost, binder, mEnvironment);
// }
//
// @Override public void onBindViewHolder(final BinderRecyclerViewAdapter.BinderViewHolder holder, final int position) {
// Object item = mItems.get(position);
// holder.bind(item);
// }
//
// @Override public void onViewDetachedFromWindow(final BinderViewHolder holder) {
// holder.unbind();
// }
//
// @Override public int getItemCount() {
// return mItems.size();
// }
//
// @Override public long getItemId(final int position) {
// if (hasStableIds()) {
// return mIdResolver.getId(mItems.get(position), mEnvironment);
// }
// return super.getItemId(position);
// }
//
// static class BinderViewHolder extends RecyclerView.ViewHolder {
// private ViewHost mViewHost;
// private BinderEnvironment mBinderEnvironment;
// private Binder mBinder;
//
// BinderViewHolder(final ViewHost viewHost, final Binder binder, final BinderEnvironment binderEnvironment) {
// super(viewHost.rootView);
// mViewHost = viewHost;
// mBinder = binder;
// mBinderEnvironment = binderEnvironment;
// }
//
// public void bind(Object object) {
// mBinder.bind(object, mViewHost, mBinderEnvironment);
// }
//
// public void unbind() {
// mBinder.unbind(mViewHost, mBinderEnvironment);
// }
// }
// }
|
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import drebin.core.StableIdsResolver;
import drebin.util.BinderRecyclerViewAdapter;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
|
mBuilder = Drebin.with(RuntimeEnvironment.application);
}
@Test
public void testAttachToRecyclerView() {
mBuilder.into(mRecyclerView);
verify(mRecyclerView).setAdapter(any(BinderRecyclerViewAdapter.class));
}
@Test
public void testNoEnvironmentCreatesEnvironment() {
mBuilder.into(mRecyclerView);
assertThat(mBuilder.mEnvironment).isNotNull();
}
@Test
public void testNoItemsCreatesList() {
mBuilder.into(mRecyclerView);
assertThat(mBuilder.mItems).isNotNull();
}
@Test
public void testNoStableIdsResolverMakesStableIdsFalse() {
BinderRecyclerViewAdapter adapter = mBuilder.into(mRecyclerView);
assertThat(adapter.hasStableIds()).isFalse();
}
@Test
public void testStableIdsResolverMakesStableIdsTrue() {
BinderRecyclerViewAdapter adapter =
|
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
// public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
//
// private final List mItems;
// private final SparseArrayCompat<Binder> mBinderCache;
// private final Context mContext;
// private final BinderSelectorMapper mMapper;
// private final BinderEnvironment mEnvironment;
// private final StableIdsResolver mIdResolver;
//
// public BinderRecyclerViewAdapter(Context context, List<?> items, BinderEnvironment environment, BinderSelectorMapper mapper, StableIdsResolver stableIdsResolver) {
// mContext = context;
// mEnvironment = environment;
// mBinderCache = new SparseArrayCompat<>();
// mItems = items;
// mMapper = mapper;
// mIdResolver = stableIdsResolver;
// setHasStableIds(mIdResolver != null);
// }
//
// public void add(Object item) {
// mItems.add(item);
// }
//
// public void addAll(List items) {
// mItems.addAll(items);
// }
//
// public void clear() {
// mItems.clear();
// }
//
// @Override public int getItemViewType(final int position) {
// Object rawItem = mItems.get(position);
// Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
// mBinderCache.put(binder.hashCode(), binder);
// return binder.hashCode();
// }
//
// @Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// Binder binder = mBinderCache.get(viewType);
// ViewHost viewHost = binder.createViewHost(binder.getViewFactory().create(mContext, parent));
// return new BinderViewHolder(viewHost, binder, mEnvironment);
// }
//
// @Override public void onBindViewHolder(final BinderRecyclerViewAdapter.BinderViewHolder holder, final int position) {
// Object item = mItems.get(position);
// holder.bind(item);
// }
//
// @Override public void onViewDetachedFromWindow(final BinderViewHolder holder) {
// holder.unbind();
// }
//
// @Override public int getItemCount() {
// return mItems.size();
// }
//
// @Override public long getItemId(final int position) {
// if (hasStableIds()) {
// return mIdResolver.getId(mItems.get(position), mEnvironment);
// }
// return super.getItemId(position);
// }
//
// static class BinderViewHolder extends RecyclerView.ViewHolder {
// private ViewHost mViewHost;
// private BinderEnvironment mBinderEnvironment;
// private Binder mBinder;
//
// BinderViewHolder(final ViewHost viewHost, final Binder binder, final BinderEnvironment binderEnvironment) {
// super(viewHost.rootView);
// mViewHost = viewHost;
// mBinder = binder;
// mBinderEnvironment = binderEnvironment;
// }
//
// public void bind(Object object) {
// mBinder.bind(object, mViewHost, mBinderEnvironment);
// }
//
// public void unbind() {
// mBinder.unbind(mViewHost, mBinderEnvironment);
// }
// }
// }
// Path: library/src/test/java/drebin/DrebinTest.java
import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import drebin.core.StableIdsResolver;
import drebin.util.BinderRecyclerViewAdapter;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
mBuilder = Drebin.with(RuntimeEnvironment.application);
}
@Test
public void testAttachToRecyclerView() {
mBuilder.into(mRecyclerView);
verify(mRecyclerView).setAdapter(any(BinderRecyclerViewAdapter.class));
}
@Test
public void testNoEnvironmentCreatesEnvironment() {
mBuilder.into(mRecyclerView);
assertThat(mBuilder.mEnvironment).isNotNull();
}
@Test
public void testNoItemsCreatesList() {
mBuilder.into(mRecyclerView);
assertThat(mBuilder.mItems).isNotNull();
}
@Test
public void testNoStableIdsResolverMakesStableIdsFalse() {
BinderRecyclerViewAdapter adapter = mBuilder.into(mRecyclerView);
assertThat(adapter.hasStableIds()).isFalse();
}
@Test
public void testStableIdsResolverMakesStableIdsTrue() {
BinderRecyclerViewAdapter adapter =
|
mBuilder.stabledIds(mock(StableIdsResolver.class))
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
|
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
|
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
|
private final SparseArrayCompat<Binder> mBinderCache;
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
|
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
|
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
private final SparseArrayCompat<Binder> mBinderCache;
private final Context mContext;
private final BinderSelectorMapper mMapper;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
private final SparseArrayCompat<Binder> mBinderCache;
private final Context mContext;
private final BinderSelectorMapper mMapper;
|
private final BinderEnvironment mEnvironment;
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
|
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
|
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
private final SparseArrayCompat<Binder> mBinderCache;
private final Context mContext;
private final BinderSelectorMapper mMapper;
private final BinderEnvironment mEnvironment;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
package drebin.util;
public class BinderRecyclerViewAdapter extends RecyclerView.Adapter<BinderRecyclerViewAdapter.BinderViewHolder> {
private final List mItems;
private final SparseArrayCompat<Binder> mBinderCache;
private final Context mContext;
private final BinderSelectorMapper mMapper;
private final BinderEnvironment mEnvironment;
|
private final StableIdsResolver mIdResolver;
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
|
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
|
mContext = context;
mEnvironment = environment;
mBinderCache = new SparseArrayCompat<>();
mItems = items;
mMapper = mapper;
mIdResolver = stableIdsResolver;
setHasStableIds(mIdResolver != null);
}
public void add(Object item) {
mItems.add(item);
}
public void addAll(List items) {
mItems.addAll(items);
}
public void clear() {
mItems.clear();
}
@Override public int getItemViewType(final int position) {
Object rawItem = mItems.get(position);
Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
mBinderCache.put(binder.hashCode(), binder);
return binder.hashCode();
}
@Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
Binder binder = mBinderCache.get(viewType);
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/StableIdsResolver.java
// public interface StableIdsResolver<M, BE extends BinderEnvironment> {
// int getId(M model, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
// Path: library/src/main/java/drebin/util/BinderRecyclerViewAdapter.java
import android.content.Context;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.StableIdsResolver;
import drebin.core.ViewHost;
mContext = context;
mEnvironment = environment;
mBinderCache = new SparseArrayCompat<>();
mItems = items;
mMapper = mapper;
mIdResolver = stableIdsResolver;
setHasStableIds(mIdResolver != null);
}
public void add(Object item) {
mItems.add(item);
}
public void addAll(List items) {
mItems.addAll(items);
}
public void clear() {
mItems.clear();
}
@Override public int getItemViewType(final int position) {
Object rawItem = mItems.get(position);
Binder binder = mMapper.binderForModel(rawItem, mEnvironment);
mBinderCache.put(binder.hashCode(), binder);
return binder.hashCode();
}
@Override public BinderRecyclerViewAdapter.BinderViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
Binder binder = mBinderCache.get(viewType);
|
ViewHost viewHost = binder.createViewHost(binder.getViewFactory().create(mContext, parent));
|
mrmans0n/drebin
|
library/src/test/java/drebin/environment/ClickableEnvironmentImplTest.java
|
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
|
import android.view.View;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.testing.TestModel;
import static org.mockito.Mockito.verify;
|
package drebin.environment;
/**
* Tests {@link ClickableEnvironmentImpl}
*/
@RunWith(RobolectricTestRunner.class)
public class ClickableEnvironmentImplTest {
@Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
|
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
// Path: library/src/test/java/drebin/environment/ClickableEnvironmentImplTest.java
import android.view.View;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.testing.TestModel;
import static org.mockito.Mockito.verify;
package drebin.environment;
/**
* Tests {@link ClickableEnvironmentImpl}
*/
@RunWith(RobolectricTestRunner.class)
public class ClickableEnvironmentImplTest {
@Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
|
@Mock private ClickableEnvironment.Listener<TestModel> mListener;
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/MainActivityModule.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
// public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
//
// @Inject Listener mListener;
//
// @Inject
// public MainActivityEnvironment() {
// }
//
// @Override public void placeSelected(Place place) {
// mListener.onPlaceSelected(place);
// }
//
// @Override public void userSelected(User user) {
// mListener.onUserSelected(user);
// }
//
// public interface Listener {
// void onPlaceSelected(Place place);
//
// void onUserSelected(User user);
// }
// }
|
import dagger.Module;
import dagger.Provides;
import io.nlopez.drebin.sample.binder.MainActivityEnvironment;
|
package io.nlopez.drebin.sample;
@Module
public class MainActivityModule {
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
// public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
//
// @Inject Listener mListener;
//
// @Inject
// public MainActivityEnvironment() {
// }
//
// @Override public void placeSelected(Place place) {
// mListener.onPlaceSelected(place);
// }
//
// @Override public void userSelected(User user) {
// mListener.onUserSelected(user);
// }
//
// public interface Listener {
// void onPlaceSelected(Place place);
//
// void onUserSelected(User user);
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/MainActivityModule.java
import dagger.Module;
import dagger.Provides;
import io.nlopez.drebin.sample.binder.MainActivityEnvironment;
package io.nlopez.drebin.sample;
@Module
public class MainActivityModule {
|
private final MainActivityEnvironment.Listener mEnvironmentListener;
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
|
package io.nlopez.drebin.sample.util;
/**
* Generates random data to fill lists
*/
public class DataGenerator {
private static final Random RANDOM = new Random();
private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
package io.nlopez.drebin.sample.util;
/**
* Generates random data to fill lists
*/
public class DataGenerator {
private static final Random RANDOM = new Random();
private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
|
private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
|
package io.nlopez.drebin.sample.util;
/**
* Generates random data to fill lists
*/
public class DataGenerator {
private static final Random RANDOM = new Random();
private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
@Inject
public DataGenerator() {
}
public List<User> generateUsers(int n) {
List<User> result = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
String name = names.get(RANDOM.nextInt(names.size()));
String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
String role = roles.get(RANDOM.nextInt(roles.size()));
User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
result.add(user);
}
return result;
}
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
package io.nlopez.drebin.sample.util;
/**
* Generates random data to fill lists
*/
public class DataGenerator {
private static final Random RANDOM = new Random();
private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
@Inject
public DataGenerator() {
}
public List<User> generateUsers(int n) {
List<User> result = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
String name = names.get(RANDOM.nextInt(names.size()));
String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
String role = roles.get(RANDOM.nextInt(roles.size()));
User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
result.add(user);
}
return result;
}
|
public List<Place> generatePlaces(int n) {
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/binder/UsersBinder.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
// V create(Context context, ViewGroup parent);
//
// /**
// * Convenience class for creating a view based on a layout resource
// */
// class INFLATE {
// public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
// return new ViewFactory<V>() {
// @Override public V create(final Context context, final ViewGroup parent) {
// return (V) LayoutInflater.from(context).inflate(resId, parent, false);
// }
// };
// }
// }
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.User;
|
package io.nlopez.drebin.sample.binder;
public class UsersBinder implements Binder<LinearLayout, UsersBinder.UserViewHost, User, HasUsersEnvironment> {
private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_user);
@Inject
public UsersBinder() {
}
@Override public ViewFactory<LinearLayout> getViewFactory() {
return VIEW_FACTORY;
}
@Override public UserViewHost createViewHost(LinearLayout view) {
return new UserViewHost(view);
}
@Override public void bind(final User model, UserViewHost viewHost, final HasUsersEnvironment environment) {
viewHost.text.setText(model.getFirstName() + " " + model.getLastName() + "\n" + model.getRole());
viewHost.image.setImageURI(model.getAvatar());
viewHost.rootView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(final View view) {
environment.userSelected(model);
}
});
}
@Override public void unbind(UserViewHost viewHost, HasUsersEnvironment environment) {
viewHost.rootView.setOnClickListener(null);
}
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
// V create(Context context, ViewGroup parent);
//
// /**
// * Convenience class for creating a view based on a layout resource
// */
// class INFLATE {
// public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
// return new ViewFactory<V>() {
// @Override public V create(final Context context, final ViewGroup parent) {
// return (V) LayoutInflater.from(context).inflate(resId, parent, false);
// }
// };
// }
// }
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/UsersBinder.java
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.User;
package io.nlopez.drebin.sample.binder;
public class UsersBinder implements Binder<LinearLayout, UsersBinder.UserViewHost, User, HasUsersEnvironment> {
private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_user);
@Inject
public UsersBinder() {
}
@Override public ViewFactory<LinearLayout> getViewFactory() {
return VIEW_FACTORY;
}
@Override public UserViewHost createViewHost(LinearLayout view) {
return new UserViewHost(view);
}
@Override public void bind(final User model, UserViewHost viewHost, final HasUsersEnvironment environment) {
viewHost.text.setText(model.getFirstName() + " " + model.getLastName() + "\n" + model.getRole());
viewHost.image.setImageURI(model.getAvatar());
viewHost.rootView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(final View view) {
environment.userSelected(model);
}
});
}
@Override public void unbind(UserViewHost viewHost, HasUsersEnvironment environment) {
viewHost.rootView.setOnClickListener(null);
}
|
static class UserViewHost extends ViewHost<LinearLayout> {
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/binder/PlacesBinder.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
// V create(Context context, ViewGroup parent);
//
// /**
// * Convenience class for creating a view based on a layout resource
// */
// class INFLATE {
// public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
// return new ViewFactory<V>() {
// @Override public V create(final Context context, final ViewGroup parent) {
// return (V) LayoutInflater.from(context).inflate(resId, parent, false);
// }
// };
// }
// }
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
|
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.Place;
|
package io.nlopez.drebin.sample.binder;
public class PlacesBinder implements Binder<LinearLayout, PlacesBinder.PlaceViewHost, Place, HasPlacesEnvironment> {
private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_place);
@Inject
public PlacesBinder() {
}
@Override public ViewFactory<LinearLayout> getViewFactory() {
return VIEW_FACTORY;
}
@Override public PlaceViewHost createViewHost(LinearLayout view) {
return new PlaceViewHost(view);
}
@Override public void bind(final Place model, PlaceViewHost viewHost, final HasPlacesEnvironment environment) {
viewHost.text.setText(model.getName());
viewHost.image.setImageURI(model.getImageUrl());
viewHost.rootView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(final View view) {
environment.placeSelected(model);
}
});
}
@Override public void unbind(PlaceViewHost viewHost, HasPlacesEnvironment environment) {
viewHost.rootView.setOnClickListener(null);
}
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/ViewFactory.java
// public interface ViewFactory<V extends View> {
// V create(Context context, ViewGroup parent);
//
// /**
// * Convenience class for creating a view based on a layout resource
// */
// class INFLATE {
// public static <V extends View> ViewFactory<V> fromLayout(@LayoutRes final int resId) {
// return new ViewFactory<V>() {
// @Override public V create(final Context context, final ViewGroup parent) {
// return (V) LayoutInflater.from(context).inflate(resId, parent, false);
// }
// };
// }
// }
// }
//
// Path: library/src/main/java/drebin/core/ViewHost.java
// public class ViewHost<V extends View> {
// public final V rootView;
//
// public ViewHost(V view) {
// this.rootView = view;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/PlacesBinder.java
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import drebin.core.Binder;
import drebin.core.ViewFactory;
import drebin.core.ViewHost;
import io.nlopez.drebin.sample.R;
import io.nlopez.drebin.sample.model.Place;
package io.nlopez.drebin.sample.binder;
public class PlacesBinder implements Binder<LinearLayout, PlacesBinder.PlaceViewHost, Place, HasPlacesEnvironment> {
private static final ViewFactory<LinearLayout> VIEW_FACTORY = ViewFactory.INFLATE.fromLayout(R.layout.view_place);
@Inject
public PlacesBinder() {
}
@Override public ViewFactory<LinearLayout> getViewFactory() {
return VIEW_FACTORY;
}
@Override public PlaceViewHost createViewHost(LinearLayout view) {
return new PlaceViewHost(view);
}
@Override public void bind(final Place model, PlaceViewHost viewHost, final HasPlacesEnvironment environment) {
viewHost.text.setText(model.getName());
viewHost.image.setImageURI(model.getImageUrl());
viewHost.rootView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(final View view) {
environment.placeSelected(model);
}
});
}
@Override public void unbind(PlaceViewHost viewHost, HasPlacesEnvironment environment) {
viewHost.rootView.setOnClickListener(null);
}
|
static class PlaceViewHost extends ViewHost<LinearLayout> {
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderSelectorMapper.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
|
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
|
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
// Path: library/src/main/java/drebin/util/BinderSelectorMapper.java
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
|
public void add(Class modelClass, Binder binder) {
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderSelectorMapper.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
|
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
|
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
public void add(Class modelClass, Binder binder) {
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
// Path: library/src/main/java/drebin/util/BinderSelectorMapper.java
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
public void add(Class modelClass, Binder binder) {
|
add(modelClass, BinderSelector.BINDER.build(binder));
|
mrmans0n/drebin
|
library/src/main/java/drebin/util/BinderSelectorMapper.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
|
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
|
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
public void add(Class modelClass, Binder binder) {
add(modelClass, BinderSelector.BINDER.build(binder));
}
public void add(Class modelClass, BinderSelector binderSelector) {
mEntries.put(modelClass, new Entry(modelClass, binderSelector));
}
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
// Path: library/src/main/java/drebin/util/BinderSelectorMapper.java
import android.support.annotation.NonNull;
import android.support.v4.util.ArrayMap;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
package drebin.util;
/**
* Convenience mapper from model classes to binder selectors.
*/
public class BinderSelectorMapper {
private final ArrayMap<Class, Entry> mEntries;
public BinderSelectorMapper() {
mEntries = new ArrayMap<>();
}
public void add(Class modelClass, Binder binder) {
add(modelClass, BinderSelector.BINDER.build(binder));
}
public void add(Class modelClass, BinderSelector binderSelector) {
mEntries.put(modelClass, new Entry(modelClass, binderSelector));
}
|
@NonNull Binder binderForModel(Object model, BinderEnvironment environment) {
|
mrmans0n/drebin
|
library/src/test/java/drebin/util/BinderSelectorMapperTest.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
|
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
|
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
// Path: library/src/test/java/drebin/util/BinderSelectorMapperTest.java
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
|
@Mock public Binder mBinder;
|
mrmans0n/drebin
|
library/src/test/java/drebin/util/BinderSelectorMapperTest.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
|
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
|
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
// Path: library/src/test/java/drebin/util/BinderSelectorMapperTest.java
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
@Mock public BinderSelector<TestModel, BinderEnvironment> mBinderSelector;
|
mrmans0n/drebin
|
library/src/test/java/drebin/util/BinderSelectorMapperTest.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
|
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
|
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
// Path: library/src/test/java/drebin/util/BinderSelectorMapperTest.java
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
@Mock public BinderSelector<TestModel, BinderEnvironment> mBinderSelector;
|
mrmans0n/drebin
|
library/src/test/java/drebin/util/BinderSelectorMapperTest.java
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
|
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
|
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
// Path: library/src/main/java/drebin/core/Binder.java
// public interface Binder<V extends View, VH extends ViewHost<V>, M, BE extends BinderEnvironment> {
// /**
// * @return an enclosing {@link ViewFactory} for a {@link View}. The {@link ViewFactory}
// * knows how to create a view.
// */
// ViewFactory<V> getViewFactory();
//
// /**
// * @param view a root view created in the {@link ViewFactory}
// * @return an enclosing {@link ViewHost} class.
// * <p>
// * The ViewHost would be the place to use injectors like ButterKnife or perform any decoration
// * on the view.
// */
// VH createViewHost(V view);
//
// /**
// * Displays the data from the model into the view.
// *
// * @param model
// * @param viewHost
// * @param environment
// */
// void bind(M model, VH viewHost, BE environment);
//
// /**
// * Cleans up anything done in the {@link #bind(Object, ViewHost, BinderEnvironment)} method.
// *
// * @param viewHost
// * @param environment
// */
// void unbind(VH viewHost, BE environment);
// }
//
// Path: library/src/main/java/drebin/core/BinderEnvironment.java
// public interface BinderEnvironment {
// /**
// * Empty implementation of a {@link BinderEnvironment}. Useful when you don't have
// * external input.
// */
// enum EmptyEnvironment implements BinderEnvironment {
// INSTANCE;
// }
// }
//
// Path: library/src/main/java/drebin/core/BinderSelector.java
// public interface BinderSelector<M, BE extends BinderEnvironment> {
//
// /**
// * @param model
// * @param environment
// * @return the appropriate {@link Binder} for the given model
// */
// Binder select(M model, BE environment);
//
// /**
// * Creates a {@link BinderSelector} based on an only possible {@link Binder}.
// */
// class BINDER {
// public static <M, BE extends BinderEnvironment> BinderSelector<M, BE> build(final Binder binder) {
// return new BinderSelector<M, BE>() {
// @Override public Binder select(final M item, final BE environment) {
// return binder;
// }
// };
// }
// }
// }
//
// Path: library/src/test/java/drebin/testing/TestModel.java
// public class TestModel {
// }
// Path: library/src/test/java/drebin/util/BinderSelectorMapperTest.java
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import drebin.core.Binder;
import drebin.core.BinderEnvironment;
import drebin.core.BinderSelector;
import drebin.testing.TestModel;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Mockito.when;
package drebin.util;
/**
* Tests {@link BinderSelectorMapper}
*/
@RunWith(RobolectricTestRunner.class)
public class BinderSelectorMapperTest {
@Rule public MockitoRule rule = MockitoJUnit.rule();
@Mock public Binder mBinder;
|
@Mock public BinderSelector<TestModel, BinderEnvironment> mBinderSelector;
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/MainViewComponent.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import java.util.List;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.ViewComponent;
|
package io.nlopez.drebin.sample;
public interface MainViewComponent extends ViewComponent {
void fillListWithData(List elements);
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/MainViewComponent.java
import java.util.List;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.ViewComponent;
package io.nlopez.drebin.sample;
public interface MainViewComponent extends ViewComponent {
void fillListWithData(List elements);
|
void showUserInfo(User user);
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/MainViewComponent.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import java.util.List;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.ViewComponent;
|
package io.nlopez.drebin.sample;
public interface MainViewComponent extends ViewComponent {
void fillListWithData(List elements);
void showUserInfo(User user);
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/MainViewComponent.java
import java.util.List;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
import revamp.base.ViewComponent;
package io.nlopez.drebin.sample;
public interface MainViewComponent extends ViewComponent {
void fillListWithData(List elements);
void showUserInfo(User user);
|
void showPlaceInfo(Place place);
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/app/AppComponent.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
// public class DataGenerator {
// private static final Random RANDOM = new Random();
//
// private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
// private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
// private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
//
// @Inject
// public DataGenerator() {
//
// }
//
// public List<User> generateUsers(int n) {
// List<User> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// String name = names.get(RANDOM.nextInt(names.size()));
// String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
// String role = roles.get(RANDOM.nextInt(roles.size()));
// User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
// result.add(user);
// }
// return result;
// }
//
// public List<Place> generatePlaces(int n) {
// List<Place> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// int length = 5 + RANDOM.nextInt(10);
// StringBuilder sb = new StringBuilder(length);
// for (int j = 0; j < length; j++) {
// char tmp = (char) ('a' + RANDOM.nextInt('z' - 'a'));
// sb.append(tmp);
// }
// Place place = new Place(sb.toString(), "http://loremflickr.com/600/300/city/all?random=" + i);
// result.add(place);
// }
// return result;
// }
//
// public List generateMix(int n) {
// List<User> users = generateUsers(n);
// List<Place> places = generatePlaces(n);
// List result = new ArrayList(n);
// for (int i = 0; i < n; i++) {
// int index = RANDOM.nextInt(n);
// if (RANDOM.nextBoolean()) {
// result.add(users.get(index));
// } else {
// result.add(places.get(index));
// }
// }
// return result;
// }
//
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/Toaster.java
// public class Toaster {
//
// @Inject Context mContext;
//
// @Inject
// public Toaster() {
//
// }
//
// public void show(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
// }
// }
|
import dagger.Component;
import io.nlopez.drebin.sample.util.DataGenerator;
import io.nlopez.drebin.sample.util.Toaster;
|
package io.nlopez.drebin.sample.app;
@Component(modules = AppModule.class)
public interface AppComponent {
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
// public class DataGenerator {
// private static final Random RANDOM = new Random();
//
// private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
// private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
// private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
//
// @Inject
// public DataGenerator() {
//
// }
//
// public List<User> generateUsers(int n) {
// List<User> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// String name = names.get(RANDOM.nextInt(names.size()));
// String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
// String role = roles.get(RANDOM.nextInt(roles.size()));
// User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
// result.add(user);
// }
// return result;
// }
//
// public List<Place> generatePlaces(int n) {
// List<Place> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// int length = 5 + RANDOM.nextInt(10);
// StringBuilder sb = new StringBuilder(length);
// for (int j = 0; j < length; j++) {
// char tmp = (char) ('a' + RANDOM.nextInt('z' - 'a'));
// sb.append(tmp);
// }
// Place place = new Place(sb.toString(), "http://loremflickr.com/600/300/city/all?random=" + i);
// result.add(place);
// }
// return result;
// }
//
// public List generateMix(int n) {
// List<User> users = generateUsers(n);
// List<Place> places = generatePlaces(n);
// List result = new ArrayList(n);
// for (int i = 0; i < n; i++) {
// int index = RANDOM.nextInt(n);
// if (RANDOM.nextBoolean()) {
// result.add(users.get(index));
// } else {
// result.add(places.get(index));
// }
// }
// return result;
// }
//
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/Toaster.java
// public class Toaster {
//
// @Inject Context mContext;
//
// @Inject
// public Toaster() {
//
// }
//
// public void show(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/app/AppComponent.java
import dagger.Component;
import io.nlopez.drebin.sample.util.DataGenerator;
import io.nlopez.drebin.sample.util.Toaster;
package io.nlopez.drebin.sample.app;
@Component(modules = AppModule.class)
public interface AppComponent {
|
DataGenerator getDataGenerator();
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/app/AppComponent.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
// public class DataGenerator {
// private static final Random RANDOM = new Random();
//
// private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
// private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
// private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
//
// @Inject
// public DataGenerator() {
//
// }
//
// public List<User> generateUsers(int n) {
// List<User> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// String name = names.get(RANDOM.nextInt(names.size()));
// String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
// String role = roles.get(RANDOM.nextInt(roles.size()));
// User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
// result.add(user);
// }
// return result;
// }
//
// public List<Place> generatePlaces(int n) {
// List<Place> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// int length = 5 + RANDOM.nextInt(10);
// StringBuilder sb = new StringBuilder(length);
// for (int j = 0; j < length; j++) {
// char tmp = (char) ('a' + RANDOM.nextInt('z' - 'a'));
// sb.append(tmp);
// }
// Place place = new Place(sb.toString(), "http://loremflickr.com/600/300/city/all?random=" + i);
// result.add(place);
// }
// return result;
// }
//
// public List generateMix(int n) {
// List<User> users = generateUsers(n);
// List<Place> places = generatePlaces(n);
// List result = new ArrayList(n);
// for (int i = 0; i < n; i++) {
// int index = RANDOM.nextInt(n);
// if (RANDOM.nextBoolean()) {
// result.add(users.get(index));
// } else {
// result.add(places.get(index));
// }
// }
// return result;
// }
//
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/Toaster.java
// public class Toaster {
//
// @Inject Context mContext;
//
// @Inject
// public Toaster() {
//
// }
//
// public void show(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
// }
// }
|
import dagger.Component;
import io.nlopez.drebin.sample.util.DataGenerator;
import io.nlopez.drebin.sample.util.Toaster;
|
package io.nlopez.drebin.sample.app;
@Component(modules = AppModule.class)
public interface AppComponent {
DataGenerator getDataGenerator();
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/DataGenerator.java
// public class DataGenerator {
// private static final Random RANDOM = new Random();
//
// private static final List<String> names = Arrays.asList("Maria", "Pablo", "Nacho", "Concha", "Pepe", "Tiburcio", "Estanislao", "Afrodisio", "Acisclo", "Juan", "John", "Paul", "Kevin", "Anacleto", "Farts", "Falos", "Perry", "Tyler", "Stan", "Kyle", "Eric", "Kenny");
// private static final List<String> lastNames = Arrays.asList("Perez", "Lopez", "Fernandez", "Mason", "Lee", "Who", "Doe", "Vergo", "Cifuentes", "Menchu", "Fuertes", "Funke", "MacGyver", "Trump", "McLovin", "McCool");
// private static final List<String> roles = Arrays.asList("User", "Admin", "VIP");
//
// @Inject
// public DataGenerator() {
//
// }
//
// public List<User> generateUsers(int n) {
// List<User> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// String name = names.get(RANDOM.nextInt(names.size()));
// String last = lastNames.get(RANDOM.nextInt(lastNames.size()));
// String role = roles.get(RANDOM.nextInt(roles.size()));
// User user = new User(name, last, role, "http://loremflickr.com/500/500/person/all?random=" + i);
// result.add(user);
// }
// return result;
// }
//
// public List<Place> generatePlaces(int n) {
// List<Place> result = new ArrayList<>(n);
// for (int i = 0; i < n; i++) {
// int length = 5 + RANDOM.nextInt(10);
// StringBuilder sb = new StringBuilder(length);
// for (int j = 0; j < length; j++) {
// char tmp = (char) ('a' + RANDOM.nextInt('z' - 'a'));
// sb.append(tmp);
// }
// Place place = new Place(sb.toString(), "http://loremflickr.com/600/300/city/all?random=" + i);
// result.add(place);
// }
// return result;
// }
//
// public List generateMix(int n) {
// List<User> users = generateUsers(n);
// List<Place> places = generatePlaces(n);
// List result = new ArrayList(n);
// for (int i = 0; i < n; i++) {
// int index = RANDOM.nextInt(n);
// if (RANDOM.nextBoolean()) {
// result.add(users.get(index));
// } else {
// result.add(places.get(index));
// }
// }
// return result;
// }
//
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/util/Toaster.java
// public class Toaster {
//
// @Inject Context mContext;
//
// @Inject
// public Toaster() {
//
// }
//
// public void show(String message) {
// Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/app/AppComponent.java
import dagger.Component;
import io.nlopez.drebin.sample.util.DataGenerator;
import io.nlopez.drebin.sample.util.Toaster;
package io.nlopez.drebin.sample.app;
@Component(modules = AppModule.class)
public interface AppComponent {
DataGenerator getDataGenerator();
|
Toaster getToaster();
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
|
package io.nlopez.drebin.sample.binder;
public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
@Inject Listener mListener;
@Inject
public MainActivityEnvironment() {
}
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
package io.nlopez.drebin.sample.binder;
public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
@Inject Listener mListener;
@Inject
public MainActivityEnvironment() {
}
|
@Override public void placeSelected(Place place) {
|
mrmans0n/drebin
|
sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
|
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
|
package io.nlopez.drebin.sample.binder;
public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
@Inject Listener mListener;
@Inject
public MainActivityEnvironment() {
}
@Override public void placeSelected(Place place) {
mListener.onPlaceSelected(place);
}
|
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/Place.java
// public class Place {
// private String imageUrl;
// private String name;
//
// public Place(String name, String imageUrl) {
// this.name = name;
// this.imageUrl = imageUrl;
// }
//
// public String getName() {
// return name;
// }
//
// public String getImageUrl() {
// return imageUrl;
// }
// }
//
// Path: sample/src/main/java/io/nlopez/drebin/sample/model/User.java
// public class User {
// private final String firstName;
// private final String lastName;
// private String role;
// private String avatar;
//
// public User(String firstName, String lastName, String role, String avatar) {
// this.firstName = firstName;
// this.lastName = lastName;
// this.role = role;
// this.avatar = avatar;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public String getRole() {
// return role;
// }
//
// public String getAvatar() {
// return avatar;
// }
// }
// Path: sample/src/main/java/io/nlopez/drebin/sample/binder/MainActivityEnvironment.java
import javax.inject.Inject;
import io.nlopez.drebin.sample.model.Place;
import io.nlopez.drebin.sample.model.User;
package io.nlopez.drebin.sample.binder;
public class MainActivityEnvironment implements HasPlacesEnvironment, HasUsersEnvironment {
@Inject Listener mListener;
@Inject
public MainActivityEnvironment() {
}
@Override public void placeSelected(Place place) {
mListener.onPlaceSelected(place);
}
|
@Override public void userSelected(User user) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/UniformRange.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
|
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class UniformRange implements IHandRange {
@Override
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
// Path: src/shaft/poker/agent/handranges/UniformRange.java
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class UniformRange implements IHandRange {
@Override
|
public double handWeight(Card c1, Card c2) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/weightedrange/CompositeFieldRange.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/agent/handranges/IPlayerRange.java
// public interface IPlayerRange extends IHandRange {
//
// public boolean activePlayer();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
import java.util.ArrayList;
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.agent.handranges.IPlayerRange;
import shaft.poker.game.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompositeFieldRange implements IHandRange, IPlayerActionListener {
private IWeightTable _wt;
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/agent/handranges/IPlayerRange.java
// public interface IPlayerRange extends IHandRange {
//
// public boolean activePlayer();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/agent/handranges/weightedrange/CompositeFieldRange.java
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
import java.util.ArrayList;
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.agent.handranges.IPlayerRange;
import shaft.poker.game.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompositeFieldRange implements IHandRange, IPlayerActionListener {
private IWeightTable _wt;
|
private List<IPlayerRange> _fieldRanges;
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/weightedrange/CompositeFieldRange.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/agent/handranges/IPlayerRange.java
// public interface IPlayerRange extends IHandRange {
//
// public boolean activePlayer();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
import java.util.ArrayList;
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.agent.handranges.IPlayerRange;
import shaft.poker.game.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompositeFieldRange implements IHandRange, IPlayerActionListener {
private IWeightTable _wt;
private List<IPlayerRange> _fieldRanges;
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/agent/handranges/IPlayerRange.java
// public interface IPlayerRange extends IHandRange {
//
// public boolean activePlayer();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/agent/handranges/weightedrange/CompositeFieldRange.java
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
import java.util.ArrayList;
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.agent.handranges.IPlayerRange;
import shaft.poker.game.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompositeFieldRange implements IHandRange, IPlayerActionListener {
private IWeightTable _wt;
private List<IPlayerRange> _fieldRanges;
|
public CompositeFieldRange(ITable table, IWeightTable wt) {
|
loopfz/Lucki
|
src/shaft/poker/game/table/PlayerData.java
|
// Path: src/shaft/poker/game/IPlayer.java
// public interface IPlayer {
//
// public String id();
//
// public void dealCard(Card c);
//
// public List<Card> holeCards();
//
// public IAction action(ITable table, IPlayerData plData, IActionBuilder plContext);
//
// public void setStack(int stack);
//
// public int stack();
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import java.util.ArrayList;
import java.util.List;
import shaft.poker.game.IPlayer;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PlayerData implements IPlayerData, IGameEventListener {
private IPlayer _pl;
private List<IPlayerActionListener> _listeners;
private List<IPlayerActionListener> _prioListeners;
private int _moneyInPotForRound;
private int _totalMoneyInPot;
private int _stack;
private int _maxWin;
private int _betsToCall;
private int _amountToCall;
private int _pos;
|
// Path: src/shaft/poker/game/IPlayer.java
// public interface IPlayer {
//
// public String id();
//
// public void dealCard(Card c);
//
// public List<Card> holeCards();
//
// public IAction action(ITable table, IPlayerData plData, IActionBuilder plContext);
//
// public void setStack(int stack);
//
// public int stack();
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/game/table/PlayerData.java
import java.util.ArrayList;
import java.util.List;
import shaft.poker.game.IPlayer;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PlayerData implements IPlayerData, IGameEventListener {
private IPlayer _pl;
private List<IPlayerActionListener> _listeners;
private List<IPlayerActionListener> _prioListeners;
private int _moneyInPotForRound;
private int _totalMoneyInPot;
private int _stack;
private int _maxWin;
private int _betsToCall;
private int _amountToCall;
private int _pos;
|
public PlayerData(IPlayer pl, ITable table) {
|
loopfz/Lucki
|
src/sane/Sane_EA.java
|
// Path: src/sane/Best_net_structure.java
// public class Best_net_structure {
//
// Best_net_structure() {
// neuron = new Neuron [Config.NUM_HIDDEN];
// }
//
// public Neuron neuron[];
//
// public float fitness;
//
// }
|
import sane.Best_net_structure;
import java.util.Random;
import java.io.*;
|
Sane.best_nets[child1].neuron[i] = pop[Config.POP_SIZE -
((Math.abs(myRandom.nextInt()) % 2)
+1) + (j*
(Math.abs(myRandom.nextInt()) %
OP_PER_ELITE)*2)];
else
Sane.best_nets[child1].neuron[i] = pop[j];
} /* end hideous for loop */
if (Config.NUM_HIDDEN > 10) {
Sane.best_nets[child1].neuron[Math.abs(myRandom.nextInt()) % Config.NUM_HIDDEN]
= pop[Math.abs(myRandom.nextInt()) % Config.POP_SIZE];
Sane.best_nets[child2].neuron[Math.abs(myRandom.nextInt()) % Config.NUM_HIDDEN]
= pop[Math.abs(myRandom.nextInt()) % Config.POP_SIZE];
} /* end if */
} /* end New_network_one_pt_crossover method */
/**********************************************************/
/*****************************************************************/
/* Sort_best_networks does an insertion sort on neurons based on */
/* their fitness values. */
/*****************************************************************/
static void Sort_best_networks() {
int i, j;
float k;
|
// Path: src/sane/Best_net_structure.java
// public class Best_net_structure {
//
// Best_net_structure() {
// neuron = new Neuron [Config.NUM_HIDDEN];
// }
//
// public Neuron neuron[];
//
// public float fitness;
//
// }
// Path: src/sane/Sane_EA.java
import sane.Best_net_structure;
import java.util.Random;
import java.io.*;
Sane.best_nets[child1].neuron[i] = pop[Config.POP_SIZE -
((Math.abs(myRandom.nextInt()) % 2)
+1) + (j*
(Math.abs(myRandom.nextInt()) %
OP_PER_ELITE)*2)];
else
Sane.best_nets[child1].neuron[i] = pop[j];
} /* end hideous for loop */
if (Config.NUM_HIDDEN > 10) {
Sane.best_nets[child1].neuron[Math.abs(myRandom.nextInt()) % Config.NUM_HIDDEN]
= pop[Math.abs(myRandom.nextInt()) % Config.POP_SIZE];
Sane.best_nets[child2].neuron[Math.abs(myRandom.nextInt()) % Config.NUM_HIDDEN]
= pop[Math.abs(myRandom.nextInt()) % Config.POP_SIZE];
} /* end if */
} /* end New_network_one_pt_crossover method */
/**********************************************************/
/*****************************************************************/
/* Sort_best_networks does an insertion sort on neurons based on */
/* their fitness values. */
/*****************************************************************/
static void Sort_best_networks() {
int i, j;
float k;
|
Best_net_structure temp;
|
loopfz/Lucki
|
src/shaft/poker/game/table/IActionBuilder.java
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IActionBuilder {
public void setContext(ITable table, IPlayerData plData);
public int minRaise();
public int maxRaise();
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/game/table/IActionBuilder.java
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IActionBuilder {
public void setContext(ITable table, IPlayerData plData);
public int minRaise();
public int maxRaise();
|
IAction makeSBlind();
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/weightedrange/frequencytable/PlayerSpecificFrequencyTable.java
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/agent/handranges/weightedrange/IFrequencyTable.java
// public interface IFrequencyTable {
//
// public double estimatedStrength(ActionType a, int numBets, Round bettingRound);
//
// }
//
// Path: src/shaft/poker/game/table/IPlayerActionListener.java
// public interface IPlayerActionListener {
//
// public void gameAction(ITable table, IPlayerData plData, ActionType type, int amount);
//
// public void leave(ITable table, IPlayerData plData);
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import java.util.List;
import shaft.poker.game.table.IPlayerData;
import shaft.poker.agent.handranges.weightedrange.IFrequencyTable;
import shaft.poker.game.table.IPlayerActionListener;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange.frequencytable;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PlayerSpecificFrequencyTable implements IFrequencyTable, IPlayerActionListener, IGameEventListener {
// Dimensions: [BettingRound][LastAction][NumBets][Fold/Call/Bet]
private int[][][][] _freqs;
IFrequencyTable _defaultFreqs;
private String _playerId;
private static final int MINIMUM_DATA = 20;
private ActionType _lastAction;
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/agent/handranges/weightedrange/IFrequencyTable.java
// public interface IFrequencyTable {
//
// public double estimatedStrength(ActionType a, int numBets, Round bettingRound);
//
// }
//
// Path: src/shaft/poker/game/table/IPlayerActionListener.java
// public interface IPlayerActionListener {
//
// public void gameAction(ITable table, IPlayerData plData, ActionType type, int amount);
//
// public void leave(ITable table, IPlayerData plData);
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/agent/handranges/weightedrange/frequencytable/PlayerSpecificFrequencyTable.java
import java.util.List;
import shaft.poker.game.table.IPlayerData;
import shaft.poker.agent.handranges.weightedrange.IFrequencyTable;
import shaft.poker.game.table.IPlayerActionListener;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange.frequencytable;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PlayerSpecificFrequencyTable implements IFrequencyTable, IPlayerActionListener, IGameEventListener {
// Dimensions: [BettingRound][LastAction][NumBets][Fold/Call/Bet]
private int[][][][] _freqs;
IFrequencyTable _defaultFreqs;
private String _playerId;
private static final int MINIMUM_DATA = 20;
private ActionType _lastAction;
|
public PlayerSpecificFrequencyTable(String playerId, ITable table) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/weightedrange/frequencytable/PlayerSpecificFrequencyTable.java
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/agent/handranges/weightedrange/IFrequencyTable.java
// public interface IFrequencyTable {
//
// public double estimatedStrength(ActionType a, int numBets, Round bettingRound);
//
// }
//
// Path: src/shaft/poker/game/table/IPlayerActionListener.java
// public interface IPlayerActionListener {
//
// public void gameAction(ITable table, IPlayerData plData, ActionType type, int amount);
//
// public void leave(ITable table, IPlayerData plData);
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
|
import java.util.List;
import shaft.poker.game.table.IPlayerData;
import shaft.poker.agent.handranges.weightedrange.IFrequencyTable;
import shaft.poker.game.table.IPlayerActionListener;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
|
if (total > 0) {
actualFreq = (double) count / (double) total;
}
// Linearly interpolate with generic default frequency table if not enough data has been collected
if (total < MINIMUM_DATA) {
double defFreq = _defaultFreqs.estimatedStrength(a, numBets, bettingRound);
actualFreq = (actualFreq * (total / ((double) MINIMUM_DATA)))
+ (defFreq * ((MINIMUM_DATA - total) / ((double) MINIMUM_DATA)));
}
return actualFreq;
}
private void doIncrease(int numBets, Round r, ActionType a) {
if (numBets > 2) {
numBets = 2;
}
int lastIdx = ActionType.values().length;
if (_lastAction != null) {
lastIdx = _lastAction.ordinal();
}
_freqs[r.ordinal()][lastIdx][numBets][a.ordinal()]++;
_lastAction = a;
}
@Override
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/agent/handranges/weightedrange/IFrequencyTable.java
// public interface IFrequencyTable {
//
// public double estimatedStrength(ActionType a, int numBets, Round bettingRound);
//
// }
//
// Path: src/shaft/poker/game/table/IPlayerActionListener.java
// public interface IPlayerActionListener {
//
// public void gameAction(ITable table, IPlayerData plData, ActionType type, int amount);
//
// public void leave(ITable table, IPlayerData plData);
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
// Path: src/shaft/poker/agent/handranges/weightedrange/frequencytable/PlayerSpecificFrequencyTable.java
import java.util.List;
import shaft.poker.game.table.IPlayerData;
import shaft.poker.agent.handranges.weightedrange.IFrequencyTable;
import shaft.poker.game.table.IPlayerActionListener;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.*;
import shaft.poker.game.table.*;
if (total > 0) {
actualFreq = (double) count / (double) total;
}
// Linearly interpolate with generic default frequency table if not enough data has been collected
if (total < MINIMUM_DATA) {
double defFreq = _defaultFreqs.estimatedStrength(a, numBets, bettingRound);
actualFreq = (actualFreq * (total / ((double) MINIMUM_DATA)))
+ (defFreq * ((MINIMUM_DATA - total) / ((double) MINIMUM_DATA)));
}
return actualFreq;
}
private void doIncrease(int numBets, Round r, ActionType a) {
if (numBets > 2) {
numBets = 2;
}
int lastIdx = ActionType.values().length;
if (_lastAction != null) {
lastIdx = _lastAction.ordinal();
}
_freqs[r.ordinal()][lastIdx][numBets][a.ordinal()]++;
_lastAction = a;
}
@Override
|
public void gameAction(ITable table, IPlayerData plData, ActionType type, int amount) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
|
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PreflopHandGroups extends AHandEvaluator {
private static int[][] _handGroups = {
{1, 1, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5},
{2, 1, 2, 3, 4, 6, 7, 7, 7, 7, 7, 7, 7},
{3, 4, 1, 3, 4, 5, 7, 9, 9, 9, 9, 9, 9},
{4, 5, 5, 1, 3, 4, 6, 8, 9, 9, 9, 9, 9},
{6, 6, 6, 5, 2, 4, 5, 7, 9, 9, 9, 9, 9},
{8, 8, 8, 7, 7, 3, 4, 5, 8, 9, 9, 9, 9},
{9, 9, 9, 8, 8, 7, 4, 5, 6, 8, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
// Path: src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PreflopHandGroups extends AHandEvaluator {
private static int[][] _handGroups = {
{1, 1, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5},
{2, 1, 2, 3, 4, 6, 7, 7, 7, 7, 7, 7, 7},
{3, 4, 1, 3, 4, 5, 7, 9, 9, 9, 9, 9, 9},
{4, 5, 5, 1, 3, 4, 6, 8, 9, 9, 9, 9, 9},
{6, 6, 6, 5, 2, 4, 5, 7, 9, 9, 9, 9, 9},
{8, 8, 8, 7, 7, 3, 4, 5, 8, 9, 9, 9, 9},
{9, 9, 9, 8, 8, 7, 4, 5, 6, 8, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
|
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
|
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PreflopHandGroups extends AHandEvaluator {
private static int[][] _handGroups = {
{1, 1, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5},
{2, 1, 2, 3, 4, 6, 7, 7, 7, 7, 7, 7, 7},
{3, 4, 1, 3, 4, 5, 7, 9, 9, 9, 9, 9, 9},
{4, 5, 5, 1, 3, 4, 6, 8, 9, 9, 9, 9, 9},
{6, 6, 6, 5, 2, 4, 5, 7, 9, 9, 9, 9, 9},
{8, 8, 8, 7, 7, 3, 4, 5, 8, 9, 9, 9, 9},
{9, 9, 9, 8, 8, 7, 4, 5, 6, 8, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
// Path: src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class PreflopHandGroups extends AHandEvaluator {
private static int[][] _handGroups = {
{1, 1, 2, 2, 3, 5, 5, 5, 5, 5, 5, 5, 5},
{2, 1, 2, 3, 4, 6, 7, 7, 7, 7, 7, 7, 7},
{3, 4, 1, 3, 4, 5, 7, 9, 9, 9, 9, 9, 9},
{4, 5, 5, 1, 3, 4, 6, 8, 9, 9, 9, 9, 9},
{6, 6, 6, 5, 2, 4, 5, 7, 9, 9, 9, 9, 9},
{8, 8, 8, 7, 7, 3, 4, 5, 8, 9, 9, 9, 9},
{9, 9, 9, 8, 8, 7, 4, 5, 6, 8, 9, 9, 9},
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
|
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
|
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
|
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
Card c1 = holecards.get(0);
Card c2 = holecards.get(1);
if (c1.rank().ordinal() > c2.rank().ordinal()) {
Card tmp = c1;
c1 = c2;
c2 = tmp;
}
if (c1.suit() == c2.suit()) {
Card tmp = c1;
c1 = c2;
c2 = tmp;
}
|
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
// Path: src/shaft/poker/agent/handevaluators/PreflopHandGroups.java
import java.util.List;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
{9, 9, 9, 9, 9, 9, 8, 5, 5, 6, 8, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 8, 6, 7, 7, 9, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 8, 6, 6, 7, 9},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8},
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7}
};
private static int[] _groupCount = {
5, 5, 6, 8, 17, 10, 19, 15, 84
};
@Override
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
Card c1 = holecards.get(0);
Card c2 = holecards.get(1);
if (c1.rank().ordinal() > c2.rank().ordinal()) {
Card tmp = c1;
c1 = c2;
c2 = tmp;
}
if (c1.suit() == c2.suit()) {
Card tmp = c1;
c1 = c2;
c2 = tmp;
}
|
int group = _handGroups[Rank.values().length - c1.rank().ordinal() - 1][Rank.values().length - c2.rank().ordinal() - 1];
|
loopfz/Lucki
|
src/shaft/poker/game/components/Hand.java
|
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/IHand.java
// public interface IHand extends Comparable<IHand> {
//
// public enum HandType {
// HIGH_CARD,
// PAIR,
// TWO_PAIR,
// THREE_OF_A_KIND,
// STRAIGHT,
// FLUSH,
// FULL_HOUSE,
// FOUR_OF_A_KIND,
// STRAIGHT_FLUSH,
// ROYAL_FLUSH
// }
//
// public HandType type();
// public List<Card> cards();
// }
|
import java.util.ArrayList;
import java.util.List;
import shaft.poker.game.Card;
import shaft.poker.game.Card.*;
import shaft.poker.game.IHand;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.components;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class Hand implements IHand {
private HandType _type;
|
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/IHand.java
// public interface IHand extends Comparable<IHand> {
//
// public enum HandType {
// HIGH_CARD,
// PAIR,
// TWO_PAIR,
// THREE_OF_A_KIND,
// STRAIGHT,
// FLUSH,
// FULL_HOUSE,
// FOUR_OF_A_KIND,
// STRAIGHT_FLUSH,
// ROYAL_FLUSH
// }
//
// public HandType type();
// public List<Card> cards();
// }
// Path: src/shaft/poker/game/components/Hand.java
import java.util.ArrayList;
import java.util.List;
import shaft.poker.game.Card;
import shaft.poker.game.Card.*;
import shaft.poker.game.IHand;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.components;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class Hand implements IHand {
private HandType _type;
|
private List<Card> _cards;
|
loopfz/Lucki
|
src/shaft/poker/agent/handevaluators/CompoundHandEval.java
|
// Path: src/shaft/poker/agent/IHandEvaluator.java
// public interface IHandEvaluator {
// public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers);
//
// public double effectiveHandStrength();
// public double rawHandStrength();
// public double posPotential();
// public double negPotential();
// }
//
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
|
import java.util.List;
import shaft.poker.agent.IHandEvaluator;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompoundHandEval implements IHandEvaluator {
private IHandEvaluator _preflop;
private IHandEvaluator _postflop;
private IHandEvaluator _lastCall;
public CompoundHandEval(IHandEvaluator preflop, IHandEvaluator postflop) {
_preflop = preflop;
_postflop = postflop;
}
@Override
|
// Path: src/shaft/poker/agent/IHandEvaluator.java
// public interface IHandEvaluator {
// public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers);
//
// public double effectiveHandStrength();
// public double rawHandStrength();
// public double posPotential();
// public double negPotential();
// }
//
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
// Path: src/shaft/poker/agent/handevaluators/CompoundHandEval.java
import java.util.List;
import shaft.poker.agent.IHandEvaluator;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompoundHandEval implements IHandEvaluator {
private IHandEvaluator _preflop;
private IHandEvaluator _postflop;
private IHandEvaluator _lastCall;
public CompoundHandEval(IHandEvaluator preflop, IHandEvaluator postflop) {
_preflop = preflop;
_postflop = postflop;
}
@Override
|
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
|
loopfz/Lucki
|
src/shaft/poker/agent/handevaluators/CompoundHandEval.java
|
// Path: src/shaft/poker/agent/IHandEvaluator.java
// public interface IHandEvaluator {
// public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers);
//
// public double effectiveHandStrength();
// public double rawHandStrength();
// public double posPotential();
// public double negPotential();
// }
//
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
|
import java.util.List;
import shaft.poker.agent.IHandEvaluator;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompoundHandEval implements IHandEvaluator {
private IHandEvaluator _preflop;
private IHandEvaluator _postflop;
private IHandEvaluator _lastCall;
public CompoundHandEval(IHandEvaluator preflop, IHandEvaluator postflop) {
_preflop = preflop;
_postflop = postflop;
}
@Override
|
// Path: src/shaft/poker/agent/IHandEvaluator.java
// public interface IHandEvaluator {
// public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers);
//
// public double effectiveHandStrength();
// public double rawHandStrength();
// public double posPotential();
// public double negPotential();
// }
//
// Path: src/shaft/poker/agent/IHandRange.java
// public interface IHandRange {
// public double handWeight(Card c1, Card c2);
// }
//
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
// Path: src/shaft/poker/agent/handevaluators/CompoundHandEval.java
import java.util.List;
import shaft.poker.agent.IHandEvaluator;
import shaft.poker.agent.IHandRange;
import shaft.poker.game.Card;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handevaluators;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class CompoundHandEval implements IHandEvaluator {
private IHandEvaluator _preflop;
private IHandEvaluator _postflop;
private IHandEvaluator _lastCall;
public CompoundHandEval(IHandEvaluator preflop, IHandEvaluator postflop) {
_preflop = preflop;
_postflop = postflop;
}
@Override
|
public void compute(List<Card> holecards, List<Card> board, IHandRange range, int numPlayers) {
|
loopfz/Lucki
|
src/shaft/poker/game/Lucki.java
|
// Path: src/shaft/poker/factory/PokerFactory.java
// public class PokerFactory {
//
// private List<IPlayer> _players;
// private PokerTable _table;
//
// private List<CompositeFieldRange> _fieldRanges;
// private List<IPlayerRange> _playerRanges;
//
// private boolean _genericModel;
//
// private static String[] _agentNames = {
// "Boris",
// "Jeff",
// "John",
// "Clark",
// "Marcel",
// "Mary",
// "Anna",
// "Joan",
// "Batman"
// };
// private static int _nameCount = 0;
//
//
// public PokerFactory() {
// _players = new ArrayList<>(10);
// _fieldRanges = new ArrayList<>(10);
// _playerRanges = new ArrayList<>(10);
// }
//
// public void genericModel(boolean generic) {
// _genericModel = generic;
// }
//
// private IFrequencyTable buildFreqTable(String id) {
// if (_genericModel) {
// return new GenericFrequencyTable();
// }
// return new PlayerSpecificFrequencyTable(id, _table);
// }
//
// public ITable newLimitTable() {
// _table = new PokerTable(new LimitRules());
// return _table;
// }
//
// public void addHumanPlayer() {
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// addPlayer(new HumanPlayer(_table), compRange);
// }
//
// public IPlayer addGUIHumanPlayer() {
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// HumanPlayerGUI gui = new HumanPlayerGUI(_table);
// addPlayer(gui, compRange);
// return gui;
// }
//
// public void addSimpleAgent() {
// String id = _agentNames[_nameCount++];
// addAgent(new HeuristicPPotEval(), new SimpleStrategy(_table), id);
// }
//
// public IPlayer addBlankNeuralNetAgent() {
// String id = _agentNames[_nameCount++];
// return addAgent(new HeuristicPPotEval(), new NeuralNetStrategy(_table), id);
// }
//
// public IPlayer addTrainedNeuralNetAgent(String name) {
// PlayerAgent agent = addAgent(new HeuristicPPotEval(), new NeuralNetStrategy(_table), name);
// NeuralNetStrategy strat = (NeuralNetStrategy) agent.bettingStrategy();
// strat.networkFromFile(name);
// return agent;
// }
//
// private PlayerAgent addAgent(IHandEvaluator eval, IBettingStrategy strat, String id) {
//
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// PlayerAgent agent = new PlayerAgent(_table, id, new CompoundHandEval(new PreflopHandGroups(), eval), compRange, strat);
// addPlayer(agent, compRange);
// return agent;
// }
//
// private void addPlayer(IPlayer player, CompositeFieldRange compRange) {
// _table.addPlayer(player);
// for (IPlayerRange range : _playerRanges) {
// compRange.addRange(range);
// }
// IPlayerRange ownRange = new PlayerWTRange(player.id(), new WeightTable(_table), buildFreqTable(player.id()),
// new CompoundHandEval(new PreflopHandGroups(), new HeuristicPPotEval()), compRange, _table);
// for (CompositeFieldRange fieldRange : _fieldRanges) {
// fieldRange.addRange(ownRange);
// }
// _fieldRanges.add(compRange);
// _playerRanges.add(ownRange);
// }
//
//
//
// public static IDeck buildDeck() {
// return new CardDeck();
// }
//
// public static IHand buildHand(List<Card> holeCards, List<Card> board) {
// return new Hand(holeCards, board);
// }
// }
|
import javax.swing.JFrame;
import shaft.poker.factory.PokerFactory;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class Lucki {
public static void main(String[] args) {
|
// Path: src/shaft/poker/factory/PokerFactory.java
// public class PokerFactory {
//
// private List<IPlayer> _players;
// private PokerTable _table;
//
// private List<CompositeFieldRange> _fieldRanges;
// private List<IPlayerRange> _playerRanges;
//
// private boolean _genericModel;
//
// private static String[] _agentNames = {
// "Boris",
// "Jeff",
// "John",
// "Clark",
// "Marcel",
// "Mary",
// "Anna",
// "Joan",
// "Batman"
// };
// private static int _nameCount = 0;
//
//
// public PokerFactory() {
// _players = new ArrayList<>(10);
// _fieldRanges = new ArrayList<>(10);
// _playerRanges = new ArrayList<>(10);
// }
//
// public void genericModel(boolean generic) {
// _genericModel = generic;
// }
//
// private IFrequencyTable buildFreqTable(String id) {
// if (_genericModel) {
// return new GenericFrequencyTable();
// }
// return new PlayerSpecificFrequencyTable(id, _table);
// }
//
// public ITable newLimitTable() {
// _table = new PokerTable(new LimitRules());
// return _table;
// }
//
// public void addHumanPlayer() {
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// addPlayer(new HumanPlayer(_table), compRange);
// }
//
// public IPlayer addGUIHumanPlayer() {
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// HumanPlayerGUI gui = new HumanPlayerGUI(_table);
// addPlayer(gui, compRange);
// return gui;
// }
//
// public void addSimpleAgent() {
// String id = _agentNames[_nameCount++];
// addAgent(new HeuristicPPotEval(), new SimpleStrategy(_table), id);
// }
//
// public IPlayer addBlankNeuralNetAgent() {
// String id = _agentNames[_nameCount++];
// return addAgent(new HeuristicPPotEval(), new NeuralNetStrategy(_table), id);
// }
//
// public IPlayer addTrainedNeuralNetAgent(String name) {
// PlayerAgent agent = addAgent(new HeuristicPPotEval(), new NeuralNetStrategy(_table), name);
// NeuralNetStrategy strat = (NeuralNetStrategy) agent.bettingStrategy();
// strat.networkFromFile(name);
// return agent;
// }
//
// private PlayerAgent addAgent(IHandEvaluator eval, IBettingStrategy strat, String id) {
//
// CompositeFieldRange compRange = new CompositeFieldRange(_table, new WeightTable(_table));
// PlayerAgent agent = new PlayerAgent(_table, id, new CompoundHandEval(new PreflopHandGroups(), eval), compRange, strat);
// addPlayer(agent, compRange);
// return agent;
// }
//
// private void addPlayer(IPlayer player, CompositeFieldRange compRange) {
// _table.addPlayer(player);
// for (IPlayerRange range : _playerRanges) {
// compRange.addRange(range);
// }
// IPlayerRange ownRange = new PlayerWTRange(player.id(), new WeightTable(_table), buildFreqTable(player.id()),
// new CompoundHandEval(new PreflopHandGroups(), new HeuristicPPotEval()), compRange, _table);
// for (CompositeFieldRange fieldRange : _fieldRanges) {
// fieldRange.addRange(ownRange);
// }
// _fieldRanges.add(compRange);
// _playerRanges.add(ownRange);
// }
//
//
//
// public static IDeck buildDeck() {
// return new CardDeck();
// }
//
// public static IHand buildHand(List<Card> holeCards, List<Card> board) {
// return new Hand(holeCards, board);
// }
// }
// Path: src/shaft/poker/game/Lucki.java
import javax.swing.JFrame;
import shaft.poker.factory.PokerFactory;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public class Lucki {
public static void main(String[] args) {
|
PokerFactory factory = new PokerFactory();
|
loopfz/Lucki
|
src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
|
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
// Path: src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
|
public void setContext(ITable table, IPlayerData plData) {
|
loopfz/Lucki
|
src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
|
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
public void setContext(ITable table, IPlayerData plData) {
_toCall = plData.amountToCall();
_potSize = table.potSize();
_sBlind = table.smallBlind();
_bBlind = table.bigBlind();
_plStack = plData.stack();
}
@Override
public int minRaise() {
return _bBlind;
}
@Override
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
// Path: src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
public void setContext(ITable table, IPlayerData plData) {
_toCall = plData.amountToCall();
_potSize = table.potSize();
_sBlind = table.smallBlind();
_bBlind = table.bigBlind();
_plStack = plData.stack();
}
@Override
public int minRaise() {
return _bBlind;
}
@Override
|
public IAction makeSBlind() {
|
loopfz/Lucki
|
src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
|
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
public void setContext(ITable table, IPlayerData plData) {
_toCall = plData.amountToCall();
_potSize = table.potSize();
_sBlind = table.smallBlind();
_bBlind = table.bigBlind();
_plStack = plData.stack();
}
@Override
public int minRaise() {
return _bBlind;
}
@Override
public IAction makeSBlind() {
int amount = _sBlind;
if (amount > _plStack) {
amount = _plStack;
}
|
// Path: src/shaft/poker/game/IAction.java
// public interface IAction {
//
// public ActionType type();
//
// public int amount();
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// public interface ITable {
//
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
//
// enum Round {
// PREFLOP,
// FLOP,
// TURN,
// RIVER
// }
//
// public void runGame(int hands, int stackSize, int sBlind, int bBlind);
//
// public int numberBets();
// public int maxBets();
// public int numberCallers();
// public Round round();
// public int potSize();
//
// public int numberPlayers();
// public int numberActivePlayers();
// public int numberPlayersToAct();
//
// public int smallBlind();
// public int bigBlind();
//
// public List<Card> board();
//
// public String playerSmallBlind();
// public String playerBigBlind();
// public String playerDealer();
//
// public void registerListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerPriorityListenerForPlayer(String id, IPlayerActionListener listener);
// public void registerListenAllPlayerEvents(IPlayerActionListener listener);
// public void registerEventListener(IGameEventListener listener);
//
// }
//
// Path: src/shaft/poker/game/ITable.java
// enum ActionType {
// FOLD,
// CALL,
// BET
// }
// Path: src/shaft/poker/game/table/actionbuilder/AActionBuilder.java
import shaft.poker.game.IAction;
import shaft.poker.game.ITable;
import shaft.poker.game.ITable.ActionType;
import shaft.poker.game.table.*;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game.table.actionbuilder;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public abstract class AActionBuilder implements IActionBuilder {
protected int _toCall;
protected int _sBlind;
protected int _bBlind;
protected int _potSize;
protected int _plStack;
@Override
public void setContext(ITable table, IPlayerData plData) {
_toCall = plData.amountToCall();
_potSize = table.potSize();
_sBlind = table.smallBlind();
_bBlind = table.bigBlind();
_plStack = plData.stack();
}
@Override
public int minRaise() {
return _bBlind;
}
@Override
public IAction makeSBlind() {
int amount = _sBlind;
if (amount > _plStack) {
amount = _plStack;
}
|
return new GameAction(ActionType.BET, amount);
|
loopfz/Lucki
|
src/shaft/poker/agent/handranges/weightedrange/IWeightTable.java
|
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
|
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IWeightTable {
public double getWeight(Card c1, Card c2);
public void suspendSetWeight(Card c1, Card c2, double weight);
public void setWeight(Card c1, Card c2, double weight);
|
// Path: src/shaft/poker/game/Card.java
// public class Card implements Comparable<Card> {
//
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
//
// public enum Suit {
// CLUBS,
// SPADES,
// HEARTS,
// DIAMONDS
// }
//
// private final Rank _rank;
// private final Suit _suit;
// private static final List<Card> _values = new ArrayList<Card>(Rank.values().length * Suit.values().length) {
// {
// for (Suit suit : Suit.values()) {
// for (Rank rank : Rank.values()) {
// add(new Card(rank, suit));
// }
// }
// }
// };
//
// public Card(Rank rank, Suit suit) {
// _rank = rank;
// _suit = suit;
// }
//
// @Override
// public String toString() {
// return _rank.toString() + " of " + _suit.toString();
// }
//
// public Rank rank() {
// return _rank;
// }
//
// public Suit suit() {
// return _suit;
// }
//
// public static List<Card> values() {
// return _values;
// }
//
// @Override
// public int compareTo(Card o) {
// if (_rank.ordinal() > o._rank.ordinal()) {
// return 1;
// }
// else if (_rank.ordinal() < o._rank.ordinal()) {
// return -1;
// }
// return 0;
// }
//
// }
//
// Path: src/shaft/poker/game/Card.java
// public enum Rank {
// DEUCE,
// THREE,
// FOUR,
// FIVE,
// SIX,
// SEVEN,
// EIGHT,
// NINE,
// TEN,
// JACK,
// QUEEN,
// KING,
// ACE
// }
// Path: src/shaft/poker/agent/handranges/weightedrange/IWeightTable.java
import shaft.poker.game.Card;
import shaft.poker.game.Card.Rank;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.agent.handranges.weightedrange;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IWeightTable {
public double getWeight(Card c1, Card c2);
public void suspendSetWeight(Card c1, Card c2, double weight);
public void setWeight(Card c1, Card c2, double weight);
|
public void setWeight(Rank r1, Rank r2, double weight);
|
loopfz/Lucki
|
src/shaft/poker/game/IPlayer.java
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/game/table/IActionBuilder.java
// public interface IActionBuilder {
//
// public void setContext(ITable table, IPlayerData plData);
//
// public int minRaise();
// public int maxRaise();
//
// IAction makeSBlind();
// IAction makeBBlind();
//
// IAction makeFold();
// IAction makeCall();
// IAction makeRaise(int amount);
// }
|
import shaft.poker.game.table.IPlayerData;
import java.util.List;
import shaft.poker.game.table.IActionBuilder;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IPlayer {
public String id();
public void dealCard(Card c);
public List<Card> holeCards();
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/game/table/IActionBuilder.java
// public interface IActionBuilder {
//
// public void setContext(ITable table, IPlayerData plData);
//
// public int minRaise();
// public int maxRaise();
//
// IAction makeSBlind();
// IAction makeBBlind();
//
// IAction makeFold();
// IAction makeCall();
// IAction makeRaise(int amount);
// }
// Path: src/shaft/poker/game/IPlayer.java
import shaft.poker.game.table.IPlayerData;
import java.util.List;
import shaft.poker.game.table.IActionBuilder;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IPlayer {
public String id();
public void dealCard(Card c);
public List<Card> holeCards();
|
public IAction action(ITable table, IPlayerData plData, IActionBuilder plContext);
|
loopfz/Lucki
|
src/shaft/poker/game/IPlayer.java
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/game/table/IActionBuilder.java
// public interface IActionBuilder {
//
// public void setContext(ITable table, IPlayerData plData);
//
// public int minRaise();
// public int maxRaise();
//
// IAction makeSBlind();
// IAction makeBBlind();
//
// IAction makeFold();
// IAction makeCall();
// IAction makeRaise(int amount);
// }
|
import shaft.poker.game.table.IPlayerData;
import java.util.List;
import shaft.poker.game.table.IActionBuilder;
|
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IPlayer {
public String id();
public void dealCard(Card c);
public List<Card> holeCards();
|
// Path: src/shaft/poker/game/table/IPlayerData.java
// public interface IPlayerData {
//
// public int amountToCall();
// public int betsToCall();
// public double potOdds(int potSize);
// public int moneyInPotForRound();
// public int totalMoneyInPot();
// public int stack();
// public int position();
// public String id();
// }
//
// Path: src/shaft/poker/game/table/IActionBuilder.java
// public interface IActionBuilder {
//
// public void setContext(ITable table, IPlayerData plData);
//
// public int minRaise();
// public int maxRaise();
//
// IAction makeSBlind();
// IAction makeBBlind();
//
// IAction makeFold();
// IAction makeCall();
// IAction makeRaise(int amount);
// }
// Path: src/shaft/poker/game/IPlayer.java
import shaft.poker.game.table.IPlayerData;
import java.util.List;
import shaft.poker.game.table.IActionBuilder;
/*
* The MIT License
*
* Copyright 2013 Thomas Schaffer <[email protected]>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package shaft.poker.game;
/**
*
* @author Thomas Schaffer <[email protected]>
*/
public interface IPlayer {
public String id();
public void dealCard(Card c);
public List<Card> holeCards();
|
public IAction action(ITable table, IPlayerData plData, IActionBuilder plContext);
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/controller/ResourceController.java
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
//
// private String name;
//
// private boolean isFile;
//
// public Resource(final String name, final boolean isFile) {
// this.name = name;
// this.isFile = isFile;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public boolean isFile() {
// return this.isFile;
// }
//
// public void setFile(final boolean isFile) {
// this.isFile = isFile;
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
//
// /** The dao. */
// @Autowired
// private ProjectRepository dao;
//
// @Autowired
// private GlobalProperties prop;
//
// /**
// * Creates the resource.
// *
// * @param projectId the project id
// * @param name the name
// * @param content the content
// * @throws IOException Signals that an I/O exception has occurred.
// */
// public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// Files.createFile(path);
// final FileWriter fileWriter = new FileWriter(path.toFile());
// fileWriter.write(content);
// fileWriter.flush();
// fileWriter.close();
// } else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// Files.createDirectory(path);
// }
// LOG.debug("Create {}.", path);
// }
//
// public List<Resource> findAllResources(final String projectId, final String subpath) {
// List<Resource> result = new ArrayList<>();
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// if (project != null) {
// try {
// result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// } catch (final IOException e) {
// LOG.error("Unable to get resources.", e);
// }
// }
// return result;
// }
//
// public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// final byte[] bytes = Files.readAllBytes(path);
// return new String(bytes);
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;
|
package com.glitterlabs.terraformui.controller;
@RestController
public class ResourceController {
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
//
// private String name;
//
// private boolean isFile;
//
// public Resource(final String name, final boolean isFile) {
// this.name = name;
// this.isFile = isFile;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public boolean isFile() {
// return this.isFile;
// }
//
// public void setFile(final boolean isFile) {
// this.isFile = isFile;
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
//
// /** The dao. */
// @Autowired
// private ProjectRepository dao;
//
// @Autowired
// private GlobalProperties prop;
//
// /**
// * Creates the resource.
// *
// * @param projectId the project id
// * @param name the name
// * @param content the content
// * @throws IOException Signals that an I/O exception has occurred.
// */
// public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// Files.createFile(path);
// final FileWriter fileWriter = new FileWriter(path.toFile());
// fileWriter.write(content);
// fileWriter.flush();
// fileWriter.close();
// } else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// Files.createDirectory(path);
// }
// LOG.debug("Create {}.", path);
// }
//
// public List<Resource> findAllResources(final String projectId, final String subpath) {
// List<Resource> result = new ArrayList<>();
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// if (project != null) {
// try {
// result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// } catch (final IOException e) {
// LOG.error("Unable to get resources.", e);
// }
// }
// return result;
// }
//
// public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// final byte[] bytes = Files.readAllBytes(path);
// return new String(bytes);
// }
//
// }
// Path: src/main/java/com/glitterlabs/terraformui/controller/ResourceController.java
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;
package com.glitterlabs.terraformui.controller;
@RestController
public class ResourceController {
|
private ResourceService resourceService;
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/controller/ResourceController.java
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
//
// private String name;
//
// private boolean isFile;
//
// public Resource(final String name, final boolean isFile) {
// this.name = name;
// this.isFile = isFile;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public boolean isFile() {
// return this.isFile;
// }
//
// public void setFile(final boolean isFile) {
// this.isFile = isFile;
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
//
// /** The dao. */
// @Autowired
// private ProjectRepository dao;
//
// @Autowired
// private GlobalProperties prop;
//
// /**
// * Creates the resource.
// *
// * @param projectId the project id
// * @param name the name
// * @param content the content
// * @throws IOException Signals that an I/O exception has occurred.
// */
// public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// Files.createFile(path);
// final FileWriter fileWriter = new FileWriter(path.toFile());
// fileWriter.write(content);
// fileWriter.flush();
// fileWriter.close();
// } else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// Files.createDirectory(path);
// }
// LOG.debug("Create {}.", path);
// }
//
// public List<Resource> findAllResources(final String projectId, final String subpath) {
// List<Resource> result = new ArrayList<>();
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// if (project != null) {
// try {
// result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// } catch (final IOException e) {
// LOG.error("Unable to get resources.", e);
// }
// }
// return result;
// }
//
// public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// final byte[] bytes = Files.readAllBytes(path);
// return new String(bytes);
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;
|
package com.glitterlabs.terraformui.controller;
@RestController
public class ResourceController {
private ResourceService resourceService;
@Autowired
public void setProjectService(final ResourceService resourceService) {
this.resourceService = resourceService;
}
@GetMapping("/project/{projectId}/resources/**")
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Resource.java
// public class Resource {
//
// private String name;
//
// private boolean isFile;
//
// public Resource(final String name, final boolean isFile) {
// this.name = name;
// this.isFile = isFile;
// }
//
// public String getName() {
// return this.name;
// }
//
// public void setName(final String name) {
// this.name = name;
// }
//
// public boolean isFile() {
// return this.isFile;
// }
//
// public void setFile(final boolean isFile) {
// this.isFile = isFile;
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/ResourceService.java
// @Service
// public class ResourceService {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceService.class);
//
// /** The dao. */
// @Autowired
// private ProjectRepository dao;
//
// @Autowired
// private GlobalProperties prop;
//
// /**
// * Creates the resource.
// *
// * @param projectId the project id
// * @param name the name
// * @param content the content
// * @throws IOException Signals that an I/O exception has occurred.
// */
// public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
// if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
// Files.createFile(path);
// final FileWriter fileWriter = new FileWriter(path.toFile());
// fileWriter.write(content);
// fileWriter.flush();
// fileWriter.close();
// } else if (StringUtils.equalsIgnoreCase(resourceType, "directory")) {
// Files.createDirectory(path);
// }
// LOG.debug("Create {}.", path);
// }
//
// public List<Resource> findAllResources(final String projectId, final String subpath) {
// List<Resource> result = new ArrayList<>();
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// if (project != null) {
// try {
// result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
// } catch (final IOException e) {
// LOG.error("Unable to get resources.", e);
// }
// }
// return result;
// }
//
// public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
// final Project project = this.dao.findOne(Long.valueOf(projectId));
// final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
// final byte[] bytes = Files.readAllBytes(path);
// return new String(bytes);
// }
//
// }
// Path: src/main/java/com/glitterlabs/terraformui/controller/ResourceController.java
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Resource;
import com.glitterlabs.terraformui.service.ResourceService;
package com.glitterlabs.terraformui.controller;
@RestController
public class ResourceController {
private ResourceService resourceService;
@Autowired
public void setProjectService(final ResourceService resourceService) {
this.resourceService = resourceService;
}
@GetMapping("/project/{projectId}/resources/**")
|
public ResponseEntity<List<Resource>> resources(@PathVariable final String projectId, final HttpServletRequest request) {
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/service/CloudService.java
|
// Path: src/main/java/com/glitterlabs/terraformui/dao/CloudRepository.java
// public interface CloudRepository extends CrudRepository<Cloud, Long> {
// @Cacheable("clouds")
// Cloud findByName(String name);
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glitterlabs.terraformui.dao.CloudRepository;
import com.glitterlabs.terraformui.model.Cloud;
|
package com.glitterlabs.terraformui.service;
@Service
public class CloudService {
@Autowired
|
// Path: src/main/java/com/glitterlabs/terraformui/dao/CloudRepository.java
// public interface CloudRepository extends CrudRepository<Cloud, Long> {
// @Cacheable("clouds")
// Cloud findByName(String name);
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glitterlabs.terraformui.dao.CloudRepository;
import com.glitterlabs.terraformui.model.Cloud;
package com.glitterlabs.terraformui.service;
@Service
public class CloudService {
@Autowired
|
private CloudRepository dao;
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/service/CloudService.java
|
// Path: src/main/java/com/glitterlabs/terraformui/dao/CloudRepository.java
// public interface CloudRepository extends CrudRepository<Cloud, Long> {
// @Cacheable("clouds")
// Cloud findByName(String name);
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glitterlabs.terraformui.dao.CloudRepository;
import com.glitterlabs.terraformui.model.Cloud;
|
package com.glitterlabs.terraformui.service;
@Service
public class CloudService {
@Autowired
private CloudRepository dao;
|
// Path: src/main/java/com/glitterlabs/terraformui/dao/CloudRepository.java
// public interface CloudRepository extends CrudRepository<Cloud, Long> {
// @Cacheable("clouds")
// Cloud findByName(String name);
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glitterlabs.terraformui.dao.CloudRepository;
import com.glitterlabs.terraformui.model.Cloud;
package com.glitterlabs.terraformui.service;
@Service
public class CloudService {
@Autowired
private CloudRepository dao;
|
public List<Cloud> findAllClouds() {
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/controller/CloudController.java
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
// @Service
// public class CloudService {
//
// @Autowired
// private CloudRepository dao;
//
// public List<Cloud> findAllClouds() {
// final List<Cloud> result = new ArrayList<>();
// this.dao.findAll().iterator().forEachRemaining(cloud -> result.add(cloud));
// return result;
// }
//
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Cloud;
import com.glitterlabs.terraformui.service.CloudService;
|
package com.glitterlabs.terraformui.controller;
@RestController
public class CloudController {
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
// @Service
// public class CloudService {
//
// @Autowired
// private CloudRepository dao;
//
// public List<Cloud> findAllClouds() {
// final List<Cloud> result = new ArrayList<>();
// this.dao.findAll().iterator().forEachRemaining(cloud -> result.add(cloud));
// return result;
// }
//
// }
// Path: src/main/java/com/glitterlabs/terraformui/controller/CloudController.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Cloud;
import com.glitterlabs.terraformui.service.CloudService;
package com.glitterlabs.terraformui.controller;
@RestController
public class CloudController {
|
private CloudService cloudService;
|
mohnishbasha/terraform-ui
|
src/main/java/com/glitterlabs/terraformui/controller/CloudController.java
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
// @Service
// public class CloudService {
//
// @Autowired
// private CloudRepository dao;
//
// public List<Cloud> findAllClouds() {
// final List<Cloud> result = new ArrayList<>();
// this.dao.findAll().iterator().forEachRemaining(cloud -> result.add(cloud));
// return result;
// }
//
// }
|
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Cloud;
import com.glitterlabs.terraformui.service.CloudService;
|
package com.glitterlabs.terraformui.controller;
@RestController
public class CloudController {
private CloudService cloudService;
@Autowired
public void setCloudService(final CloudService cloudService) {
this.cloudService = cloudService;
}
@GetMapping("/clouds")
|
// Path: src/main/java/com/glitterlabs/terraformui/model/Cloud.java
// @Entity
// public class Cloud {
//
// /** The id. */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "CLOUD_ID")
// private Long id;
//
// /** The name. */
// @Column(name = "NAME", nullable = false)
// private String name;
//
// /** The date. */
// @Column(name = "CREATED_DATE", nullable = false)
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// /**
// * Instantiates a new cloud.
// */
// public Cloud() {
// // JPA
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param id the id
// */
// public Cloud(final Long id) {
// this.id = id;
// }
//
// /**
// * Instantiates a new cloud.
// *
// * @param name the name
// */
// public Cloud(final String name) {
// this.name = name;
// }
//
// /**
// * Gets the id.
// *
// * @return the id
// */
// public Long getId() {
// return this.id;
// }
//
// /**
// * Sets the id.
// *
// * @param id the new id
// */
// public void setId(final Long id) {
// this.id = id;
// }
//
// /**
// * Gets the name.
// *
// * @return the name
// */
// public String getName() {
// return this.name;
// }
//
// /**
// * Sets the name.
// *
// * @param name the new name
// */
// public void setName(final String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Cloud [id=" + this.id + ", name=" + this.name + ", date=" + this.date + "]";
// }
// }
//
// Path: src/main/java/com/glitterlabs/terraformui/service/CloudService.java
// @Service
// public class CloudService {
//
// @Autowired
// private CloudRepository dao;
//
// public List<Cloud> findAllClouds() {
// final List<Cloud> result = new ArrayList<>();
// this.dao.findAll().iterator().forEachRemaining(cloud -> result.add(cloud));
// return result;
// }
//
// }
// Path: src/main/java/com/glitterlabs/terraformui/controller/CloudController.java
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glitterlabs.terraformui.model.Cloud;
import com.glitterlabs.terraformui.service.CloudService;
package com.glitterlabs.terraformui.controller;
@RestController
public class CloudController {
private CloudService cloudService;
@Autowired
public void setCloudService(final CloudService cloudService) {
this.cloudService = cloudService;
}
@GetMapping("/clouds")
|
public ResponseEntity<List<Cloud>> dashboard() {
|
sbt/junit-interface
|
src/main/java/com/novocode/junit/RunSettings.java
|
// Path: src/main/java/com/novocode/junit/Ansi.java
// public static String c(String s, String colorSequence)
// {
// if(colorSequence == null) return s;
// else return colorSequence + s + NORMAL;
// }
|
import static com.novocode.junit.Ansi.ENAME1;
import static com.novocode.junit.Ansi.ENAME2;
import static com.novocode.junit.Ansi.ENAME3;
import static com.novocode.junit.Ansi.NNAME1;
import static com.novocode.junit.Ansi.NNAME2;
import static com.novocode.junit.Ansi.NNAME3;
import static com.novocode.junit.Ansi.c;
import java.lang.reflect.Method;
import java.util.*;
import org.junit.runner.Description;
|
Method m = cl.getMethod("decode", String.class);
String decoded = (String)m.invoke(null, name);
return decoded == null ? name : decoded;
} catch(Throwable t) {
//System.err.println("Error decoding Scala name:");
//t.printStackTrace(System.err);
return name;
}
}
String buildInfoName(Description desc) {
return buildColoredName(desc, NNAME1, NNAME2, NNAME3);
}
String buildErrorName(Description desc) {
return buildColoredName(desc, ENAME1, ENAME2, ENAME3);
}
String buildPlainName(Description desc) {
return buildColoredName(desc, null, null, null);
}
String buildColoredMessage(Throwable t, String c1) {
if(t == null) return "null";
if(!logExceptionClass || !logAssert && t instanceof AssertionError) return t.getMessage();
StringBuilder b = new StringBuilder();
String cn = decodeName(t.getClass().getName());
int pos1 = cn.indexOf('$');
int pos2 = pos1 == -1 ? cn.lastIndexOf('.') : cn.lastIndexOf('.', pos1);
|
// Path: src/main/java/com/novocode/junit/Ansi.java
// public static String c(String s, String colorSequence)
// {
// if(colorSequence == null) return s;
// else return colorSequence + s + NORMAL;
// }
// Path: src/main/java/com/novocode/junit/RunSettings.java
import static com.novocode.junit.Ansi.ENAME1;
import static com.novocode.junit.Ansi.ENAME2;
import static com.novocode.junit.Ansi.ENAME3;
import static com.novocode.junit.Ansi.NNAME1;
import static com.novocode.junit.Ansi.NNAME2;
import static com.novocode.junit.Ansi.NNAME3;
import static com.novocode.junit.Ansi.c;
import java.lang.reflect.Method;
import java.util.*;
import org.junit.runner.Description;
Method m = cl.getMethod("decode", String.class);
String decoded = (String)m.invoke(null, name);
return decoded == null ? name : decoded;
} catch(Throwable t) {
//System.err.println("Error decoding Scala name:");
//t.printStackTrace(System.err);
return name;
}
}
String buildInfoName(Description desc) {
return buildColoredName(desc, NNAME1, NNAME2, NNAME3);
}
String buildErrorName(Description desc) {
return buildColoredName(desc, ENAME1, ENAME2, ENAME3);
}
String buildPlainName(Description desc) {
return buildColoredName(desc, null, null, null);
}
String buildColoredMessage(Throwable t, String c1) {
if(t == null) return "null";
if(!logExceptionClass || !logAssert && t instanceof AssertionError) return t.getMessage();
StringBuilder b = new StringBuilder();
String cn = decodeName(t.getClass().getName());
int pos1 = cn.indexOf('$');
int pos2 = pos1 == -1 ? cn.lastIndexOf('.') : cn.lastIndexOf('.', pos1);
|
if(pos2 == -1) b.append(c(cn, c1));
|
sbt/junit-interface
|
src/main/java/com/novocode/junit/EventDispatcher.java
|
// Path: src/main/java/com/novocode/junit/Ansi.java
// public class Ansi {
// // Standard ANSI sequences
// private static final String NORMAL = "\u001B[0m";
// private static final String HIGH_INTENSITY = "\u001B[1m";
// private static final String LOW_INTESITY = "\u001B[2m";
// private static final String BLACK = "\u001B[30m";
// private static final String RED = "\u001B[31m";
// private static final String GREEN = "\u001B[32m";
// private static final String YELLOW = "\u001B[33m";
// private static final String BLUE = "\u001B[34m";
// private static final String MAGENTA = "\u001B[35m";
// private static final String CYAN = "\u001B[36m";
// private static final String WHITE = "\u001B[37m";
//
// public static String c(String s, String colorSequence)
// {
// if(colorSequence == null) return s;
// else return colorSequence + s + NORMAL;
// }
//
// public static String filterAnsi(String s)
// {
// if(s == null) return null;
// StringBuilder b = new StringBuilder(s.length());
// int len = s.length();
// for(int i=0; i<len; i++)
// {
// char c = s.charAt(i);
// if(c == '\u001B')
// {
// do { i++; } while(s.charAt(i) != 'm');
// }
// else b.append(c);
// }
// return b.toString();
// }
//
// private Ansi() {}
//
// public static final String INFO = BLUE;
// public static final String ERRCOUNT = RED;
// public static final String IGNCOUNT = YELLOW;
// public static final String ERRMSG = RED;
// public static final String NNAME1 = YELLOW;
// public static final String NNAME2 = CYAN;
// public static final String NNAME3 = YELLOW;
// public static final String ENAME1 = YELLOW;
// public static final String ENAME2 = RED;
// public static final String ENAME3 = YELLOW;
// public static final String TESTFILE1 = MAGENTA;
// public static final String TESTFILE2 = YELLOW;
// }
|
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.io.IOException;
import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import sbt.testing.EventHandler;
import sbt.testing.Fingerprint;
import sbt.testing.Status;
import static com.novocode.junit.Ansi.*;
|
}
private Long elapsedTime(Description description) {
Long startTime = startTimes.get(settings.buildPlainName(description));
if( startTime == null ) {
return 0L;
} else {
return System.currentTimeMillis() - startTime;
}
}
@Override
public void testRunFinished(Result result)
{
debugOrInfo(c("Test run ", INFO)+taskInfo+c(" finished: ", INFO)+
c(result.getFailureCount()+" failed", result.getFailureCount() > 0 ? ERRCOUNT : INFO)+
c(", ", INFO)+
c(result.getIgnoreCount()+" ignored", result.getIgnoreCount() > 0 ? IGNCOUNT : INFO)+
c(", "+result.getRunCount()+" total, "+ result.getRunTime() / 1000.0 +"s", INFO), RunSettings.Verbosity.RUN_FINISHED);
runStatistics.addTime(result.getRunTime());
}
@Override
public void testRunStarted(Description description)
{
debugOrInfo(c("Test run ", INFO)+taskInfo+c(" started", INFO), RunSettings.Verbosity.STARTED);
}
void testExecutionFailed(String testName, Throwable err)
{
|
// Path: src/main/java/com/novocode/junit/Ansi.java
// public class Ansi {
// // Standard ANSI sequences
// private static final String NORMAL = "\u001B[0m";
// private static final String HIGH_INTENSITY = "\u001B[1m";
// private static final String LOW_INTESITY = "\u001B[2m";
// private static final String BLACK = "\u001B[30m";
// private static final String RED = "\u001B[31m";
// private static final String GREEN = "\u001B[32m";
// private static final String YELLOW = "\u001B[33m";
// private static final String BLUE = "\u001B[34m";
// private static final String MAGENTA = "\u001B[35m";
// private static final String CYAN = "\u001B[36m";
// private static final String WHITE = "\u001B[37m";
//
// public static String c(String s, String colorSequence)
// {
// if(colorSequence == null) return s;
// else return colorSequence + s + NORMAL;
// }
//
// public static String filterAnsi(String s)
// {
// if(s == null) return null;
// StringBuilder b = new StringBuilder(s.length());
// int len = s.length();
// for(int i=0; i<len; i++)
// {
// char c = s.charAt(i);
// if(c == '\u001B')
// {
// do { i++; } while(s.charAt(i) != 'm');
// }
// else b.append(c);
// }
// return b.toString();
// }
//
// private Ansi() {}
//
// public static final String INFO = BLUE;
// public static final String ERRCOUNT = RED;
// public static final String IGNCOUNT = YELLOW;
// public static final String ERRMSG = RED;
// public static final String NNAME1 = YELLOW;
// public static final String NNAME2 = CYAN;
// public static final String NNAME3 = YELLOW;
// public static final String ENAME1 = YELLOW;
// public static final String ENAME2 = RED;
// public static final String ENAME3 = YELLOW;
// public static final String TESTFILE1 = MAGENTA;
// public static final String TESTFILE2 = YELLOW;
// }
// Path: src/main/java/com/novocode/junit/EventDispatcher.java
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.io.IOException;
import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import sbt.testing.EventHandler;
import sbt.testing.Fingerprint;
import sbt.testing.Status;
import static com.novocode.junit.Ansi.*;
}
private Long elapsedTime(Description description) {
Long startTime = startTimes.get(settings.buildPlainName(description));
if( startTime == null ) {
return 0L;
} else {
return System.currentTimeMillis() - startTime;
}
}
@Override
public void testRunFinished(Result result)
{
debugOrInfo(c("Test run ", INFO)+taskInfo+c(" finished: ", INFO)+
c(result.getFailureCount()+" failed", result.getFailureCount() > 0 ? ERRCOUNT : INFO)+
c(", ", INFO)+
c(result.getIgnoreCount()+" ignored", result.getIgnoreCount() > 0 ? IGNCOUNT : INFO)+
c(", "+result.getRunCount()+" total, "+ result.getRunTime() / 1000.0 +"s", INFO), RunSettings.Verbosity.RUN_FINISHED);
runStatistics.addTime(result.getRunTime());
}
@Override
public void testRunStarted(Description description)
{
debugOrInfo(c("Test run ", INFO)+taskInfo+c(" started", INFO), RunSettings.Verbosity.STARTED);
}
void testExecutionFailed(String testName, Throwable err)
{
|
post(new Event(Ansi.c(testName, Ansi.ERRMSG), settings.buildErrorMessage(err), Status.Error, 0L, err) {
|
jprante/elasticsearch-helper
|
src/integration-test/java/suites/IngestTransportTestSuite.java
|
// Path: src/integration-test/java/org/xbib/elasticsearch/helper/client/ingest/IngestTransportDuplicateIDTest.java
// public class IngestTransportDuplicateIDTest extends NodeTestUtils {
//
// private final static ESLogger logger = ESLoggerFactory.getLogger(IngestTransportDuplicateIDTest.class.getSimpleName());
//
// private final static Long MAX_ACTIONS = 1000L;
//
// private final static Long NUM_ACTIONS = 12345L;
//
// @Test
// public void testDuplicateDocIDs() throws Exception {
// long numactions = NUM_ACTIONS;
// final IngestTransportClient client = ClientBuilder.builder()
// .put(getSettings())
// .put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS)
// .setMetric(new LongAdderIngestMetric())
// .toIngestTransportClient();
// try {
// client.newIndex("test");
// client.waitForCluster("GREEN", TimeValue.timeValueSeconds(30));
// for (int i = 0; i < NUM_ACTIONS; i++) {
// client.index("test", "test", randomString(1), "{ \"name\" : \"" + randomString(32) + "\"}");
// }
// client.flushIngest();
// logger.info("flushed, waiting for responses");
// client.waitForResponses(TimeValue.timeValueSeconds(30));
// logger.info("refreshing");
// client.refreshIndex("test");
// logger.info("searching");
// SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client.client(), SearchAction.INSTANCE)
// .setIndices("test")
// .setTypes("test")
// .setQuery(matchAllQuery());
// long hits = searchRequestBuilder.execute().actionGet().getHits().getTotalHits();
// logger.info("hits = {}", hits);
// assertTrue(hits < NUM_ACTIONS);
// } catch (NoNodeAvailableException e) {
// logger.warn("skipping, no node available");
// } catch (Throwable t) {
// logger.error("oops", t);
// } finally {
// logger.info("shutting down client");
// client.shutdown();
// assertEquals(numactions, client.getMetric().getSucceeded().getCount());
// if (client.hasThrowable()) {
// logger.error("error", client.getThrowable());
// }
// assertFalse(client.hasThrowable());
// logger.info("done");
// }
// }
// }
|
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportClientTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportDuplicateIDTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportReplicaTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportUpdateReplicaLevelTest;
|
package suites;
@RunWith(ListenerSuite.class)
@Suite.SuiteClasses({
IngestTransportClientTest.class,
|
// Path: src/integration-test/java/org/xbib/elasticsearch/helper/client/ingest/IngestTransportDuplicateIDTest.java
// public class IngestTransportDuplicateIDTest extends NodeTestUtils {
//
// private final static ESLogger logger = ESLoggerFactory.getLogger(IngestTransportDuplicateIDTest.class.getSimpleName());
//
// private final static Long MAX_ACTIONS = 1000L;
//
// private final static Long NUM_ACTIONS = 12345L;
//
// @Test
// public void testDuplicateDocIDs() throws Exception {
// long numactions = NUM_ACTIONS;
// final IngestTransportClient client = ClientBuilder.builder()
// .put(getSettings())
// .put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS)
// .setMetric(new LongAdderIngestMetric())
// .toIngestTransportClient();
// try {
// client.newIndex("test");
// client.waitForCluster("GREEN", TimeValue.timeValueSeconds(30));
// for (int i = 0; i < NUM_ACTIONS; i++) {
// client.index("test", "test", randomString(1), "{ \"name\" : \"" + randomString(32) + "\"}");
// }
// client.flushIngest();
// logger.info("flushed, waiting for responses");
// client.waitForResponses(TimeValue.timeValueSeconds(30));
// logger.info("refreshing");
// client.refreshIndex("test");
// logger.info("searching");
// SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(client.client(), SearchAction.INSTANCE)
// .setIndices("test")
// .setTypes("test")
// .setQuery(matchAllQuery());
// long hits = searchRequestBuilder.execute().actionGet().getHits().getTotalHits();
// logger.info("hits = {}", hits);
// assertTrue(hits < NUM_ACTIONS);
// } catch (NoNodeAvailableException e) {
// logger.warn("skipping, no node available");
// } catch (Throwable t) {
// logger.error("oops", t);
// } finally {
// logger.info("shutting down client");
// client.shutdown();
// assertEquals(numactions, client.getMetric().getSucceeded().getCount());
// if (client.hasThrowable()) {
// logger.error("error", client.getThrowable());
// }
// assertFalse(client.hasThrowable());
// logger.info("done");
// }
// }
// }
// Path: src/integration-test/java/suites/IngestTransportTestSuite.java
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportClientTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportDuplicateIDTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportReplicaTest;
import org.xbib.elasticsearch.helper.client.ingest.IngestTransportUpdateReplicaLevelTest;
package suites;
@RunWith(ListenerSuite.class)
@Suite.SuiteClasses({
IngestTransportClientTest.class,
|
IngestTransportDuplicateIDTest.class,
|
jprante/elasticsearch-helper
|
src/main/java/org/elasticsearch/action/admin/indices/create/HttpCreateIndexAction.java
|
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpAction.java
// public abstract class HttpAction<Request extends ActionRequest, Response extends ActionResponse> extends AbstractComponent {
//
// protected final String actionName;
// protected final ParseFieldMatcher parseFieldMatcher;
//
// protected HttpAction(Settings settings, String actionName) {
// super(settings);
// this.actionName = actionName;
// this.parseFieldMatcher = new ParseFieldMatcher(settings);
// }
//
// public final ActionFuture<Response> execute(HttpInvocationContext<Request,Response> httpInvocationContext, Request request) {
// PlainActionFuture<Response> future = newFuture();
// execute(httpInvocationContext, future);
// return future;
// }
//
// public final void execute(HttpInvocationContext<Request,Response> httpInvocationContext, ActionListener<Response> listener) {
// ActionRequestValidationException validationException = httpInvocationContext.getRequest().validate();
// if (validationException != null) {
// listener.onFailure(validationException);
// return;
// }
// httpInvocationContext.setListener(listener);
// httpInvocationContext.setMillis(System.currentTimeMillis());
// try {
// doExecute(httpInvocationContext);
// } catch(Throwable t) {
// logger.error("exception during http action execution", t);
// listener.onFailure(t);
// }
// }
//
// protected HttpRequest newGetRequest(URL url, String path) {
// return newGetRequest(url, path, null);
// }
//
// protected HttpRequest newGetRequest(URL url, String path, CharSequence content) {
// return newRequest(HttpMethod.GET, url, path, content);
// }
//
// protected HttpRequest newPostRequest(URL url, String path, CharSequence content) {
// return newRequest(HttpMethod.POST, url, path, content);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, CharSequence content) {
// return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content, CharsetUtil.UTF_8) : null);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, BytesReference content) {
// return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content.toBytes()) : null);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, ChannelBuffer buffer) {
// HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, path);
// request.headers().add(HttpHeaders.Names.HOST, url.getHost());
// request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
// request.headers().add(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
// if (buffer != null) {
// request.setContent(buffer);
// int length = request.getContent().readableBytes();
// request.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json");
// request.headers().add(HttpHeaders.Names.CONTENT_LENGTH, length);
// }
// return request;
// }
//
// protected void doExecute(final HttpInvocationContext<Request,Response> httpInvocationContext) {
// httpInvocationContext.getChannel().write(httpInvocationContext.getHttpRequest());
// }
//
// protected abstract HttpRequest createHttpRequest(URL base, Request request) throws IOException;
//
// protected abstract Response createResponse(HttpInvocationContext<Request,Response> httpInvocationContext) throws IOException;
//
// }
//
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpInvocationContext.java
// public class HttpInvocationContext<Request extends ActionRequest, Response extends ActionResponse> {
//
// private final HttpAction httpAction;
//
// private ActionListener<Response> listener;
//
// private final Request request;
//
// private final List<HttpChunk> chunks;
//
// private Channel channel;
//
// HttpRequest httpRequest;
//
// HttpResponse httpResponse;
//
// private long millis;
//
// HttpInvocationContext(HttpAction httpAction, ActionListener<Response> listener, List<HttpChunk> chunks, Request request) {
// this.httpAction = httpAction;
// this.listener = listener;
// this.chunks = chunks;
// this.request = request;
// }
//
// public Request getRequest() {
// return request;
// }
//
// public HttpAction getHttpAction() {
// return httpAction;
// }
//
// public void setListener(ActionListener<Response> listener) {
// this.listener = listener;
// }
//
// public ActionListener<Response> getListener() {
// return listener;
// }
//
// public void setChannel(Channel channel) {
// this.channel = channel;
// }
//
// public Channel getChannel() {
// return channel;
// }
//
// public HttpRequest getHttpRequest() {
// return httpRequest;
// }
//
// public HttpResponse getHttpResponse() {
// return httpResponse;
// }
//
// public void setMillis(long millis) {
// this.millis = millis;
// }
//
// }
|
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ChannelBufferBytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.xbib.elasticsearch.helper.client.http.HttpAction;
import org.xbib.elasticsearch.helper.client.http.HttpInvocationContext;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
|
package org.elasticsearch.action.admin.indices.create;
public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, CreateIndexResponse> {
public HttpCreateIndexAction(Settings settings) {
super(settings, CreateIndexAction.NAME);
}
@Override
protected HttpRequest createHttpRequest(URL url, CreateIndexRequest request) {
return newPostRequest(url, "/" + request.index(), null);
}
@Override
|
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpAction.java
// public abstract class HttpAction<Request extends ActionRequest, Response extends ActionResponse> extends AbstractComponent {
//
// protected final String actionName;
// protected final ParseFieldMatcher parseFieldMatcher;
//
// protected HttpAction(Settings settings, String actionName) {
// super(settings);
// this.actionName = actionName;
// this.parseFieldMatcher = new ParseFieldMatcher(settings);
// }
//
// public final ActionFuture<Response> execute(HttpInvocationContext<Request,Response> httpInvocationContext, Request request) {
// PlainActionFuture<Response> future = newFuture();
// execute(httpInvocationContext, future);
// return future;
// }
//
// public final void execute(HttpInvocationContext<Request,Response> httpInvocationContext, ActionListener<Response> listener) {
// ActionRequestValidationException validationException = httpInvocationContext.getRequest().validate();
// if (validationException != null) {
// listener.onFailure(validationException);
// return;
// }
// httpInvocationContext.setListener(listener);
// httpInvocationContext.setMillis(System.currentTimeMillis());
// try {
// doExecute(httpInvocationContext);
// } catch(Throwable t) {
// logger.error("exception during http action execution", t);
// listener.onFailure(t);
// }
// }
//
// protected HttpRequest newGetRequest(URL url, String path) {
// return newGetRequest(url, path, null);
// }
//
// protected HttpRequest newGetRequest(URL url, String path, CharSequence content) {
// return newRequest(HttpMethod.GET, url, path, content);
// }
//
// protected HttpRequest newPostRequest(URL url, String path, CharSequence content) {
// return newRequest(HttpMethod.POST, url, path, content);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, CharSequence content) {
// return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content, CharsetUtil.UTF_8) : null);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, BytesReference content) {
// return newRequest(method, url, path, content != null ? ChannelBuffers.copiedBuffer(content.toBytes()) : null);
// }
//
// protected HttpRequest newRequest(HttpMethod method, URL url, String path, ChannelBuffer buffer) {
// HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, path);
// request.headers().add(HttpHeaders.Names.HOST, url.getHost());
// request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
// request.headers().add(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);
// if (buffer != null) {
// request.setContent(buffer);
// int length = request.getContent().readableBytes();
// request.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json");
// request.headers().add(HttpHeaders.Names.CONTENT_LENGTH, length);
// }
// return request;
// }
//
// protected void doExecute(final HttpInvocationContext<Request,Response> httpInvocationContext) {
// httpInvocationContext.getChannel().write(httpInvocationContext.getHttpRequest());
// }
//
// protected abstract HttpRequest createHttpRequest(URL base, Request request) throws IOException;
//
// protected abstract Response createResponse(HttpInvocationContext<Request,Response> httpInvocationContext) throws IOException;
//
// }
//
// Path: src/main/java/org/xbib/elasticsearch/helper/client/http/HttpInvocationContext.java
// public class HttpInvocationContext<Request extends ActionRequest, Response extends ActionResponse> {
//
// private final HttpAction httpAction;
//
// private ActionListener<Response> listener;
//
// private final Request request;
//
// private final List<HttpChunk> chunks;
//
// private Channel channel;
//
// HttpRequest httpRequest;
//
// HttpResponse httpResponse;
//
// private long millis;
//
// HttpInvocationContext(HttpAction httpAction, ActionListener<Response> listener, List<HttpChunk> chunks, Request request) {
// this.httpAction = httpAction;
// this.listener = listener;
// this.chunks = chunks;
// this.request = request;
// }
//
// public Request getRequest() {
// return request;
// }
//
// public HttpAction getHttpAction() {
// return httpAction;
// }
//
// public void setListener(ActionListener<Response> listener) {
// this.listener = listener;
// }
//
// public ActionListener<Response> getListener() {
// return listener;
// }
//
// public void setChannel(Channel channel) {
// this.channel = channel;
// }
//
// public Channel getChannel() {
// return channel;
// }
//
// public HttpRequest getHttpRequest() {
// return httpRequest;
// }
//
// public HttpResponse getHttpResponse() {
// return httpResponse;
// }
//
// public void setMillis(long millis) {
// this.millis = millis;
// }
//
// }
// Path: src/main/java/org/elasticsearch/action/admin/indices/create/HttpCreateIndexAction.java
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ChannelBufferBytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.xbib.elasticsearch.helper.client.http.HttpAction;
import org.xbib.elasticsearch.helper.client.http.HttpInvocationContext;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
package org.elasticsearch.action.admin.indices.create;
public class HttpCreateIndexAction extends HttpAction<CreateIndexRequest, CreateIndexResponse> {
public HttpCreateIndexAction(Settings settings) {
super(settings, CreateIndexAction.NAME);
}
@Override
protected HttpRequest createHttpRequest(URL url, CreateIndexRequest request) {
return newPostRequest(url, "/" + request.index(), null);
}
@Override
|
protected CreateIndexResponse createResponse(HttpInvocationContext<CreateIndexRequest,CreateIndexResponse> httpInvocationContext) {
|
jprante/elasticsearch-helper
|
src/main/java/org/xbib/elasticsearch/helper/client/Search.java
|
// Path: src/main/java/org/xbib/elasticsearch/action/search/helper/BasicGetRequest.java
// public class BasicGetRequest {
//
// private final ESLogger logger = ESLoggerFactory.getLogger(BasicGetRequest.class.getName());
//
// private GetRequestBuilder getRequestBuilder;
//
// private String index;
//
// private String type;
//
// private String id;
//
// public BasicGetRequest newRequest(GetRequestBuilder getRequestBuilder) {
// this.getRequestBuilder = getRequestBuilder;
// return this;
// }
//
// public GetRequestBuilder getRequestBuilder() {
// return getRequestBuilder;
// }
//
// public BasicGetRequest index(String index) {
// if (index != null && !"*".equals(index)) {
// this.index = index;
// }
// return this;
// }
//
// public String index() {
// return index;
// }
//
// public BasicGetRequest type(String type) {
// if (type != null && !"*".equals(type)) {
// this.type = type;
// }
// return this;
// }
//
// public String type() {
// return type;
// }
//
// public BasicGetRequest id(String id) {
// this.id = id;
// return this;
// }
//
// public String id() {
// return id;
// }
//
// public BasicGetResponse execute() throws IOException {
// BasicGetResponse response = new BasicGetResponse();
// if (getRequestBuilder == null) {
// return response;
// }
// logger.info(" get request: {}/{}/{}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id());
// getRequestBuilder
// .setIndex(index)
// .setType(type)
// .setId(id);
// long t0 = System.currentTimeMillis();
// response.setResponse(getRequestBuilder.execute().actionGet());
// long t1 = System.currentTimeMillis();
// logger.info(" get request complete: {}/{}/{} [{}ms] {}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id(),
// (t1 - t0), response.exists());
// return response;
// }
//
// }
|
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.settings.Settings;
import org.xbib.elasticsearch.action.search.helper.BasicGetRequest;
import org.xbib.elasticsearch.action.search.helper.BasicSearchRequest;
import java.io.IOException;
import java.util.Map;
|
/*
* Copyright (C) 2015 Jörg Prante
*
* 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.xbib.elasticsearch.helper.client;
/**
* Search support
*/
public interface Search {
Search init(Settings settings) throws IOException;
Search init(Map<String, String> settings) throws IOException;
/**
* Return the Elasticsearch client
*
* @return the client
*/
ElasticsearchClient client();
/**
* Get index
*
* @return the index
*/
String getIndex();
/**
* Set index
*
* @param index index
* @return this search
*/
Search setIndex(String index);
/**
* Create new search request
*
* @return this search request
*/
BasicSearchRequest newSearchRequest();
/**
* Create new get request
*
* @return this search request
*/
|
// Path: src/main/java/org/xbib/elasticsearch/action/search/helper/BasicGetRequest.java
// public class BasicGetRequest {
//
// private final ESLogger logger = ESLoggerFactory.getLogger(BasicGetRequest.class.getName());
//
// private GetRequestBuilder getRequestBuilder;
//
// private String index;
//
// private String type;
//
// private String id;
//
// public BasicGetRequest newRequest(GetRequestBuilder getRequestBuilder) {
// this.getRequestBuilder = getRequestBuilder;
// return this;
// }
//
// public GetRequestBuilder getRequestBuilder() {
// return getRequestBuilder;
// }
//
// public BasicGetRequest index(String index) {
// if (index != null && !"*".equals(index)) {
// this.index = index;
// }
// return this;
// }
//
// public String index() {
// return index;
// }
//
// public BasicGetRequest type(String type) {
// if (type != null && !"*".equals(type)) {
// this.type = type;
// }
// return this;
// }
//
// public String type() {
// return type;
// }
//
// public BasicGetRequest id(String id) {
// this.id = id;
// return this;
// }
//
// public String id() {
// return id;
// }
//
// public BasicGetResponse execute() throws IOException {
// BasicGetResponse response = new BasicGetResponse();
// if (getRequestBuilder == null) {
// return response;
// }
// logger.info(" get request: {}/{}/{}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id());
// getRequestBuilder
// .setIndex(index)
// .setType(type)
// .setId(id);
// long t0 = System.currentTimeMillis();
// response.setResponse(getRequestBuilder.execute().actionGet());
// long t1 = System.currentTimeMillis();
// logger.info(" get request complete: {}/{}/{} [{}ms] {}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id(),
// (t1 - t0), response.exists());
// return response;
// }
//
// }
// Path: src/main/java/org/xbib/elasticsearch/helper/client/Search.java
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.settings.Settings;
import org.xbib.elasticsearch.action.search.helper.BasicGetRequest;
import org.xbib.elasticsearch.action.search.helper.BasicSearchRequest;
import java.io.IOException;
import java.util.Map;
/*
* Copyright (C) 2015 Jörg Prante
*
* 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.xbib.elasticsearch.helper.client;
/**
* Search support
*/
public interface Search {
Search init(Settings settings) throws IOException;
Search init(Map<String, String> settings) throws IOException;
/**
* Return the Elasticsearch client
*
* @return the client
*/
ElasticsearchClient client();
/**
* Get index
*
* @return the index
*/
String getIndex();
/**
* Set index
*
* @param index index
* @return this search
*/
Search setIndex(String index);
/**
* Create new search request
*
* @return this search request
*/
BasicSearchRequest newSearchRequest();
/**
* Create new get request
*
* @return this search request
*/
|
BasicGetRequest newGetRequest();
|
jprante/elasticsearch-helper
|
src/main/java/org/xbib/elasticsearch/helper/client/SearchTransportClient.java
|
// Path: src/main/java/org/xbib/elasticsearch/action/search/helper/BasicGetRequest.java
// public class BasicGetRequest {
//
// private final ESLogger logger = ESLoggerFactory.getLogger(BasicGetRequest.class.getName());
//
// private GetRequestBuilder getRequestBuilder;
//
// private String index;
//
// private String type;
//
// private String id;
//
// public BasicGetRequest newRequest(GetRequestBuilder getRequestBuilder) {
// this.getRequestBuilder = getRequestBuilder;
// return this;
// }
//
// public GetRequestBuilder getRequestBuilder() {
// return getRequestBuilder;
// }
//
// public BasicGetRequest index(String index) {
// if (index != null && !"*".equals(index)) {
// this.index = index;
// }
// return this;
// }
//
// public String index() {
// return index;
// }
//
// public BasicGetRequest type(String type) {
// if (type != null && !"*".equals(type)) {
// this.type = type;
// }
// return this;
// }
//
// public String type() {
// return type;
// }
//
// public BasicGetRequest id(String id) {
// this.id = id;
// return this;
// }
//
// public String id() {
// return id;
// }
//
// public BasicGetResponse execute() throws IOException {
// BasicGetResponse response = new BasicGetResponse();
// if (getRequestBuilder == null) {
// return response;
// }
// logger.info(" get request: {}/{}/{}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id());
// getRequestBuilder
// .setIndex(index)
// .setType(type)
// .setId(id);
// long t0 = System.currentTimeMillis();
// response.setResponse(getRequestBuilder.execute().actionGet());
// long t1 = System.currentTimeMillis();
// logger.info(" get request complete: {}/{}/{} [{}ms] {}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id(),
// (t1 - t0), response.exists());
// return response;
// }
//
// }
|
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.xbib.elasticsearch.action.search.helper.BasicGetRequest;
import org.xbib.elasticsearch.action.search.helper.BasicSearchRequest;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
|
}
@Override
public SearchTransportClient init(Map<String, String> settings) throws IOException {
init(Settings.builder().put(settings).build());
return this;
}
@Override
public SearchTransportClient init(Settings settings) throws IOException {
super.createClient(settings);
Collection<InetSocketTransportAddress> addrs = findAddresses(settings);
if (!connect(addrs, settings.getAsBoolean("autodiscover", false))) {
throw new NoNodeAvailableException("no cluster nodes available, check settings "
+ settings.getAsMap());
}
return this;
}
public Client client() {
return client;
}
@Override
public BasicSearchRequest newSearchRequest() {
return new BasicSearchRequest()
.newRequest(client.prepareSearch());
}
@Override
|
// Path: src/main/java/org/xbib/elasticsearch/action/search/helper/BasicGetRequest.java
// public class BasicGetRequest {
//
// private final ESLogger logger = ESLoggerFactory.getLogger(BasicGetRequest.class.getName());
//
// private GetRequestBuilder getRequestBuilder;
//
// private String index;
//
// private String type;
//
// private String id;
//
// public BasicGetRequest newRequest(GetRequestBuilder getRequestBuilder) {
// this.getRequestBuilder = getRequestBuilder;
// return this;
// }
//
// public GetRequestBuilder getRequestBuilder() {
// return getRequestBuilder;
// }
//
// public BasicGetRequest index(String index) {
// if (index != null && !"*".equals(index)) {
// this.index = index;
// }
// return this;
// }
//
// public String index() {
// return index;
// }
//
// public BasicGetRequest type(String type) {
// if (type != null && !"*".equals(type)) {
// this.type = type;
// }
// return this;
// }
//
// public String type() {
// return type;
// }
//
// public BasicGetRequest id(String id) {
// this.id = id;
// return this;
// }
//
// public String id() {
// return id;
// }
//
// public BasicGetResponse execute() throws IOException {
// BasicGetResponse response = new BasicGetResponse();
// if (getRequestBuilder == null) {
// return response;
// }
// logger.info(" get request: {}/{}/{}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id());
// getRequestBuilder
// .setIndex(index)
// .setType(type)
// .setId(id);
// long t0 = System.currentTimeMillis();
// response.setResponse(getRequestBuilder.execute().actionGet());
// long t1 = System.currentTimeMillis();
// logger.info(" get request complete: {}/{}/{} [{}ms] {}",
// getRequestBuilder.request().index(),
// getRequestBuilder.request().type(),
// getRequestBuilder.request().id(),
// (t1 - t0), response.exists());
// return response;
// }
//
// }
// Path: src/main/java/org/xbib/elasticsearch/helper/client/SearchTransportClient.java
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.xbib.elasticsearch.action.search.helper.BasicGetRequest;
import org.xbib.elasticsearch.action.search.helper.BasicSearchRequest;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
}
@Override
public SearchTransportClient init(Map<String, String> settings) throws IOException {
init(Settings.builder().put(settings).build());
return this;
}
@Override
public SearchTransportClient init(Settings settings) throws IOException {
super.createClient(settings);
Collection<InetSocketTransportAddress> addrs = findAddresses(settings);
if (!connect(addrs, settings.getAsBoolean("autodiscover", false))) {
throw new NoNodeAvailableException("no cluster nodes available, check settings "
+ settings.getAsMap());
}
return this;
}
public Client client() {
return client;
}
@Override
public BasicSearchRequest newSearchRequest() {
return new BasicSearchRequest()
.newRequest(client.prepareSearch());
}
@Override
|
public BasicGetRequest newGetRequest() {
|
alexruiz/dw-lombok
|
src/eclipse/lombok/eclipse/handlers/MethodBuilder.java
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static MethodDeclaration methodDeclaration(CompilationResult compilationResult, ASTNode source) {
// MethodDeclaration method = new MethodDeclaration(compilationResult);
// copySourceStartAndEnt(source, method);
// setGeneratedBy(method, source);
// return method;
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/MemberChecks.java
// static boolean isField(EclipseNode node) {
// return FIELD.equals(node.getKind());
// }
|
import static lombok.core.util.Arrays.*;
import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
import static lombok.eclipse.handlers.Eclipse.methodDeclaration;
import static lombok.eclipse.handlers.MemberChecks.isField;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
|
}
MethodBuilder withReturnType(TypeReference newReturnType) {
returnType = newReturnType;
return this;
}
MethodBuilder withParameters(Argument[] newParameters) {
parameters = copy(newParameters);
return this;
}
MethodBuilder withThrowsClauses(TypeReference[] newThrowsClauses) {
throwsClauses = copy(newThrowsClauses);
return this;
}
MethodBuilder withBody(Statement[] newBody) {
body = copy(newBody);
return this;
}
MethodBuilder withAnnotations(Annotation[] newAnnotations) {
annotations = copy(newAnnotations);
return this;
}
MethodDeclaration buildWith(EclipseNode node) {
TypeDeclaration parent = parentOf(node);
ASTNode source = node.get();
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static MethodDeclaration methodDeclaration(CompilationResult compilationResult, ASTNode source) {
// MethodDeclaration method = new MethodDeclaration(compilationResult);
// copySourceStartAndEnt(source, method);
// setGeneratedBy(method, source);
// return method;
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/MemberChecks.java
// static boolean isField(EclipseNode node) {
// return FIELD.equals(node.getKind());
// }
// Path: src/eclipse/lombok/eclipse/handlers/MethodBuilder.java
import static lombok.core.util.Arrays.*;
import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
import static lombok.eclipse.handlers.Eclipse.methodDeclaration;
import static lombok.eclipse.handlers.MemberChecks.isField;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
}
MethodBuilder withReturnType(TypeReference newReturnType) {
returnType = newReturnType;
return this;
}
MethodBuilder withParameters(Argument[] newParameters) {
parameters = copy(newParameters);
return this;
}
MethodBuilder withThrowsClauses(TypeReference[] newThrowsClauses) {
throwsClauses = copy(newThrowsClauses);
return this;
}
MethodBuilder withBody(Statement[] newBody) {
body = copy(newBody);
return this;
}
MethodBuilder withAnnotations(Annotation[] newAnnotations) {
annotations = copy(newAnnotations);
return this;
}
MethodDeclaration buildWith(EclipseNode node) {
TypeDeclaration parent = parentOf(node);
ASTNode source = node.get();
|
MethodDeclaration method = methodDeclaration(parent.compilationResult, source);
|
alexruiz/dw-lombok
|
src/eclipse/lombok/eclipse/handlers/MethodBuilder.java
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static MethodDeclaration methodDeclaration(CompilationResult compilationResult, ASTNode source) {
// MethodDeclaration method = new MethodDeclaration(compilationResult);
// copySourceStartAndEnt(source, method);
// setGeneratedBy(method, source);
// return method;
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/MemberChecks.java
// static boolean isField(EclipseNode node) {
// return FIELD.equals(node.getKind());
// }
|
import static lombok.core.util.Arrays.*;
import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
import static lombok.eclipse.handlers.Eclipse.methodDeclaration;
import static lombok.eclipse.handlers.MemberChecks.isField;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
|
}
MethodBuilder withBody(Statement[] newBody) {
body = copy(newBody);
return this;
}
MethodBuilder withAnnotations(Annotation[] newAnnotations) {
annotations = copy(newAnnotations);
return this;
}
MethodDeclaration buildWith(EclipseNode node) {
TypeDeclaration parent = parentOf(node);
ASTNode source = node.get();
MethodDeclaration method = methodDeclaration(parent.compilationResult, source);
method.modifiers = modifiers;
method.returnType = returnType;
method.arguments = parameters;
method.selector = name;
method.thrownExceptions = throwsClauses;
method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
method.bodyStart = method.declarationSourceStart = method.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd;
method.statements = body;
if (isNotEmpty(annotations)) method.annotations = annotations;
return method;
}
private TypeDeclaration parentOf(EclipseNode node) {
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static MethodDeclaration methodDeclaration(CompilationResult compilationResult, ASTNode source) {
// MethodDeclaration method = new MethodDeclaration(compilationResult);
// copySourceStartAndEnt(source, method);
// setGeneratedBy(method, source);
// return method;
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/MemberChecks.java
// static boolean isField(EclipseNode node) {
// return FIELD.equals(node.getKind());
// }
// Path: src/eclipse/lombok/eclipse/handlers/MethodBuilder.java
import static lombok.core.util.Arrays.*;
import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
import static lombok.eclipse.handlers.Eclipse.methodDeclaration;
import static lombok.eclipse.handlers.MemberChecks.isField;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
}
MethodBuilder withBody(Statement[] newBody) {
body = copy(newBody);
return this;
}
MethodBuilder withAnnotations(Annotation[] newAnnotations) {
annotations = copy(newAnnotations);
return this;
}
MethodDeclaration buildWith(EclipseNode node) {
TypeDeclaration parent = parentOf(node);
ASTNode source = node.get();
MethodDeclaration method = methodDeclaration(parent.compilationResult, source);
method.modifiers = modifiers;
method.returnType = returnType;
method.arguments = parameters;
method.selector = name;
method.thrownExceptions = throwsClauses;
method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
method.bodyStart = method.declarationSourceStart = method.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd;
method.statements = body;
if (isNotEmpty(annotations)) method.annotations = annotations;
return method;
}
private TypeDeclaration parentOf(EclipseNode node) {
|
if (isField(node)) return (TypeDeclaration) node.up().get();
|
alexruiz/dw-lombok
|
src/eclipse/lombok/eclipse/handlers/FieldBuilder.java
|
// Path: src/core/lombok/core/util/Arrays.java
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static TypeReference qualifiedTypeReference(Class<?> type, ASTNode source) {
// long p = posNom(source);
// return new QualifiedTypeReference(fromQualifiedName(type.getName()), new long[] { p, p, p });
// }
|
import static lombok.core.util.Arrays.copy;
import static lombok.eclipse.Eclipse.setGeneratedBy;
import static lombok.eclipse.handlers.Eclipse.qualifiedTypeReference;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
|
/*
* Created on Dec 6, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.eclipse.handlers;
/**
* Utility methods related to generation of fields.
*
* @author Alex Ruiz
*/
final class FieldBuilder {
private static final Expression[] NO_ARGS = new Expression[0];
static FieldBuilder newField() {
return new FieldBuilder();
}
private Class<?> type;
private String name;
private int modifiers;
private Expression[] args = NO_ARGS;
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(int newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(Expression...newArgs) {
|
// Path: src/core/lombok/core/util/Arrays.java
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static TypeReference qualifiedTypeReference(Class<?> type, ASTNode source) {
// long p = posNom(source);
// return new QualifiedTypeReference(fromQualifiedName(type.getName()), new long[] { p, p, p });
// }
// Path: src/eclipse/lombok/eclipse/handlers/FieldBuilder.java
import static lombok.core.util.Arrays.copy;
import static lombok.eclipse.Eclipse.setGeneratedBy;
import static lombok.eclipse.handlers.Eclipse.qualifiedTypeReference;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
/*
* Created on Dec 6, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.eclipse.handlers;
/**
* Utility methods related to generation of fields.
*
* @author Alex Ruiz
*/
final class FieldBuilder {
private static final Expression[] NO_ARGS = new Expression[0];
static FieldBuilder newField() {
return new FieldBuilder();
}
private Class<?> type;
private String name;
private int modifiers;
private Expression[] args = NO_ARGS;
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(int newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(Expression...newArgs) {
|
args = copy(newArgs);
|
alexruiz/dw-lombok
|
src/eclipse/lombok/eclipse/handlers/FieldBuilder.java
|
// Path: src/core/lombok/core/util/Arrays.java
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static TypeReference qualifiedTypeReference(Class<?> type, ASTNode source) {
// long p = posNom(source);
// return new QualifiedTypeReference(fromQualifiedName(type.getName()), new long[] { p, p, p });
// }
|
import static lombok.core.util.Arrays.copy;
import static lombok.eclipse.Eclipse.setGeneratedBy;
import static lombok.eclipse.handlers.Eclipse.qualifiedTypeReference;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
|
private String name;
private int modifiers;
private Expression[] args = NO_ARGS;
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(int newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(Expression...newArgs) {
args = copy(newArgs);
return this;
}
FieldDeclaration buildWith(EclipseNode node) {
ASTNode source = node.get();
FieldDeclaration fieldDecl = new FieldDeclaration(name.toCharArray(), source.sourceStart, source.sourceEnd);
setGeneratedBy(fieldDecl, source);
fieldDecl.declarationSourceEnd = -1;
fieldDecl.modifiers = modifiers;
|
// Path: src/core/lombok/core/util/Arrays.java
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// Path: src/eclipse/lombok/eclipse/handlers/Eclipse.java
// static TypeReference qualifiedTypeReference(Class<?> type, ASTNode source) {
// long p = posNom(source);
// return new QualifiedTypeReference(fromQualifiedName(type.getName()), new long[] { p, p, p });
// }
// Path: src/eclipse/lombok/eclipse/handlers/FieldBuilder.java
import static lombok.core.util.Arrays.copy;
import static lombok.eclipse.Eclipse.setGeneratedBy;
import static lombok.eclipse.handlers.Eclipse.qualifiedTypeReference;
import lombok.eclipse.EclipseNode;
import org.eclipse.jdt.internal.compiler.ast.*;
private String name;
private int modifiers;
private Expression[] args = NO_ARGS;
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(int newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(Expression...newArgs) {
args = copy(newArgs);
return this;
}
FieldDeclaration buildWith(EclipseNode node) {
ASTNode source = node.get();
FieldDeclaration fieldDecl = new FieldDeclaration(name.toCharArray(), source.sourceStart, source.sourceEnd);
setGeneratedBy(fieldDecl, source);
fieldDecl.declarationSourceEnd = -1;
fieldDecl.modifiers = modifiers;
|
fieldDecl.type = qualifiedTypeReference(type, source);
|
alexruiz/dw-lombok
|
src/javac/lombok/javac/handlers/FieldBuilder.java
|
// Path: src/core/lombok/core/util/Names.java
// public static String[] splitNameOf(Class<?> type) {
// return type.getName().split("\\.");
// }
|
import static com.sun.tools.javac.util.List.nil;
import static lombok.core.util.Names.splitNameOf;
import static lombok.javac.handlers.JavacHandlerUtil.chainDots;
import lombok.javac.JavacNode;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.List;
|
/*
* Created on Nov 30, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.javac.handlers;
/**
* Simplifies creation of fields.
*
* @author Alex Ruiz
*/
class FieldBuilder {
static FieldBuilder newField() {
return new FieldBuilder();
}
private Class<?> type;
private String name;
private long modifiers;
private List<JCExpression> args = nil();
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(long newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(JCExpression... newArgs) {
args = List.from(newArgs);
return this;
}
JCVariableDecl buildWith(JavacNode node) {
TreeMaker treeMaker = node.getTreeMaker();
|
// Path: src/core/lombok/core/util/Names.java
// public static String[] splitNameOf(Class<?> type) {
// return type.getName().split("\\.");
// }
// Path: src/javac/lombok/javac/handlers/FieldBuilder.java
import static com.sun.tools.javac.util.List.nil;
import static lombok.core.util.Names.splitNameOf;
import static lombok.javac.handlers.JavacHandlerUtil.chainDots;
import lombok.javac.JavacNode;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.List;
/*
* Created on Nov 30, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.javac.handlers;
/**
* Simplifies creation of fields.
*
* @author Alex Ruiz
*/
class FieldBuilder {
static FieldBuilder newField() {
return new FieldBuilder();
}
private Class<?> type;
private String name;
private long modifiers;
private List<JCExpression> args = nil();
FieldBuilder ofType(Class<?> newType) {
type = newType;
return this;
}
FieldBuilder withName(String newName) {
name = newName;
return this;
}
FieldBuilder withModifiers(long newModifiers) {
modifiers = newModifiers;
return this;
}
FieldBuilder withArgs(JCExpression... newArgs) {
args = List.from(newArgs);
return this;
}
JCVariableDecl buildWith(JavacNode node) {
TreeMaker treeMaker = node.getTreeMaker();
|
JCExpression classType = chainDots(treeMaker, node, splitNameOf(type));
|
alexruiz/dw-lombok
|
test/core/lombok/core/util/Arrays_isNotEmpty_Test.java
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
|
import static org.fest.assertions.Assertions.assertThat;
import lombok.core.util.Arrays;
import org.junit.Test;
|
/*
* Created on Dec 8, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.core.util;
/**
* Tests for <code>{@link Arrays#isNotEmpty(Object[])}</code>.
*
* @author Alex Ruiz
*/
public class Arrays_isNotEmpty_Test {
@Test public void should_return_false_if_array_is_null() {
|
// Path: src/core/lombok/core/util/Arrays.java
// public final class Arrays {
//
// /**
// * Convenience method for creating arrays.
// * @param <T> the type of elements of the array.
// * @param elements the array, in varargs form.
// * @return the given array in varargs form.
// */
// public static <T> T[] array(T...elements) {
// return elements;
// }
//
// /**
// * Returns a copy of the given array.
// * @param <T> the type of the given array.
// * @param array the given array.
// * @return a copy of the given array.
// */
// public static <T> T[] copy(T[] array) {
// return copyOf(array, array.length);
// }
//
// /**
// * Indicates whether the given array has elements or not.
// * @param array the given array.
// * @return {@code true} if the given array is not {@code null} and contains at least one element; {@code false}
// * otherwise.
// */
// public static boolean isNotEmpty(Object[] array) {
// return array != null && array.length > 0;
// }
//
// private Arrays() {}
// }
// Path: test/core/lombok/core/util/Arrays_isNotEmpty_Test.java
import static org.fest.assertions.Assertions.assertThat;
import lombok.core.util.Arrays;
import org.junit.Test;
/*
* Created on Dec 8, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright @2010 the original author or authors.
*/
package lombok.core.util;
/**
* Tests for <code>{@link Arrays#isNotEmpty(Object[])}</code>.
*
* @author Alex Ruiz
*/
public class Arrays_isNotEmpty_Test {
@Test public void should_return_false_if_array_is_null() {
|
assertThat(Arrays.isNotEmpty(null)).isFalse();
|
cbg-ethz/InDelFixer
|
src/main/java/jaligner/NeedlemanWunschGotoh.java
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
|
import jaligner.matrix.Matrix;
import java.util.logging.Logger;
|
/*
* $Id: NeedlemanWunschGotoh.java,v 1.12 2006/04/05 00:18:30 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Needleman-Wunsch algorithm with Gotoh's improvement
* for biological global pairwise sequence alignment.
*
* @author Ahmed Moustafa
* @author Bram Minnaert
* @version $Revision: 1.12 $
*/
public final class NeedlemanWunschGotoh {
/**
* Logger
*/
private static final Logger logger = Logger
.getLogger(NeedlemanWunschGotoh.class.getSimpleName());
/**
* Hidden constructor
*/
private NeedlemanWunschGotoh() {
super();
}
/**
* Aligns two sequences by Needleman-Wunsch (global)
*
* @param s1
* sequene #1 ({@link Read})
* @param s2
* sequene #2 ({@link Read})
* @param matrix
* scoring matrix ({@link Matrix})
* @param o
* open gap penalty
* @param e
* extend gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Read
* @see Matrix
*/
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
// Path: src/main/java/jaligner/NeedlemanWunschGotoh.java
import jaligner.matrix.Matrix;
import java.util.logging.Logger;
/*
* $Id: NeedlemanWunschGotoh.java,v 1.12 2006/04/05 00:18:30 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Needleman-Wunsch algorithm with Gotoh's improvement
* for biological global pairwise sequence alignment.
*
* @author Ahmed Moustafa
* @author Bram Minnaert
* @version $Revision: 1.12 $
*/
public final class NeedlemanWunschGotoh {
/**
* Logger
*/
private static final Logger logger = Logger
.getLogger(NeedlemanWunschGotoh.class.getSimpleName());
/**
* Hidden constructor
*/
private NeedlemanWunschGotoh() {
super();
}
/**
* Aligns two sequences by Needleman-Wunsch (global)
*
* @param s1
* sequene #1 ({@link Read})
* @param s2
* sequene #2 ({@link Read})
* @param matrix
* scoring matrix ({@link Matrix})
* @param o
* open gap penalty
* @param e
* extend gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Read
* @see Matrix
*/
|
public static Alignment align(Sequence s1, Sequence s2, Matrix matrix,
|
cbg-ethz/InDelFixer
|
src/main/java/jaligner/SmithWatermanGotoh.java
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
|
import jaligner.matrix.Matrix;
import java.util.logging.Logger;
|
/*
* $Id: SmithWatermanGotoh.java,v 1.10 2006/02/09 13:27:36 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Smith-Waterman algorithm with Gotoh's improvement
* for biological local pairwise sequence alignment.
*
* <strong>Recursive definition:</strong>
* <ul>
* <li>
* <strong>Base conditions:</strong>
* <ul>
* <li><code>V(0, 0) = 0</code></li>
* <li><code>V(i, 0) = E(i, 0) = W<sub>g</sub> + iW<sub>s</sub></code></li>
* <li><code>V(0, j) = F(0, j) = W<sub>g</sub> + jW<sub>s</sub></code></li>
* </ul>
* </li>
* <li>
* <strong>Recurrence relation:</strong>
* <ul>
* <li><code>V(i, j) = max{E(i, j), F(i, j), G(i, j)}</code>, where:</li>
* <li><code>G(i, j) = V(i - 1, j - 1) + similarity(S<sub>i</sub>, T<sub>j</sub>)</code></li>
* <li><code>E(i, j) = max{E(i, j - 1) + W<sub>s</sub>, V(i, j - 1) + W<sub>g</sub> + W<sub>s</sub>}</code></li>
* <li><code>F(i, j) = max{F(i - 1, j) + W<sub>s</sub>, V(i - 1, j) + W<sub>g</sub> + W<sub>s</sub>}</code></li>
* </ul>
* </ul>
*
* @author Ahmed Moustafa ([email protected])
*/
public final class SmithWatermanGotoh {
/**
* Hidden constructor
*/
private SmithWatermanGotoh() {
super();
}
/**
* Aligns two sequences by Smith-Waterman (local)
*
* @param s1 sequene #1 ({@link Sequence})
* @param s2 sequene #2 ({@link Sequence})
* @param matrix scoring matrix ({@link Matrix})
* @param o open gap penalty
* @param e extend gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Sequence
* @see Matrix
*/
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
// Path: src/main/java/jaligner/SmithWatermanGotoh.java
import jaligner.matrix.Matrix;
import java.util.logging.Logger;
/*
* $Id: SmithWatermanGotoh.java,v 1.10 2006/02/09 13:27:36 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Smith-Waterman algorithm with Gotoh's improvement
* for biological local pairwise sequence alignment.
*
* <strong>Recursive definition:</strong>
* <ul>
* <li>
* <strong>Base conditions:</strong>
* <ul>
* <li><code>V(0, 0) = 0</code></li>
* <li><code>V(i, 0) = E(i, 0) = W<sub>g</sub> + iW<sub>s</sub></code></li>
* <li><code>V(0, j) = F(0, j) = W<sub>g</sub> + jW<sub>s</sub></code></li>
* </ul>
* </li>
* <li>
* <strong>Recurrence relation:</strong>
* <ul>
* <li><code>V(i, j) = max{E(i, j), F(i, j), G(i, j)}</code>, where:</li>
* <li><code>G(i, j) = V(i - 1, j - 1) + similarity(S<sub>i</sub>, T<sub>j</sub>)</code></li>
* <li><code>E(i, j) = max{E(i, j - 1) + W<sub>s</sub>, V(i, j - 1) + W<sub>g</sub> + W<sub>s</sub>}</code></li>
* <li><code>F(i, j) = max{F(i - 1, j) + W<sub>s</sub>, V(i - 1, j) + W<sub>g</sub> + W<sub>s</sub>}</code></li>
* </ul>
* </ul>
*
* @author Ahmed Moustafa ([email protected])
*/
public final class SmithWatermanGotoh {
/**
* Hidden constructor
*/
private SmithWatermanGotoh() {
super();
}
/**
* Aligns two sequences by Smith-Waterman (local)
*
* @param s1 sequene #1 ({@link Sequence})
* @param s2 sequene #2 ({@link Sequence})
* @param matrix scoring matrix ({@link Matrix})
* @param o open gap penalty
* @param e extend gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Sequence
* @see Matrix
*/
|
public static Alignment align(Sequence s1, Sequence s2, Matrix matrix,
|
cbg-ethz/InDelFixer
|
src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFFile.java
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/utils/StatusUpdate.java
// public class StatusUpdate {
//
// private static final long start = System.currentTimeMillis();
// private static final DateFormat df;
// public static int readCount = 0;
// public static int unmappedCount = 0;
// public static int tooSmallCount = 0;
// public static int alignCount1 = 0;
// public static int alignCount2 = 0;
// public static int alignCount3 = 0;
// private static String oldOut = "";
//
// static {
// df = new SimpleDateFormat("HH:mm:ss");
// df.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
//
// public static void print(String text, double percentage) {
// System.out.print("\r" + time() + " " + text + Math.round(percentage * 100) / 100 + "%");
// }
//
// public static void print(String text) {
// System.out.print("\r" + time() + " " + text);
// }
//
// public synchronized static void processReads() {
// readCount++;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + readCount + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public synchronized static void processUnmapped() {
// ++unmappedCount;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public synchronized static void processLength() {
// ++tooSmallCount;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public static void println(String text) {
// System.out.println("\r" + time() + " " + text);
// }
//
// private static String time() {
// return df.format(new Date(System.currentTimeMillis() - start));
// }
// }
|
import ch.ethz.bsse.indelfixer.utils.StatusUpdate;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
|
byte[] flowCharsByte = new byte[numberOfFlowsPerReadBig.intValue()];
raf.read(flowCharsByte);
flowChars = new String(flowCharsByte);
// keySequence
byte[] keySequenceByte = new byte[keyLengthBig.intValue()];
raf.read(keySequenceByte);
keySequence = new String(keySequenceByte);
// go to index location
raf.seek(indexOffsetBig.longValue());
// indexMagicNumber
byte[] indexMagicNumberByte = new byte[4];
raf.read(indexMagicNumberByte);
BigInteger indexMagicNumberBig = new BigInteger(indexMagicNumberByte);
indexMagicNumber = indexMagicNumberBig.intValue();
// indexVersion
byte[] indexVersionByte = new byte[4];
raf.read(indexVersionByte);
indexVersion = new String(indexVersionByte);
}
/**
* Creates an index of the sff file by scanning the file.
*
* @throws IOException
*/
private void createIndex() throws IOException {
// go to first read
offset = eightBytePadding(headerLength);
int indexing = 0;
while (offset < indexOffset) {
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/utils/StatusUpdate.java
// public class StatusUpdate {
//
// private static final long start = System.currentTimeMillis();
// private static final DateFormat df;
// public static int readCount = 0;
// public static int unmappedCount = 0;
// public static int tooSmallCount = 0;
// public static int alignCount1 = 0;
// public static int alignCount2 = 0;
// public static int alignCount3 = 0;
// private static String oldOut = "";
//
// static {
// df = new SimpleDateFormat("HH:mm:ss");
// df.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
//
// public static void print(String text, double percentage) {
// System.out.print("\r" + time() + " " + text + Math.round(percentage * 100) / 100 + "%");
// }
//
// public static void print(String text) {
// System.out.print("\r" + time() + " " + text);
// }
//
// public synchronized static void processReads() {
// readCount++;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + readCount + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public synchronized static void processUnmapped() {
// ++unmappedCount;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public synchronized static void processLength() {
// ++tooSmallCount;
// if (!oldOut.equals(time())) {
// oldOut = time();
// System.out.print("\r ");
// System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
// }
// }
//
// public static void println(String text) {
// System.out.println("\r" + time() + " " + text);
// }
//
// private static String time() {
// return df.format(new Date(System.currentTimeMillis() - start));
// }
// }
// Path: src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFFile.java
import ch.ethz.bsse.indelfixer.utils.StatusUpdate;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
byte[] flowCharsByte = new byte[numberOfFlowsPerReadBig.intValue()];
raf.read(flowCharsByte);
flowChars = new String(flowCharsByte);
// keySequence
byte[] keySequenceByte = new byte[keyLengthBig.intValue()];
raf.read(keySequenceByte);
keySequence = new String(keySequenceByte);
// go to index location
raf.seek(indexOffsetBig.longValue());
// indexMagicNumber
byte[] indexMagicNumberByte = new byte[4];
raf.read(indexMagicNumberByte);
BigInteger indexMagicNumberBig = new BigInteger(indexMagicNumberByte);
indexMagicNumber = indexMagicNumberBig.intValue();
// indexVersion
byte[] indexVersionByte = new byte[4];
raf.read(indexVersionByte);
indexVersion = new String(indexVersionByte);
}
/**
* Creates an index of the sff file by scanning the file.
*
* @throws IOException
*/
private void createIndex() throws IOException {
// go to first read
offset = eightBytePadding(headerLength);
int indexing = 0;
while (offset < indexOffset) {
|
StatusUpdate.print("Indexing SFF:\t\t" + indexing++);
|
cbg-ethz/InDelFixer
|
src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFParsing.java
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
//
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/SimpleRead.java
// public class SimpleRead {
// public String read;
// public String quality;
//
// public SimpleRead(String read, String quality) {
// this.read = read;
// this.quality = quality;
// }
//
// }
|
import ch.ethz.bsse.indelfixer.stored.Globals;
import ch.ethz.bsse.indelfixer.stored.SimpleRead;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
|
/**
* Copyright (c) 2011-2013 Armin Töpfer
*
* This file is part of InDelFixer.
*
* InDelFixer is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or any later version.
*
* InDelFixer is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* InDelFixer. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.ethz.bsse.indelfixer.sffParser;
/**
* @author Armin Töpfer (armin.toepfer [at] gmail.com)
*/
public class SFFParsing {
public static SimpleRead[] parse(String path) {
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
//
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/SimpleRead.java
// public class SimpleRead {
// public String read;
// public String quality;
//
// public SimpleRead(String read, String quality) {
// this.read = read;
// this.quality = quality;
// }
//
// }
// Path: src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFParsing.java
import ch.ethz.bsse.indelfixer.stored.Globals;
import ch.ethz.bsse.indelfixer.stored.SimpleRead;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Copyright (c) 2011-2013 Armin Töpfer
*
* This file is part of InDelFixer.
*
* InDelFixer is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or any later version.
*
* InDelFixer is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* InDelFixer. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.ethz.bsse.indelfixer.sffParser;
/**
* @author Armin Töpfer (armin.toepfer [at] gmail.com)
*/
public class SFFParsing {
public static SimpleRead[] parse(String path) {
|
Globals.N = 0;
|
cbg-ethz/InDelFixer
|
src/main/java/jaligner/NeedlemanWunsch.java
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
|
import jaligner.matrix.Matrix;
|
/*
* $Id: NeedlemanWunsch.java,v 1.4 2006/02/09 12:23:24 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Needleman-Wunsch algorithm for biological global
* pairwise sequence alignment.
*
* <br>
* Reference: <a
* href="http://www.sbc.su.se/~per/molbioinfo2001/dynprog/adv_dynamic.html">Advanced
* Dynamic Programming Tutorial</a>.
*
*
* @author <a href="[email protected]">Ahmed Moustafa</a>
*/
public final class NeedlemanWunsch {
/**
* Hidden constructor
*/
private NeedlemanWunsch() {
super();
}
/**
* Aligns two sequences by Needleman-Wunsch (global)
*
* @param s1
* sequene #1 ({@link Sequence})
* @param s2
* sequene #2 ({@link Sequence})
* @param matrix
* scoring matrix ({@link Matrix})
* @param gap
* open gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Sequence
* @see Matrix
*/
|
// Path: src/main/java/jaligner/matrix/Matrix.java
// public class Matrix implements Serializable {
// /**
// *
// */
// private static final long serialVersionUID = 3833742170619524400L;
//
// /**
// * The size of the scoring matrix. It is the number of the characters in the
// * ASCII table. It is more than the 20 amino acids just to save the
// * processing time of the mapping.
// */
// public static final int SIZE = 127;
//
// /**
// * Matrix id (or name)
// */
// private final String id;
//
// /**
// * Scores
// */
// private final float[][] scores;
//
// public Matrix(String id, float[][] scores) {
// this.id = id;
// this.scores = scores;
// }
//
// /**
// * @return Returns the id.
// */
// public String getId() {
// return this.id;
// }
//
// /**
// * @return Returns the scores.
// */
// public float[][] getScores() {
// return this.scores;
// }
//
// /**
// *
// * @param a
// * @param b
// * @return score
// */
// public float getScore(char a, char b) {
// return this.scores[a][b];
// }
// }
// Path: src/main/java/jaligner/NeedlemanWunsch.java
import jaligner.matrix.Matrix;
/*
* $Id: NeedlemanWunsch.java,v 1.4 2006/02/09 12:23:24 ahmed Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jaligner;
/**
* An implementation of the Needleman-Wunsch algorithm for biological global
* pairwise sequence alignment.
*
* <br>
* Reference: <a
* href="http://www.sbc.su.se/~per/molbioinfo2001/dynprog/adv_dynamic.html">Advanced
* Dynamic Programming Tutorial</a>.
*
*
* @author <a href="[email protected]">Ahmed Moustafa</a>
*/
public final class NeedlemanWunsch {
/**
* Hidden constructor
*/
private NeedlemanWunsch() {
super();
}
/**
* Aligns two sequences by Needleman-Wunsch (global)
*
* @param s1
* sequene #1 ({@link Sequence})
* @param s2
* sequene #2 ({@link Sequence})
* @param matrix
* scoring matrix ({@link Matrix})
* @param gap
* open gap penalty
* @return alignment object contains the two aligned sequences, the
* alignment score and alignment statistics
* @see Sequence
* @see Matrix
*/
|
public static Alignment align(Sequence s1, Sequence s2, Matrix matrix,
|
cbg-ethz/InDelFixer
|
src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFRead.java
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
|
import ch.ethz.bsse.indelfixer.stored.Globals;
|
/**
* Copyright (c) 2011-2013 Armin Töpfer
*
* This file is part of InDelFixer.
*
* InDelFixer is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or any later version.
*
* InDelFixer is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* InDelFixer. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.ethz.bsse.indelfixer.sffParser;
/**
* @author Armin Töpfer (armin.toepfer [at] gmail.com)
*/
public class SFFRead {
private String read;
private char[] quality;
private double[] errorProbability;
private String description;
private int clipQualLeft;
private int clipQualRight;
private boolean clipped;
/**
*
* @param read
* @param quality
* @param description
* @param clipQualLeft
* @param clipQualRight
*/
public SFFRead(String read, char[] quality, String description, int clipQualLeft, int clipQualRight) {
this.read = read;
this.quality = quality;
this.description = description;
this.clipQualLeft = clipQualLeft;
this.clipQualRight = clipQualRight;
}
/**
*
*/
public void clip() {
if (clipQualLeft != 0 && clipQualRight != 0) {
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
// Path: src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFRead.java
import ch.ethz.bsse.indelfixer.stored.Globals;
/**
* Copyright (c) 2011-2013 Armin Töpfer
*
* This file is part of InDelFixer.
*
* InDelFixer is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or any later version.
*
* InDelFixer is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* InDelFixer. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.ethz.bsse.indelfixer.sffParser;
/**
* @author Armin Töpfer (armin.toepfer [at] gmail.com)
*/
public class SFFRead {
private String read;
private char[] quality;
private double[] errorProbability;
private String description;
private int clipQualLeft;
private int clipQualRight;
private boolean clipped;
/**
*
* @param read
* @param quality
* @param description
* @param clipQualLeft
* @param clipQualRight
*/
public SFFRead(String read, char[] quality, String description, int clipQualLeft, int clipQualRight) {
this.read = read;
this.quality = quality;
this.description = description;
this.clipQualLeft = clipQualLeft;
this.clipQualRight = clipQualRight;
}
/**
*
*/
public void clip() {
if (clipQualLeft != 0 && clipQualRight != 0) {
|
if (clipQualLeft < Globals.CUT) {
|
cbg-ethz/InDelFixer
|
src/main/java/ch/ethz/bsse/indelfixer/utils/FastaParser.java
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
|
import ch.ethz.bsse.indelfixer.stored.Globals;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
|
if (!lowerCase) {
if (Character.isLowerCase(c)) {
lowerCase = true;
continue;
}
}
if (!upperCase) {
if (Character.isUpperCase(c)) {
upperCase = true;
continue;
}
}
if (upperCase && lowerCase) {
cut = true;
break;
}
}
first = false;
}
if (cut) {
for (char c : strLine.toCharArray()) {
if (Character.isUpperCase(c)) {
sb.append(c);
}
}
} else {
sb.append(strLine);
}
}
}
|
// Path: src/main/java/ch/ethz/bsse/indelfixer/stored/Globals.java
// public class Globals {
//
// public static boolean NO_HASHING;
// public static boolean SENSITIVE;
// public static boolean CONSENSUS;
// public static int READCOUNTER = 0;
// public static int STEPS;
// public static List<SequenceEntry> TRASH_READS = new CopyOnWriteArrayList<>();
// public static boolean RM_DEL;
// public static boolean REFINE;
// public static boolean FILTER;
// public static boolean FLAT;
// public static float GOP;
// public static float GEX;
// public static double MAX_DEL;
// public static double MAX_INS;
// public static double MAX_SUB;
// public static boolean KEEP;
// public static List<Read> READS;
// public static int MAX_CONSECUTIVE_DEL;
// public static int MIN_LENGTH_ALIGNED;
// public static int MIN_LENGTH;
// public static int GENOME_LENGTH;
// public static int THRESHOLD;
// public static String[] GENOME_SEQUENCES;
// public static boolean ADJUST;
// public static boolean SAVE;
// public static int GENOME_COUNT;
// public static Genome[] GENOMES;
// public static int CUT = 0;
// public static int KMER_OVERLAP = 10;
// public static int KMER_LENGTH = 1;
// public static final ForkJoinPool fjPool = new ForkJoinPool();
// public static int N = 0;
// public static int maxN = 0;
// public static double PERCENTAGE_PROCESSING_READS = 0;
// public static double PERCENTAGE_EXTRACTING_READS = 0;
// public static double UNIDENTICAL = 0;
// public static String output = System.getProperty("user.dir") + File.separator;
// public static Matrix MATRIX = loadMatrix();
// public static int[] RS;
// public static String[] ADAPTER;
// public static double PLURALITY;
// public static double PLURALITY_N;
// public static int MIN_CONS_COV = 0;
// public static double Q;
// public static double REALIGN;
//
// /**
// *
// * @return
// */
// public static Matrix loadMatrix() {
// Matrix m = null;
// try {
// m = MatrixLoader.load("EDNAFULL");
// } catch (MatrixLoaderException ex) {
// System.err.println("Matrix error loading");
// }
// return m;
// }
//
// public static void printPercentageExtractingReads() {
// PERCENTAGE_EXTRACTING_READS += 100d / N;
// StatusUpdate.print("Extracting reads:\t", PERCENTAGE_EXTRACTING_READS);
// }
//
// public static void printPercentageProcessingReads() {
// PERCENTAGE_PROCESSING_READS += 100d / N;
// StatusUpdate.print("Processing reads:\t", PERCENTAGE_PROCESSING_READS);
// }
// }
// Path: src/main/java/ch/ethz/bsse/indelfixer/utils/FastaParser.java
import ch.ethz.bsse.indelfixer.stored.Globals;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
if (!lowerCase) {
if (Character.isLowerCase(c)) {
lowerCase = true;
continue;
}
}
if (!upperCase) {
if (Character.isUpperCase(c)) {
upperCase = true;
continue;
}
}
if (upperCase && lowerCase) {
cut = true;
break;
}
}
first = false;
}
if (cut) {
for (char c : strLine.toCharArray()) {
if (Character.isUpperCase(c)) {
sb.append(c);
}
}
} else {
sb.append(strLine);
}
}
}
|
readList.add(sb.toString().substring(Globals.CUT));
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ListWithEditTextPreference.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
|
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.core.text.BidiFormatter;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import static net.fabiszewski.ulogger.Alert.showAlert;
|
}
return super.getSummary();
}
/**
* Returns the index of the given value (in the entry values array).
*
* @param value The value whose index should be returned
* @return The index of the value, or -1 if not found
*/
@Override
public int findIndexOfValue(String value) {
int index = super.findIndexOfValue(value);
if (index == -1) {
return super.findIndexOfValue(OTHER);
} else {
return index;
}
}
/**
* Show dialog with EditText
* @param preference Preference
*/
private void showOtherDialog(Preference preference) {
Activity context = getActivity();
if (context == null) {
return;
}
final String key = preference.getKey();
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ListWithEditTextPreference.java
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.core.text.BidiFormatter;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import static net.fabiszewski.ulogger.Alert.showAlert;
}
return super.getSummary();
}
/**
* Returns the index of the given value (in the entry values array).
*
* @param value The value whose index should be returned
* @return The index of the value, or -1 if not found
*/
@Override
public int findIndexOfValue(String value) {
int index = super.findIndexOfValue(value);
if (index == -1) {
return super.findIndexOfValue(OTHER);
} else {
return index;
}
}
/**
* Show dialog with EditText
* @param preference Preference
*/
private void showOtherDialog(Preference preference) {
Activity context = getActivity();
if (context == null) {
return;
}
final String key = preference.getKey();
|
final AlertDialog dialog = showAlert(context,
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
|
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
|
* @param view View
*/
private void uploadData(View view) {
Context context = view.getContext();
if (!SettingsFragment.isValidServerSetup(context)) {
showToast(getString(R.string.provide_user_pass_url));
} else if (DbAccess.needsSync(context)) {
Intent syncIntent = new Intent(context, WebSyncService.class);
context.startService(syncIntent);
showToast(getString(R.string.uploading_started));
isUploading = true;
} else {
showToast(getString(R.string.nothing_to_synchronize));
}
}
/**
* Called when the user clicks the track text view
* @param view View
*/
private void trackSummary(View view) {
Context context = view.getContext();
final TrackSummary summary = DbAccess.getTrackSummary(context);
if (summary == null) {
showToast(getString(R.string.no_positions));
return;
}
MainActivity activity = (MainActivity) getActivity();
if (activity != null) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
* @param view View
*/
private void uploadData(View view) {
Context context = view.getContext();
if (!SettingsFragment.isValidServerSetup(context)) {
showToast(getString(R.string.provide_user_pass_url));
} else if (DbAccess.needsSync(context)) {
Intent syncIntent = new Intent(context, WebSyncService.class);
context.startService(syncIntent);
showToast(getString(R.string.uploading_started));
isUploading = true;
} else {
showToast(getString(R.string.nothing_to_synchronize));
}
}
/**
* Called when the user clicks the track text view
* @param view View
*/
private void trackSummary(View view) {
Context context = view.getContext();
final TrackSummary summary = DbAccess.getTrackSummary(context);
if (summary == null) {
showToast(getString(R.string.no_positions));
return;
}
MainActivity activity = (MainActivity) getActivity();
if (activity != null) {
|
final AlertDialog dialog = showAlert(activity,
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
|
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
|
distance *= KM_MILE;
unitName = getString(R.string.unit_mile);
} else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
distance *= KM_NMILE;
unitName = getString(R.string.unit_nmile);
}
final NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
final String distanceString = nf.format(distance);
if (summaryDistance != null) {
summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
}
final long h = summary.getDuration() / 3600;
final long m = summary.getDuration() % 3600 / 60;
if (summaryDuration != null) {
summaryDuration.setText(getString(R.string.summary_duration, h, m));
}
int positionsCount = (int) summary.getPositionsCount();
if (summaryPositions != null) {
summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
}
}
}
/**
* Display warning before deleting not synchronized track
*/
private void showNotSyncedWarning() {
Context context = getContext();
if (context != null) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
distance *= KM_MILE;
unitName = getString(R.string.unit_mile);
} else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
distance *= KM_NMILE;
unitName = getString(R.string.unit_nmile);
}
final NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
final String distanceString = nf.format(distance);
if (summaryDistance != null) {
summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
}
final long h = summary.getDuration() / 3600;
final long m = summary.getDuration() % 3600 / 60;
if (summaryDuration != null) {
summaryDuration.setText(getString(R.string.summary_duration, h, m));
}
int positionsCount = (int) summary.getPositionsCount();
if (summaryPositions != null) {
summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
}
}
}
/**
* Display warning before deleting not synchronized track
*/
private void showNotSyncedWarning() {
Context context = getContext();
if (context != null) {
|
showConfirm(context,
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
|
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
|
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
|
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
|
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.